Skip to content

Commit 6589b6d

Browse files
authored
docs/add-reasoning-tools (#208)
Reasoning Tool Docs
1 parent 8cc7fb4 commit 6589b6d

File tree

2 files changed

+141
-24
lines changed

2 files changed

+141
-24
lines changed

mint.json

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,7 @@
108108
"teams/introduction",
109109
{
110110
"group": "Team Modes",
111-
"pages": [
112-
"teams/route",
113-
"teams/coordinate",
114-
"teams/collaborate"
115-
]
111+
"pages": ["teams/route", "teams/coordinate", "teams/collaborate"]
116112
}
117113
]
118114
},
@@ -235,6 +231,7 @@
235231
]
236232
},
237233
"tools/mcp",
234+
"tools/reasoning-tools",
238235
"tools/functions",
239236
"tools/custom-toolkits",
240237
"tools/async-tools",
@@ -252,10 +249,7 @@
252249
},
253250
{
254251
"group": "Memory",
255-
"pages": [
256-
"memory/introduction",
257-
"memory/storage"
258-
]
252+
"pages": ["memory/introduction", "memory/storage"]
259253
},
260254
{
261255
"group": "Knowledge",
@@ -875,9 +869,8 @@
875869
"group": "OpenAI",
876870
"pages": [
877871
{
878-
879-
"group":"OpenAI Chat",
880-
"pages":[
872+
"group": "OpenAI Chat",
873+
"pages": [
881874
"examples/models/openai/chat/basic",
882875
"examples/models/openai/chat/basic_stream",
883876
"examples/models/openai/chat/tool_use",
@@ -892,8 +885,8 @@
892885
]
893886
},
894887
{
895-
"group":"OpenAI Responses",
896-
"pages":[
888+
"group": "OpenAI Responses",
889+
"pages": [
897890
"examples/models/openai/responses/basic",
898891
"examples/models/openai/responses/basic_stream",
899892
"examples/models/openai/responses/tool_use",
@@ -905,8 +898,6 @@
905898
"examples/models/openai/responses/pdf_input_local",
906899
"examples/models/openai/responses/pdf_input_url"
907900
]
908-
909-
910901
}
911902
]
912903
},
@@ -1005,17 +996,11 @@
1005996
"pages": [
1006997
{
1007998
"group": "Agents",
1008-
"pages": [
1009-
"reference/agents/agent",
1010-
"reference/agents/session"
1011-
]
999+
"pages": ["reference/agents/agent", "reference/agents/session"]
10121000
},
10131001
{
10141002
"group": "Teams",
1015-
"pages": [
1016-
"reference/teams/team",
1017-
"reference/teams/session"
1018-
]
1003+
"pages": ["reference/teams/team", "reference/teams/session"]
10191004
},
10201005
{
10211006
"group": "Workflows",

tools/reasoning-tools.mdx

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
---
2+
title: Reasoning Tools
3+
sidebarTitle: Reasoning
4+
---
5+
6+
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.
7+
8+
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.
9+
10+
The toolkit includes the following tools:
11+
12+
- `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.
13+
- `analyze`: This tool is used to analyze the results from a reasoning step and determine the next actions.
14+
15+
## Example
16+
17+
Here's an example of how to use the `ReasoningTools` toolkit:
18+
19+
```python
20+
from agno.agent import Agent
21+
from agno.models.anthropic import Claude
22+
from agno.tools.thinking import ThinkingTools
23+
from agno.tools.yfinance import YFinanceTools
24+
25+
thinking_agent = Agent(
26+
model=Claude(id="claude-3-7-sonnet-latest"),
27+
tools=[
28+
ThinkingTools(add_instructions=True),
29+
YFinanceTools(
30+
stock_price=True,
31+
analyst_recommendations=True,
32+
company_info=True,
33+
company_news=True,
34+
),
35+
],
36+
instructions="Use tables where possible",
37+
show_tool_calls=True,
38+
markdown=True,
39+
)
40+
41+
thinking_agent.print_response("Write a report comparing NVDA to TSLA", stream=True)
42+
```
43+
44+
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:
45+
46+
```python
47+
reasoning_agent = Agent(
48+
model=Claude(id="claude-3-7-sonnet-latest"),
49+
tools=[
50+
ReasoningTools(
51+
think=True,
52+
analyze=True,
53+
add_instructions=True,
54+
add_few_shot=True,
55+
),
56+
],
57+
)
58+
```
59+
60+
`ReasoningTools` can be used with any model provider that supports function calling. Here is an example with of a reasoning Agent using `OpenAIChat`:
61+
62+
```python
63+
from textwrap import dedent
64+
65+
from agno.agent import Agent
66+
from agno.models.openai import OpenAIChat
67+
from agno.tools.reasoning import ReasoningTools
68+
69+
reasoning_agent = Agent(
70+
model=OpenAIChat(id="gpt-4o"),
71+
tools=[ReasoningTools(add_instructions=True)],
72+
instructions=dedent("""\
73+
You are an expert problem-solving assistant with strong analytical skills! 🧠
74+
75+
Your approach to problems:
76+
1. First, break down complex questions into component parts
77+
2. Clearly state your assumptions
78+
3. Develop a structured reasoning path
79+
4. Consider multiple perspectives
80+
5. Evaluate evidence and counter-arguments
81+
6. Draw well-justified conclusions
82+
83+
When solving problems:
84+
- Use explicit step-by-step reasoning
85+
- Identify key variables and constraints
86+
- Explore alternative scenarios
87+
- Highlight areas of uncertainty
88+
- Explain your thought process clearly
89+
- Consider both short and long-term implications
90+
- Evaluate trade-offs explicitly
91+
92+
For quantitative problems:
93+
- Show your calculations
94+
- Explain the significance of numbers
95+
- Consider confidence intervals when appropriate
96+
- Identify source data reliability
97+
98+
For qualitative reasoning:
99+
- Assess how different factors interact
100+
- Consider psychological and social dynamics
101+
- Evaluate practical constraints
102+
- Address value considerations
103+
\
104+
"""),
105+
add_datetime_to_instructions=True,
106+
stream_intermediate_steps=True,
107+
show_tool_calls=True,
108+
markdown=True,
109+
)
110+
```
111+
112+
This Agent can be used to ask questions that elicit thoughtful analysis, such as:
113+
114+
```python
115+
reasoning_agent.print_response(
116+
"A startup has $500,000 in funding and needs to decide between spending it on marketing or "
117+
"product development. They want to maximize growth and user acquisition within 12 months. "
118+
"What factors should they consider and how should they analyze this decision?",
119+
stream=True
120+
)
121+
```
122+
123+
or,
124+
125+
```python
126+
reasoning_agent.print_response(
127+
"Solve this logic puzzle: A man has to take a fox, a chicken, and a sack of grain across a river. "
128+
"The boat is only big enough for the man and one item. If left unattended together, the fox will "
129+
"eat the chicken, and the chicken will eat the grain. How can the man get everything across safely?",
130+
stream=True,
131+
)
132+
```

0 commit comments

Comments
 (0)