Skip to main content
Set strict=True on a function and output_schema on the agent to constrain the tool call and final response separately.

Code

structured_output_strict_tools.py
Both schemas must use Anthropic’s supported JSON Schema subset. Agno adds additionalProperties: false and makes every strict function parameter required when it formats the tool schema. In Agno 2.7.2, defaulted and Optional function parameters remain required when strict=True because Function rewrites the schema’s required list. This example therefore requires unit in both the function signature and the explicit schema.

Usage

1

Set up your virtual environment

2

Install dependencies

3

Export your Anthropic API key

4

Run the agent

Save the code above as structured_output_strict_tools.py, then run:

Developer Resources