> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent with Structured Outputs and Strict Tools

> Validate both Claude tool-call inputs and the agent's final Pydantic response.

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

## Code

```python structured_output_strict_tools.py theme={null}
from agno.agent import Agent
from agno.models.anthropic import Claude
from agno.tools import Function
from pydantic import BaseModel


class WeatherInfo(BaseModel):
    location: str
    temperature: float
    unit: str
    condition: str


def get_weather(location: str, unit: str) -> str:
    temp = 72 if unit == "fahrenheit" else 22
    symbol = "F" if unit == "fahrenheit" else "C"
    return f"Weather in {location}: {temp} degrees {symbol}, sunny"


weather_tool = Function(
    name="get_weather",
    description="Get current weather information for a location",
    parameters={
        "type": "object",
        "properties": {
            "location": {
                "type": "string",
                "description": "The city and state, e.g. San Francisco, CA",
            },
            "unit": {
                "type": "string",
                "enum": ["celsius", "fahrenheit"],
                "description": "Temperature unit",
            },
        },
        "required": ["location", "unit"],
        "additionalProperties": False,
    },
    strict=True,
    entrypoint=get_weather,
)

agent = Agent(
    model=Claude(id="claude-sonnet-4-6"),
    tools=[weather_tool],
    output_schema=WeatherInfo,
    description="You help users get weather information.",
)

if __name__ == "__main__":
    agent.print_response("What's the weather like in San Francisco?")
```

| Contract | Agno setting | Anthropic request shape |
| - | - | - |
| Tool name and arguments | `Function(strict=True)` | Top-level `strict: true` beside `name`, `description`, and `input_schema` |
| Final response | `Agent(output_schema=WeatherInfo)` | JSON output schema |

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

<Snippet file="create-venv-step.mdx" />

**1. Install dependencies**

```bash theme={null}
uv pip install -U "agno[anthropic]"
```

**2. Export your Anthropic API key**

```bash Mac/Linux theme={null}
export ANTHROPIC_API_KEY="your_anthropic_api_key_here"
```

```powershell Windows theme={null}
$Env:ANTHROPIC_API_KEY="your_anthropic_api_key_here"
```

**3. Run the agent**

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

```bash theme={null}
python structured_output_strict_tools.py
```

## Developer Resources

* [Structured outputs](https://agno-v2.mintlify.site/models/providers/native/anthropic/usage/structured-output.md)
* [Tool overview](https://agno-v2.mintlify.site/tools/overview.md)
* [Anthropic strict tool use](https://platform.claude.com/docs/en/agents-and-tools/tool-use/strict-tool-use)
* [Anthropic structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.