Skip to main content

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

Error: "handoff field 'user.name': expected str, got int"

Typed list

Every element must match the declared type:
Error: "handoff field 'tags[2]': expected str, got int"

Union typed list

Elements can be any of the listed types:
Each element is checked against all listed types — passes if it matches any.

List of dicts

Each element must match the dict schema:
Error: "handoff field 'results[0].score': expected float, got str"

Deeply nested

Schemas compose arbitrarily:

Strict bool/int separation

Python’s bool subclasses int, but reagent-flow distinguishes them: This prevents silent type confusion at agent boundaries.

Optional Pydantic support

When Pydantic is installed, pass a BaseModel subclass instead of a dict schema:
Pydantic validation uses 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.