Skip to main content

Overview

Tool output contracts validate the structure of what a tool returns. When a tool’s return shape changes — an upstream API renames a field, drops a key, or changes a type — assert_tool_output_matches catches it before the downstream agent sees wrong data.

assert_tool_output_matches

What it checks

  • Finds all tool results for the named tool across all turns
  • Validates every result against the schema
  • Reports the first mismatch with the exact field path

Failure message

Schema format

Schemas are dicts mapping field names to expected types:
See Nested Schemas for the full schema language.

Adapter support

Tool output contracts work with all framework adapters:

Example with manual logging

Example with OpenAI adapter