Enable step-by-step reasoning for complex problems
Reasoning mode enables agents to work through problems step-by-step, showing their thinking process before arriving at a final answer. This is particularly useful for complex reasoning tasks, math problems, and multi-step planning.
from agno import Agentagent = Agent( model="gpt-4o", reasoning=True, reasoning_min_steps=1, reasoning_max_steps=10)response = agent.run("If a train travels 60 mph for 2.5 hours, how far does it go?")print(response.reasoning_content) # Shows step-by-step thinkingprint(response.content) # Final answer
from agno import Agentagent = Agent( model="gpt-4o", reasoning=True)response = agent.run( "A store has 150 apples. They sell 60% on Monday and 25% of the " "remainder on Tuesday. How many apples are left?")print(response.reasoning_content)# Step 1: Calculate Monday sales# 60% of 150 = 0.6 × 150 = 90 apples# Remaining: 150 - 90 = 60 apples## Step 2: Calculate Tuesday sales# 25% of 60 = 0.25 × 60 = 15 apples# Remaining: 60 - 15 = 45 applesprint(response.content)# There are 45 apples left.
from agno import Agent# Create specialized reasoning agentreasoning_agent = Agent( model="gpt-4o", instructions=[ "Break down problems step by step", "Show your work for each step", "Verify your logic before proceeding" ])# Main agent uses reasoning agentagent = Agent( model="gpt-4o", reasoning=True, reasoning_agent=reasoning_agent)
agent = Agent( model="gpt-4o", reasoning=True, instructions=["Plan before implementing"])response = agent.run( "Design and implement a binary search tree with insert and delete operations")
agent = Agent( model="gpt-4o", reasoning=True, reasoning_max_steps=20)response = agent.run( "Create a go-to-market strategy for a new SaaS product targeting small businesses")