Reasoning With Model

Run a separate native OpenAI reasoning stage before the main response and display available reasoning output.

reasoning_with_model.py
"""
Reasoning With Model
=============================

Use a separate native reasoning model (o1, o3, DeepSeek-R1, etc.) for thinking.
"""

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

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(
    model=OpenAIResponses(id="gpt-5.6"),
    # Use a native reasoning model for the thinking step
    reasoning_model=OpenAIResponses(id="o3-mini"),
    markdown=True,
)

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    agent.print_response(
        "A farmer has 17 sheep. All but 9 die. How many sheep are left?",
        stream=True,
        show_full_reasoning=True,
    )

An explicit reasoning_model runs as a separate, tool-free reasoning stage before the main model response. show_full_reasoning=True displays the reasoning data Agno receives; it cannot reveal a provider's private internal trace. Some adapters use the reasoning stage's answer text when separate reasoning content is unavailable. A failed reasoning stage can still be followed by a main-model answer, so a completed run alone does not prove the reasoning stage succeeded.

OpenAI schedules o3-mini and o4-mini for shutdown on October 23, 2026. The provider lifecycle notice lists their replacements. Check the selected replacement's reasoning and service-tier support before changing the source model ID.

Run the Example

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Install dependencies

uv pip install -U agno openai

Export your OpenAI API key

export OPENAI_API_KEY="your_openai_api_key_here"

Run the example

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

python reasoning_with_model.py

Full source: cookbook/02_agents/13_reasoning/reasoning_with_model.py