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

# 推理工具

一类新的研究正在兴起，通过为模型提供结构化思考工具（如草稿板）来极大地提高它们的推理能力。

例如，通过为模型提供一个 **“思考”工具**，我们可以提供一个专门用于解决问题的空间，从而大大提高其推理能力。这是一种简单而有效的方法，可以为不具备推理能力的模型添加推理功能。

这项技术最初由 Anthropic 在[这篇博客文章](https://www.anthropic.com/engineering/claude-think-tool)中发布，尽管在发布之前，许多人工智能工程师（包括我们自己的团队）就已经在实践了。

## v0：思考工具

思考工具的第一个版本由 Anthropic 在[这篇博客文章](https://www.anthropic.com/engineering/claude-think-tool)中发布。

```python claude_thinking_tools.py theme={null}
from agno.agent import Agent
from agno.models.anthropic import Claude
from agno.tools.thinking import ThinkingTools
from agno.tools.yfinance import YFinanceTools

reasoning_agent = Agent(
    model=Claude(id="claude-3-7-sonnet-latest"),
    tools=[
        ThinkingTools(add_instructions=True),
        YFinanceTools(
            stock_price=True,
            analyst_recommendations=True,
            company_info=True,
            company_news=True,
        ),
    ],
    instructions="Use tables where possible",
    markdown=True,
)

if __name__ == "__main__":
    reasoning_agent.print_response(
        "Write a report on NVDA. Only the report, no other text.",
        stream=True,
        show_full_reasoning=True,
        stream_intermediate_steps=True,
    )
```

## v1：推理工具

虽然 v0 思考工具是一个很好的开始，但它的局限性在于它只提供了一个思考空间。v1 推理工具更进一步，允许 Agent **分析**其操作（即工具调用）的结果，从而大大提高了 Agent 解决需要顺序工具调用的问题的能力。

**ReasoningTools = `think` + `analyze`**

```python claude_reasoning_tools.py theme={null}
from agno.agent import Agent
from agno.models.anthropic import Claude
from agno.tools.reasoning import ReasoningTools
from agno.tools.yfinance import YFinanceTools

reasoning_agent = Agent(
    model=Claude(id="claude-3-7-sonnet-20250219"),
    tools=[
        ReasoningTools(add_instructions=True),
        YFinanceTools(stock_price=True, analyst_recommendations=True, company_info=True, company_news=True),
    ],
    show_tool_calls=True,
)
reasoning_agent.print_response(
    "Write a report comparing NVDA to TSLA", stream=True, markdown=True
)
```

## v2：知识工具

知识工具通过允许 Agent **搜索**知识库和**分析**其操作的结果，将 v1 推理工具提升了一个层次。

**KnowledgeTools = `think` + `search` + `analyze`**

```python knowledge_tools.py theme={null}
import os
from agno.agent import Agent
from agno.embedder.openai import OpenAIEmbedder
from agno.knowledge.url import UrlKnowledge
from agno.models.openai import OpenAIChat
from agno.tools.knowledge import KnowledgeTools
from agno.vectordb.lancedb import LanceDb, SearchType


agno_docs = UrlKnowledge(
    urls=["https://docs.agno.com/llms-full.txt"],

    vector_db=LanceDb(
        uri="tmp/lancedb",
        table_name="agno_docs",
        search_type=SearchType.hybrid,
        embedder=OpenAIEmbedder(id="text-embedding-3-small"),
    ),
)


knowledge_tools = KnowledgeTools(
    knowledge=agno_docs,
    think=True,
    search=True,
    analyze=True,
    add_few_shot=True,
)


agent = Agent(
    model=OpenAIChat(id="gpt-4o"),
    tools=[knowledge_tools],
    show_tool_calls=True,
    markdown=True,
)


agno_docs.load(recreate=True)


agent.print_response("How do I build multi-agent teams with Agno?", stream=True)
```

## 开发者资源

* 查看 [带推理工具的 Agent 示例](/examples/concepts/reasoning/tools)
* 查看 [带推理工具的 Agent 操作手册](https://github.com/agno-agi/agno/tree/main/cookbook/reasoning/tools)
* 查看 [带推理工具的团队示例](/examples/concepts/reasoning/teams)
* 查看 [带推理工具的团队操作手册](https://github.com/agno-agi/agno/tree/main/cookbook/reasoning/teams)
