> ## 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.

# Tool Choice

> Compare tool_choice values none, auto, and a forced get_weather call across three agents.

Tool Choice Control.

```python tool_choice.py theme={null}
"""
Tool Choice
=============================

Tool Choice Control.
"""

from agno.agent import Agent
from agno.models.openai import OpenAIResponses


def get_weather(city: str) -> str:
    return f"Weather data placeholder for {city}: 72F and clear."


# ---------------------------------------------------------------------------
# Create Agents
# ---------------------------------------------------------------------------
no_tools_agent = Agent(
    name="No-Tools Agent",
    model=OpenAIResponses(id="gpt-5.2"),
    tools=[get_weather],
    tool_choice="none",
)

auto_tools_agent = Agent(
    name="Auto-Tools Agent",
    model=OpenAIResponses(id="gpt-5.2"),
    tools=[get_weather],
    tool_choice="auto",
)

forced_tool_agent = Agent(
    name="Forced-Tool Agent",
    model=OpenAIResponses(id="gpt-5.2"),
    tools=[get_weather],
    tool_choice={"type": "function", "name": "get_weather"},
)

# ---------------------------------------------------------------------------
# Run Agents
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    prompt = "What is the weather in San Francisco today?"
    no_tools_agent.print_response(prompt, stream=True)
    auto_tools_agent.print_response(prompt, stream=True)
    forced_tool_agent.print_response(prompt, stream=True)
```

## Run the Example

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

**1. Install dependencies**

```bash theme={null}
uv pip install -U agno openai
```

**2. Export your OpenAI API key**

```bash Mac/Linux theme={null}
export OPENAI_API_KEY="your_openai_api_key_here"
```

```bash Windows theme={null}
$Env:OPENAI_API_KEY="your_openai_api_key_here"
```

**3. Run the example**

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

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

Full source: [cookbook/02\_agents/04\_tools/tool\_choice.py](https://github.com/agno-agi/agno/blob/v3.0.4/cookbook/02_agents/04_tools/tool_choice.py)


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