Overview
assert_handoff_matches and assert_tool_output_matches support deeply nested schema validation. Error messages include dot/bracket path notation so you can pinpoint exactly which field failed.
Schema types
Flat dict
Nested dict
"handoff field 'user.name': expected str, got int"
Typed list
Every element must match the declared type:"handoff field 'tags[2]': expected str, got int"
Union typed list
Elements can be any of the listed types:List of dicts
Each element must match the dict schema:"handoff field 'results[0].score': expected float, got str"
Deeply nested
Schemas compose arbitrarily:Strict bool/int separation
Python’sbool subclasses int, but reagent-flow distinguishes them:
This prevents silent type confusion at agent boundaries.
Optional Pydantic support
When Pydantic is installed, pass aBaseModel subclass instead of a dict schema:
model_validate() under the hood. On failure, the Pydantic error details are included in the assertion message.
Pydantic is never imported at module level — detection is purely runtime. Users without Pydantic get identical behavior using dict schemas. No new dependency is introduced.