Capture Reasoning Content

Capture available explicit tool notes and native summaries from run outputs and completion events.

Capture explicit ReasoningTools notes or provider-exposed content from a supported native reasoning_model. These fields can be empty; instructions and display flags do not guarantee that a tool is called or a summary is returned.

Add the following code to your Python file

capture_reasoning_content_default_cot.py
from agno.agent import Agent
from agno.models.openai import OpenAIChat, OpenAIResponses
from agno.run.agent import RunCompletedEvent
from agno.tools.reasoning import ReasoningTools

def make_agent(separate_stage: bool) -> Agent:
    if separate_stage:
        return Agent(
            model=OpenAIChat(id="gpt-4.1"),
            reasoning_model=OpenAIResponses(
                id="gpt-5.2", reasoning_effort="medium", reasoning_summary="auto"
            ),
        )
    return Agent(
        model=OpenAIChat(id="gpt-4.1"),
        tools=[ReasoningTools(add_instructions=True)],
    )

for separate_stage in (False, True):
    response = make_agent(separate_stage).run("Compute the sum of integers 1 through 10.")
    print(response.reasoning_content or "No reasoning content was returned")

    completed = None
    for event in make_agent(separate_stage).run(
        "Compute 5 factorial.", stream=True, stream_events=True
    ):
        if isinstance(event, RunCompletedEvent):
            completed = event
    if completed is not None:
        print(completed.reasoning_content or "No reasoning content was returned")
    else:
        print("The stream ended without a completion event")

Set up your virtual environment

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

Install dependencies

uv pip install -U openai agno

Export your OpenAI API key

  export OPENAI_API_KEY="your_openai_api_key_here"

Run Agent

python capture_reasoning_content_default_cot.py