Software has contracts.
Your agents have
a paragraph of hope.
Types, assertions, APIs — every reliable system you have ever shipped was reliable because something checked it. AI agents handle money, health records, and legal decisions on the strength of a prompt. Agent Behavioral Contracts give them runtime enforcement, < 10 ms inline invariant checks, and a mathematical theorem that bounds their drift.
arXiv:2608.12895 · 49 pages · 18 theorems
Geometric Convergence to Invariant Boundary
For any autonomous AI agent with stochastic perturbation rate α and contract recovery rate γ > α, expected trajectory drift concentrates within the bounded envelope D★ = α / γ.
A contract is four clauses:
C = (P, I, G, R)
Each clause is checked at a different moment in the agent's life. Everything else in both papers — every bound, every certificate — is a direct mathematical consequence of this tuple.
One file. The agent cannot ignore it.
The contract lives beside the agent, not inside its prompt. Enforcement is code, so it does not depend on the model choosing to cooperate.
# Agent Behavioral Contract agent: financial-advisor version: "1.0" before: # P (Preconditions) - user must be authenticated - compliance status must be approved during: # I (Invariants - inline < 10ms) - responses must not contain SSN patterns - responses must not contain credit card numbers - session cost must stay under $5.00 severity: critical action: block after: # G (Governance - post-action) - response must include regulatory disclaimer - all PII references must be redacted on_failure: # R (Recovery - γ parameter) retries: 3 fallback: escalate_to_human message: "Connecting you with a human advisor."
Correct it faster than it wanders,
and it can never wander far.
Drift is the distance between what the agent is doing and what the contract says. Each step, the world pushes it out by α and recovery pulls it back by a fraction γ of wherever it currently is. Those two forces settle at exactly one place.
m = Monitor(contract) m.metrics.drift # 0.263 m.metrics.recovery # 0.118 # measured: D★ < 0.27 across extended sessions
Why 90% of Multi-Agent Systems Fail
Watch author Varun Pratap Bhardwaj break down the mathematical proofs behind Agent Behavioral Contracts, the 18,000-mission co-failure trap, and the convex moment polytope certifier.
"It complied" is the wrong question.
A model that samples cannot promise you certainty, so demanding it is theatre. What you can demand is this: on at least p of sessions, every clause is satisfied within k recovery attempts — and we are confident of that to within δ.
That is the whole trick. Non-determinism stops being an excuse and becomes a parameter you set, audit and report.
Measured, not claimed.
Six domains behave. One does not. Composition — agents handing work to agents — is the weak column, and that gap is exactly where the second paper starts.
Two agents are not two chances.
Chain two agents and everyone multiplies their reliabilities — a step licensed by assuming they fail independently. We ran 18,000 preregistered missions, scored by deterministic code with no LLM judge, to check. They do not.
pipeline: - agent: model-x # same model - agent: model-x # redundancy over-credited # fix: substitute a distinct architecture
The tempting fix makes it worse.
If agents are correlated, why not model the correlation and bootstrap a confidence interval? Because that interval tightens around whatever your model believes — while the truth stays where it always was. More data does not fix it. More data hides it.
bootstrap haircut = O(n−1/2)
Assume nothing. Bound everything.
Take every joint failure distribution consistent with what you actually measured — not one fitted guess, all of them — and ask which is worst. That worst case is the certificate. It cannot be optimistic, because nothing was assumed away.
Non-Parametric LP Certificate over Moments
Rather than fitting a parametric distribution that underestimates co-failure tails, AgentAssert solves an exact linear program over the convex polytope of moment functionals M₁₀ ... M₁₄, guaranteeing anytime-valid Type-I error α ≤ 0.0471.
cert = certify(missions, moments=14, alpha=0.05) cert.floor # 0.4116 cert.sound # True # anytime-valid: type-I error 0.0471
Two papers. One argument.
The first says what a contract is and proves what it bounds. The second tests the assumption everyone composes on, and replaces it with something you can certify.
Defines C = (P, I, G, R) and (p, δ, k)-satisfaction, proves the Drift Bounds Theorem, and evaluates on AgentContract-Bench.
Tests the independence assumption on 18,000 preregistered missions, proves bootstrap coverage loss, and builds the LP certificate.
Your first contract takes four lines.
Wrap the agent you already have. Nothing about the model changes — what changes is that violations become visible, blockable and countable.
from agentassert_abc import Contract, Monitor contract = Contract.from_yaml("advisor.yaml") agent = Monitor(contract).wrap(my_agent) agent.run("summarise my portfolio") # → invariant I2 blocked 1 action, recovered in 1