What is contract testing?
In a multi-agent system, agents pass structured data to each other. A contract is the declared shape of that data — the fields, types, and values the downstream agent expects. Without contracts, schema drift is silent. An upstream team renames a field, the LLM adapts, tests pass, and the bug shows up in production as a wrong decision. reagent-flow makes these contracts explicit and testable:contains_customer_pii to handles_personal_data, this assertion fails at PR time with the exact field path:
Two types of contracts
Handoff contracts
Validate the data passed between agents viahandoff_context:
Tool output contracts
Validate the data returned by a tool within a single agent:What contracts catch
The multi-agent pattern
A typical contract-tested pipeline:Contracts are checked at test time using pytest, not at runtime. This keeps production behavior unchanged while catching drift in CI.
Why not guardrails or structured outputs?
See where contract testing fits alongside structured outputs, runtime guardrails, evals, and observability.