The ReasoningTools
toolkit allows an Agent to use reasoning like any other tool, at any point during execution. Unlike traditional approaches that reason once at the start to create a fixed plan, this enables the Agent to reflect after each step, adjust its thinking, and update its actions on the fly.
We’ve found that this approach significantly improves an Agent’s ability to solve complex problems it would otherwise fail to handle. By giving the Agent space to “think” about its actions, it can examine its own responses more deeply, question its assumptions, and approach the problem from different angles.
The toolkit includes the following tools:
think
: This tool is used as a scratchpad by the Agent to reason about the question and work through it step by step. It helps break down complex problems into smaller, manageable chunks and track the reasoning process.
analyze
: This tool is used to analyze the results from a reasoning step and determine the next actions.
Example
Here’s an example of how to use the ReasoningTools
toolkit:
from agno.agent import Agent
from agno.models.anthropic import Claude
from agno.tools.reasoning import ReasoningTools
from agno.tools.yfinance import YFinanceTools
thinking_agent = Agent(
model=Claude(id="claude-3-7-sonnet-latest"),
tools=[
ReasoningTools(add_instructions=True),
YFinanceTools(
stock_price=True,
analyst_recommendations=True,
company_info=True,
company_news=True,
),
],
instructions="Use tables where possible",
show_tool_calls=True,
markdown=True,
)
thinking_agent.print_response("Write a report comparing NVDA to TSLA", stream=True)
The toolkit comes with default instructions and few-shot examples to help the Agent use the tool effectively. Here is how you can enable them:
reasoning_agent = Agent(
model=Claude(id="claude-3-7-sonnet-latest"),
tools=[
ReasoningTools(
think=True,
analyze=True,
add_instructions=True,
add_few_shot=True,
),
],
)
ReasoningTools
can be used with any model provider that supports function calling. Here is an example with of a reasoning Agent using OpenAIChat
:
from textwrap import dedent
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.reasoning import ReasoningTools
reasoning_agent = Agent(
model=OpenAIChat(id="gpt-4o"),
tools=[ReasoningTools(add_instructions=True)],
instructions=dedent("""\
You are an expert problem-solving assistant with strong analytical skills! 🧠
Your approach to problems:
1. First, break down complex questions into component parts
2. Clearly state your assumptions
3. Develop a structured reasoning path
4. Consider multiple perspectives
5. Evaluate evidence and counter-arguments
6. Draw well-justified conclusions
When solving problems:
- Use explicit step-by-step reasoning
- Identify key variables and constraints
- Explore alternative scenarios
- Highlight areas of uncertainty
- Explain your thought process clearly
- Consider both short and long-term implications
- Evaluate trade-offs explicitly
For quantitative problems:
- Show your calculations
- Explain the significance of numbers
- Consider confidence intervals when appropriate
- Identify source data reliability
For qualitative reasoning:
- Assess how different factors interact
- Consider psychological and social dynamics
- Evaluate practical constraints
- Address value considerations
\
"""),
add_datetime_to_instructions=True,
stream_intermediate_steps=True,
show_tool_calls=True,
markdown=True,
)
This Agent can be used to ask questions that elicit thoughtful analysis, such as:
reasoning_agent.print_response(
"A startup has $500,000 in funding and needs to decide between spending it on marketing or "
"product development. They want to maximize growth and user acquisition within 12 months. "
"What factors should they consider and how should they analyze this decision?",
stream=True
)
or,
reasoning_agent.print_response(
"Solve this logic puzzle: A man has to take a fox, a chicken, and a sack of grain across a river. "
"The boat is only big enough for the man and one item. If left unattended together, the fox will "
"eat the chicken, and the chicken will eat the grain. How can the man get everything across safely?",
stream=True,
)