Agno : コンセプト : 推論 – 概要

推論はエージェントに、応答する前に「考える」能力と、アクション (i.e. ツール呼び出し) の結果を「分析する」能力を与え、連続的なツール呼び出しを必要とする問題を解決するエージェントの能力を大幅に向上させます。

Agno : ユーザガイド : コンセプト : 推論 – 概要

作成 : クラスキャット・セールスインフォメーション
作成日時 : 08/12/2025
バージョン : Agno 1.7.7

* 本記事は docs.agno.com の以下のページを独自に翻訳した上で、補足説明を加えてまとめ直しています :

* サンプルコードの動作確認はしておりますが、必要な場合には適宜、追加改変しています。
* ご自由にリンクを張って頂いてかまいませんが、sales-info@classcat.com までご一報いただけると嬉しいです。

 

クラスキャット 人工知能 研究開発支援サービス ⭐️ リニューアルしました 😉

クラスキャット は人工知能に関する各種サービスを提供しています。お気軽にご相談ください :

  • 人工知能導入個別相談会(無償)実施中! [詳細]

  • 人工知能研究開発支援 [詳細]
    1. 自社特有情報を含むチャットボット構築支援
    2. 画像認識 (医療系含む) / 画像生成

  • PoC(概念実証)を失敗させないための支援 [詳細]

お問合せ : 下記までお願いします。

  • クラスキャット セールス・インフォメーション
  • sales-info@classcat.com
  • ClassCatJP

 

 

Agno ユーザガイド : コンセプト : 推論 – 概要

推論はエージェントに、応答する前に「考える」能力と、アクション (i.e. ツール呼び出し) の結果を「分析する」能力を与え、連続的なツール呼び出しを必要とする問題を解決するエージェントの能力を大幅に向上させます。

推論エージェントは応答する前に内部の思考連鎖をたどり、様々なアイデアを検討し、必要に応じて検証して修正します :

  1. 推論モデル

  2. 推論ツール

  3. 推論エージェント

どのアプローチが最良に動作するかはユースケースに依存します、それらすべてを試してみて、推論エージェントの新しい時代を体験することを勧めます。

 

推論モデル

推論モデルは、回答前に思考するように強化学習でトレーニングされた大規模言語モデルの分離したクラスです。それらは応答前に内部的な思考の連鎖を生成します。推論モデルの例としては、OpenAI o-シリーズ、拡張思考モードの Claude 3.7 sonnet、Gemini 2.0 flash thinking そして DeepSeek-R1 があります。

モデル層の推論は、応答を生成し始める前にモデルが何をするかがすべてです。推論モデルはシングルショットのユースケースに優れています。複数回のターンや、シークエンシャルなツール呼び出しを必要としない、困難な問題 (コーディング、数学、物理) を解くために最適です。

 

o3_mini.py

from agno.agent import Agent
from agno.models.openai import OpenAIChat

agent = Agent(model=OpenAIChat(id="o3-mini"))
agent.print_response(
    "Solve the trolley problem. Evaluate multiple ethical frameworks. "
    "Include an ASCII diagram of your solution.",
    stream=True,
)

Read more about reasoning models in the Reasoning Models Guide.

 

推論モデル + 応答モデル

推論には推論モデルを使用し、しかし応答を生成するためには異なるモデルを使用したいならどうでしょうか?推論モデルは問題解決には優れていますが、自然な方法で応答するのはそうでもないことはよく知られています (like claude sonnet or gpt-4o)。

推論用の独立したモデルと応答用の異なるモデルを使用することで、両者の最良のものを利用できます。

 

推論には Groq の deepseek-r1 を使用し、自然な応答には claude sonnet を使用してみましょう。

deepseek_plus_claude.py

from agno.agent import Agent
from agno.models.anthropic import Claude
from agno.models.groq import Groq

deepseek_plus_claude = Agent(
    model=Claude(id="claude-3-7-sonnet-20250219"),
    reasoning_model=Groq(
        id="deepseek-r1-distill-llama-70b", temperature=0.6, max_tokens=1024, top_p=0.95
    ),
)
deepseek_plus_claude.print_response("9.11 and 9.9 -- which is bigger?", stream=True)

 

推論ツール

モデルに「考える」ツールを与えることで、構造化された思考のための専用スペースが提供され、推論能力を大幅に向上させられます。これは非推論モデルに推論を追加するための単純ですが、効果的なアプローチです。

この研究は、このブログ記事 で Anthropic により最初に公開されましたが、公開されるよりずっと前から (私たちのチームを含む) 多くの AI エンジニアにより実践されてきました。

 

claude_thinking_tools.py

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,
    )

Read more about reasoning tools in the Reasoning Tools Guide.

 

推論エージェント

推論エージェントは、思考の連鎖の推論とツール使用を組み合わせた、Agno により開発されたマルチエージェント・システムの新しいタイプです。

reasoning=True を設定することで、任意のエージェントで推論を有効にできます。

reasoning=True のエージェントにタスクが与えられると、最初に個別の「推論エージェント」が思考の連鎖 (chain-of-thought) を使用して問題を解きます。各ステップでそれはツールを呼び出して、情報を収集し、結果を検証し、そして最終的な答えに到達するまで繰り返します。推論エージェントが最終的な答えを持てば、結果を元のエージェントに返して、検証して応答を提供します。

 

reasoning_agent.py

from agno.agent import Agent
from agno.models.openai import OpenAIChat

reasoning_agent = Agent(
    model=OpenAIChat(id="gpt-4o"),
    reasoning=True,
    markdown=True,
)
reasoning_agent.print_response(
    "Solve the trolley problem. Evaluate multiple ethical frameworks. "
    "Include an ASCII diagram of your solution.",
    stream=True,
    show_full_reasoning=True,
)

Read more about reasoning agents in the Reasoning Agents Guide.

 

以上