Agent Behavioral Contracts II: Certifying Compositional Reliability Without Assuming Independence
Two instances of the same model failed together on 90% of missions where either failed — independence is not a safe assumption
Contracts · AgentAssert
AgentAssert brings formal behavioral contracts to AI agents. Define preconditions, invariants, governance policies and recovery using a domain-specific language. The system detects behavioral drift using Jensen-Shannon divergence and automatically triggers recovery re-prompting when agents violate their contracts. For agents you cannot change, the [proxy] extra runs AgentAssert as an HTTP proxy between the agent and its model provider and enforces the same contracts with no agent code changes.
Verify it yourself

Figures as reported by the project. Check them against the code and paper linked above.
Recipes
12 contract templates and 9 Python examples for runtime behavioral checks. Connect your observation fields, adapt the contract and inspect violations.
Working proof
Check an approval signal before your application proceeds with a protected action. The application supplies the signal and invokes the check.
python -m pip install "agentassert-abc[yaml,math]"The synthetic two-state proof returned no hard violations for true and raised ContractBreachError for false. It is not a PII classifier or a guarantee for every host action. Research results retain their paper assumptions.
Install
Proxy mode, with no agent code changes: pip install "agentassert-abc[proxy]". This replaces the separate AgentAssert Type-C packages, which are deprecated.
Install
python -m pip install "agentassert-abc[yaml,math]"What it does
A domain-specific language for defining behavioral contracts: preconditions, invariants, governance policies and recovery.
Jensen-Shannon divergence monitoring. Detect when agent behavior deviates from contracted norms.
Automatic intervention when contracts are violated. Re-prompt agents back to compliant behavior.
Probabilistic contract satisfaction with confidence bounds. Statistical guarantees for stochastic agents.
Ornstein-Uhlenbeck process modeling of behavioral drift with Lyapunov stability proofs.
Contracts compose across multi-agent systems. Verify pipeline-level compliance from component contracts.
Use it for
Changelog
The latest releases on GitHub.
0.7.0 — universal Type C enforcement
Enforcement is no longer tied to a vendor. Until now a contract could only be enforced through an LLM wire format, a vendor SDK client, or the Claude Code hook — and the framework integrations could only measure. This release makes enforcement available anywhere an agent runs.
0.6.0 — paper–code parity, enforcement state fix, drift calibration
Closes the gaps between the published paper and the shipped package, and fixes two defects that produced confidently wrong numbers.
agentassert-abc 0.5.0 — runtime enforcement plane
0.5.0 adds a runtime enforcement plane — real-time ALLOW/DENY/REDACT/MODIFY decisions on tool calls and model responses — alongside the existing measurement and certification planes. New zero-code-change adoption surfaces ship as optional extras: agentassert-abc[sdk] (wrap()…
v0.4.0 — Dependence-aware compositional reliability certificate
Dependence-aware compositional reliability certificate that does not assume stage-failure independence (C5):
Formal Behavioral Contracts for AI Agents
Research
Two instances of the same model failed together on 90% of missions where either failed — independence is not a safe assumption
Design-by-contract for agents — invariants that hold on every execution path. 1,980 sessions across 7 models