Gemini Basic Reasoning

Compare a single Gemini 3.7 Flash call with a separate reasoning stage and inspect returned thought summaries.

Compare a single Gemini 3.7 Flash agent with a two-stage agent. Both use thinking-capable models; this is not a comparison with thinking disabled.

basic_reasoning.py
"""
Basic Reasoning
===============

Demonstrates this reasoning cookbook example.
"""

from agno.agent import Agent
from agno.models.google import Gemini
from rich.console import Console


# ---------------------------------------------------------------------------
# Create Example
# ---------------------------------------------------------------------------
def run_example() -> None:
    console = Console()

    # Classic reasoning test
    task = "9.11 and 9.9 -- which is bigger? Explain your reasoning."

    # Create a regular agent (no reasoning)
    regular_agent = Agent(
        model=Gemini(id="gemini-3.7-flash"),
        markdown=True,
    )

    # Create an agent with thinking budget
    reasoning_agent = Agent(
        model=Gemini(id="gemini-3.7-flash"),
        reasoning_model=Gemini(id="gemini-3.7-flash", thinking_budget=1024),
        markdown=True,
    )

    console.rule("[bold blue]Regular Gemini Agent (No Reasoning)[/bold blue]")
    console.print("This agent will answer directly without extended thinking.\n")
    regular_agent.print_response(task, stream=True)

    console.rule("[bold green]Gemini with Thinking Budget[/bold green]")
    console.print("This agent uses thinking budget to analyze the problem.\n")
    reasoning_agent.print_response(task, stream=True, show_full_reasoning=True)

    console.rule("[bold cyan]Accessing Reasoning Content[/bold cyan]")
    response = reasoning_agent.run(task, stream=False)
    if response.reasoning_content:
        console.print(
            f"[dim]Reasoning tokens used: ~{len(response.reasoning_content.split())}[/dim]"
        )
        console.print(
            f"\n[bold]Reasoning process:[/bold]\n{response.reasoning_content[:400]}..."
        )
    else:
        console.print("[yellow]No reasoning content available[/yellow]")


# ---------------------------------------------------------------------------
# Run Example
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    run_example()

Use current thinking settings and inspect summaries

Before running, change both model=Gemini(id="gemini-3.7-flash") expressions to model=Gemini(id="gemini-3.7-flash", thinking_level="low"). Replace the separate reasoning model with:

Gemini(id="gemini-3.7-flash", thinking_level="high", include_thoughts=True)

Update the printed labels to "Single call with low thinking" and "Separate high-thinking stage, then low-thinking answer". Replace the printed sentence "This agent will answer directly without extended thinking." with "This agent makes one call with low thinking." Replace the explanation about a thinking budget with "This agent uses a separate high-thinking stage before the answer." Gemini 3.7 supports low, medium, and high thinking levels; it cannot disable thinking completely. The comparison changes the number of calls as well as thinking settings, so it does not isolate reasoning cost or prove an accuracy gain. See Gemini thinking.

Replace the final if response.reasoning_content: block with this check of actual returned thought content:

summaries = [
    message.reasoning_content
    for message in response.reasoning_messages or []
    if isinstance(message.reasoning_content, str) and message.reasoning_content.strip()
]
if summaries:
    print("\n\n".join(summaries))
else:
    print("No thought summary was returned")

Keep this inside run_example(). A truthy response.reasoning_content can contain only a formatted empty thinking block. Its whitespace word count is not the provider's reasoning-token usage. Returned summaries are summarized output; use provider usage metrics, when available, for token accounting.

Run the Example

Set up your virtual environment

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

Install dependencies

uv pip install -U agno google-genai

Export your Google API key

export GOOGLE_API_KEY="your_google_api_key_here"

Run the example

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

python basic_reasoning.py

Full source: cookbook/10_reasoning/models/gemini/basic_reasoning.py