Overview
Handoff contracts validate the structured data passed from one agent session to another viahandoff_context. They catch renamed fields, missing keys, wrong types, and broken parent-child links.
Setting up a handoff
Link two sessions by passingparent_trace_id and handoff_context:
assert_handoff_received
Verifies that a child session is linked to its expected parent.parent_trace_id doesn’t match the parent’s trace_id, or if handoff_context is missing.
assert_handoff_matches
Type-checks thehandoff_context against a declared schema.
What it checks
- Every key in the schema must exist in the handoff data
- Every value must match the declared type
- Nested dicts, typed lists, and list-of-dicts are supported (see Nested Schemas)
boolandintare strictly separated —Trueis not a validint
Failure message
assert_handoff_has_fields
Checks that specific field names exist in the handoff context (without type checking):assert_no_extra_fields
Verifies that the handoff context contains only the allowed fields:assert_context_preserved
Verifies that specific values survived a handoff unchanged:source dict values against the child’s handoff_context for the listed fields. Fails if any value was mutated, truncated, or lost.