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

# Capture Reasoning Content

> Inspect reasoning_content in streaming and non-streaming runs.

```python capture_reasoning_content_default_COT.py theme={null}
"""
Capture Reasoning Content
=========================

Demonstrates how to inspect reasoning_content in streaming and non-streaming runs.
"""

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


# ---------------------------------------------------------------------------
# Create Helpers
# ---------------------------------------------------------------------------
def print_reasoning_content(response, label: str) -> None:
    """Print a short reasoning_content report for a run response."""
    print(f"\n--- reasoning_content from {label} ---")
    if hasattr(response, "reasoning_content") and response.reasoning_content:
        print("[OK] reasoning_content FOUND")
        print(f"   Length: {len(response.reasoning_content)} characters")
        print("\n=== reasoning_content preview ===")
        preview = response.reasoning_content[:1000]
        if len(response.reasoning_content) > 1000:
            preview += "..."
        print(preview)
    else:
        print("[NOT FOUND] reasoning_content NOT FOUND")


# ---------------------------------------------------------------------------
# Run Examples
# ---------------------------------------------------------------------------
def run_examples() -> None:
    print("\n=== Example 1: Using reasoning=True (default COT) ===\n")

    agent = Agent(
        model=OpenAIChat(id="gpt-4o"),
        reasoning=True,
        markdown=True,
    )

    print("Running with reasoning=True (non-streaming)...")
    response = agent.run("What is the sum of the first 10 natural numbers?")
    print_reasoning_content(response, label="non-streaming response")

    print("\n\n=== Example 2: Using a custom reasoning_model ===\n")

    agent_with_reasoning_model = Agent(
        model=OpenAIChat(id="gpt-4o"),
        reasoning_model=OpenAIChat(id="gpt-4o"),
        markdown=True,
    )

    print("Running with reasoning_model specified (non-streaming)...")
    response = agent_with_reasoning_model.run(
        "What is the sum of the first 10 natural numbers?"
    )
    print_reasoning_content(response, label="non-streaming response")

    print("\n\n=== Example 3: Processing stream with reasoning=True ===\n")

    streaming_agent = Agent(
        model=OpenAIChat(id="gpt-4o"),
        reasoning=True,
        markdown=True,
    )

    print("Running with reasoning=True (streaming)...")
    final_response = None
    for event in streaming_agent.run(
        "What is the value of 5! (factorial)?",
        stream=True,
        stream_events=True,
    ):
        if hasattr(event, "content") and event.content:
            print(event.content, end="", flush=True)

        if hasattr(event, "reasoning_content"):
            final_response = event

    print_reasoning_content(final_response, label="final stream event")

    print("\n\n=== Example 4: Processing stream with reasoning_model ===\n")

    streaming_agent_with_model = Agent(
        model=OpenAIChat(id="gpt-4o"),
        reasoning_model=OpenAIChat(id="gpt-4o"),
        markdown=True,
    )

    print("Running with reasoning_model specified (streaming)...")
    final_response_with_model = None
    for event in streaming_agent_with_model.run(
        "What is the value of 7! (factorial)?",
        stream=True,
        stream_events=True,
    ):
        if hasattr(event, "content") and event.content:
            print(event.content, end="", flush=True)

        if hasattr(event, "reasoning_content"):
            final_response_with_model = event

    print_reasoning_content(
        final_response_with_model,
        label="final stream event (reasoning_model)",
    )


if __name__ == "__main__":
    run_examples()
```

## Run the Example

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

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U agno openai
    ```
  </Step>

  <Step title="Export your OpenAI API key">
    <CodeGroup>
      ```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"
      ```
    </CodeGroup>
  </Step>

  <Step title="Run the example">
    Save the code above as `capture_reasoning_content_default_COT.py`, then run:

    ```bash theme={null}
    python capture_reasoning_content_default_COT.py
    ```
  </Step>
</Steps>

Full source: [cookbook/10\_reasoning/agents/capture\_reasoning\_content\_default\_COT.py](https://github.com/agno-agi/agno/blob/main/cookbook/10_reasoning/agents/capture_reasoning_content_default_COT.py)
