Agno 2.x : チーム – チームのデバッグ

Agno チームのデバッグ方法を学習します。
Agno は例を見ないほど優れて構築されたデバッグモードを備えています、これはチームの開発エクスペリエンスを次のレベルに引き上げます。それは実行フローと中間ステップの理解に役立ちます。

Agno 2.x : Learn : チーム – チームのデバッグ

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

* 本記事は docs.agno.com の以下のページを独自に翻訳した上で、補足説明を加えてまとめ直しています。スニペットはできる限り日本語を使用しています :

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

 

クラスキャット AI 研究開発支援サービス ⭐️ 創立30周年(30th Anniversary)🎉💐

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

  • AI 研究開発支援 [詳細]

    1. AI エージェント構築支援
    2. 画像認識 (医療系含む) / 画像生成

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

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

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

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

 

 

Agno 2.x : Learn : チーム – チームのデバッグ

Agno チームのデバッグ方法を学習します。

Agno は例を見ないほど優れて構築されたデバッグモードを備えています、これはチームの開発エクスペリエンスを次のレベルに引き上げます。それは実行フローと中間ステップの理解に役立ちます。例えば :

  1. モデルに送信されたメッセージと、モデルが生成したレスポンスを検査します。

  2. 中間ステップをトレースし、トークン使用量、実行時間等のメトリクスを監視します。

  3. ツール呼び出し、エラーとそれらの結果を検査します。

  4. チームメンバー間のやり取り、委任パターンを監視します。

 

デバッグモード

デバッグモードを有効にするには :

  1. チームで debug_mode パラメータを設定すると、メンバーの実行に加えてすべての実行に対して有効になります。

  2. run メソッドで debug_mode パラメータを設定すると、現在の実行に対して有効になります。

  3. AGNO_DEBUG 環境変数を True に設定すると、すべてのチームに対してデバッグモードが有効になります。
from agno.team import Team
from agno.agent import Agent
from agno.models.openai import OpenAIChat

news_agent = Agent(name="News Agent", role="Get the latest news")
weather_agent = Agent(name="Weather Agent", role="Get the weather for the next 7 days")

team = Team(
    name="News and Weather Team",
    members=[news_agent, weather_agent],
    model=OpenAIChat(id="gpt-4o"),
    debug_mode=True,
    # debug_level=2, # Uncomment to get more detailed logs
)

# Run team and print response to the terminal
team.print_response("What is the weather in Tokyo?")

出力例

DEBUG ************************************************ Team ID: news-and-weather-team ***********************************************              
INFO Agent 'News Agent' inheriting model from Team: gpt-4o                                                                                         
INFO Agent 'Weather Agent' inheriting model from Team: gpt-4o                                                                                      
DEBUG *************************************** Session ID: 196e49c0-36dc-47b8-a7a6-d87c15745a52 **************************************              
DEBUG Creating new TeamSession: 196e49c0-36dc-47b8-a7a6-d87c15745a52                                                                               
DEBUG Processing tools for model                                                                                                                   
DEBUG Added tool delegate_task_to_member                                                                                                           
DEBUG ************************************* Team Run Start: e1d1a15c-777b-48b4-89f0-3f8496f41075 ************************************              
DEBUG ---------------------------------------------------- OpenAI Response Start ----------------------------------------------------              
DEBUG -------------------------------------------------------- Model: gpt-4o --------------------------------------------------------              
DEBUG ============================================================ system ===========================================================              
DEBUG You are the leader of a team and sub-teams of AI Agents.                                                                                     
      Your task is to coordinate the team to complete the user's request.                                                                          
                                                                                                                                                   
      Here are the members in your team:                                                                                                           
                                                                                                                                     
       - Agent 1:                                                                                                                                  
         - ID: news-agent                                                                                                                          
         - Name: News Agent                                                                                                                        
         - Role: Get the latest news                                                                                                               
       - Agent 2:                                                                                                                                  
         - ID: weather-agent                                                                                                                       
         - Name: Weather Agent                                                                                                                     
         - Role: Get the weather for the next 7 days                                                                                               
                                                                                                                                    
                                                                                                                                                   
                                                                                                                                   
      - Your role is to delegate tasks to members in your team with the highest likelihood of completing the user's request.                       
      - Carefully analyze the tools available to the members and their roles before delegating tasks.                                              
      - You cannot use a member tool directly. You can only delegate tasks to members.                                                             
      - When you delegate a task to another member, make sure to include:                                                                          
        - member_id (str): The ID of the member to delegate the task to. Use only the ID of the member, not the ID of the team followed by the ID  
      of the member.                                                                                                                               
        - task (str): A clear description of the task. Determine the best way to describe the task to the member.                                  
      - You can delegate tasks to multiple members at once.                                                                                        
      - You must always analyze the responses from members before responding to the user.                                                          
      - After analyzing the responses from the members, if you feel the task has been completed, you can stop and respond to the user.             
      - If you are NOT satisfied with the responses from the members, you should re-assign the task to a different member.                         
      - For simple greetings, thanks, or questions about the team itself, you should respond directly.                                             
      - For all work requests, tasks, or questions requiring expertise, route to appropriate team members.                                         
                                                                                                                                  
DEBUG ============================================================= user ============================================================              
DEBUG What is the weather in Tokyo?                                                                                                                
DEBUG ========================================================== assistant ==========================================================              
DEBUG Tool Calls:                                                                                                                                  
        - ID: 'call_IFeG4agBKr6I5XhaOvG9DuR6'                                                                                                      
          Name: 'delegate_task_to_member'                                                                                                          
          Arguments: 'member_id: weather-agent, task: Get the current weather and 7-day forecast for Tokyo.'                                       
DEBUG **********************************************************  METRICS  **********************************************************              
DEBUG * Tokens:                      input=506, output=33, total=539                                                                               
DEBUG * Duration:                    2.4375s                                                                                                       
DEBUG * Tokens per second:           13.5386 tokens/s                                                                                              
DEBUG **********************************************************  METRICS  **********************************************************              
DEBUG Running: delegate_task_to_member(member_id=weather-agent, task=Get the current weather and 7-day forecast for Tokyo.)                        
DEBUG *************************************************** Agent ID: weather-agent ***************************************************              
DEBUG Creating new AgentSession: 196e49c0-36dc-47b8-a7a6-d87c15745a52                                                                              
DEBUG ************************************ Agent Run Start: f363b908-5cb3-44c2-80e9-f2b83c46c7fb ************************************              
DEBUG ---------------------------------------------------- OpenAI Response Start ----------------------------------------------------              
DEBUG -------------------------------------------------------- Model: gpt-4o --------------------------------------------------------              
DEBUG ============================================================ system ===========================================================              
DEBUG                                                                                                                                   
      Get the weather for the next 7 days                                                                                                          
                                                                                                                                       
DEBUG ============================================================= user ============================================================              
DEBUG Get the current weather and 7-day forecast for Tokyo.                                                                                        
DEBUG ========================================================== assistant ==========================================================              
DEBUG I’m unable to provide real-time weather updates or current forecasts. To get the most accurate and up-to-date weather information for Tokyo, 
      I recommend checking a reliable weather website or app such as the Weather Channel, BBC Weather, or a local news service that offers live    
      weather updates.                                                                                                                             
DEBUG **********************************************************  METRICS  **********************************************************              
DEBUG * Tokens:                      input=41, output=56, total=97                                                                                 
DEBUG * Duration:                    2.7732s                                                                                                       
DEBUG * Tokens per second:           20.1931 tokens/s                                                                                              
DEBUG **********************************************************  METRICS  **********************************************************              
DEBUG ----------------------------------------------------- OpenAI Response End -----------------------------------------------------              
DEBUG Added RunOutput to Agent Session                                                                                                             
DEBUG ************************************* Agent Run End: f363b908-5cb3-44c2-80e9-f2b83c46c7fb *************************************              
DEBUG Updated team run context with member name: Weather Agent                                                                                     
DEBUG Added RunOutput to Team Session                                                                                                              
DEBUG ============================================================= tool ============================================================              
DEBUG Tool call Id: call_IFeG4agBKr6I5XhaOvG9DuR6                                                                                                  
DEBUG I’m unable to provide real-time weather updates or current forecasts. To get the most accurate and up-to-date weather information for Tokyo, 
      I recommend checking a reliable weather website or app such as the Weather Channel, BBC Weather, or a local news service that offers live    
      weather updates.                                                                                                                             
DEBUG ********************************************************  TOOL METRICS  *******************************************************              
DEBUG * Duration:                    0.0020s                                                                                                       
DEBUG ********************************************************  TOOL METRICS  *******************************************************              
DEBUG ========================================================== assistant ==========================================================              
DEBUG I couldn't retrieve the weather for Tokyo at the moment. For the latest and most accurate weather updates, please check a reliable weather   
      website or app like the Weather Channel, BBC Weather, or a local news service.                                                               
DEBUG **********************************************************  METRICS  **********************************************************              
DEBUG * Tokens:                      input=605, output=43, total=648                                                                               
DEBUG * Duration:                    3.8719s                                                                                                       
DEBUG * Tokens per second:           11.1055 tokens/s                                                                                              
DEBUG **********************************************************  METRICS  **********************************************************              
DEBUG ----------------------------------------------------- OpenAI Response End -----------------------------------------------------              
DEBUG Added RunOutput to Team Session                                                                                                              
DEBUG ************************************** Team Run End: e1d1a15c-777b-48b4-89f0-3f8496f41075 *************************************              
┏━ Message ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃                                                                                                                                                 ┃
┃ What is the weather in Tokyo?                                                                                                                   ┃
┃                                                                                                                                                 ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Team Tool Calls ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃                                                                                                                                                 ┃
┃ • delegate_task_to_member(member_id=weather-agent, task=Get the current weather and 7-day forecast for Tokyo.)                                  ┃
┃                                                                                                                                                 ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Response (11.7s) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃                                                                                                                                                 ┃
┃ I couldn't retrieve the weather for Tokyo at the moment. For the latest and most accurate weather updates, please check a reliable weather      ┃
┃ website or app like the Weather Channel, BBC Weather, or a local news service.                                                                  ┃
┃                                                                                                                                                 ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

💡 You can set debug_level=2 to get even more detailed logs.

 

インタラクティブ CLI

Agno はまた、チームをコマンドライン・アプリケーションとして実行する、事前構築済みインタラクティブ CLI を備えています。これを使用して、チームとの会話のやり取りをテストできます。

from agno.team import Team
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIChat

news_agent = Agent(name="News Agent", role="Get the latest news")
weather_agent = Agent(name="Weather Agent", role="Get the weather for the next 7 days")

team = Team(
    name="News and Weather Team",
    members=[news_agent, weather_agent],
    model=OpenAIChat(id="gpt-4o"),
    db=SqliteDb(db_file="tmp/data.db"),
    add_history_to_context=True,
    num_history_runs=3,
)

# Run team as an interactive CLI app
team.cli_app(stream=True)

出力例

 😎 User : 東京のニュースは?
INFO Agent 'News Agent' inheriting model from Team: gpt-4o                                                                                         
INFO Agent 'Weather Agent' inheriting model from Team: gpt-4o                                                                                      
┏━ Message ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃                                                                                                                                                 ┃
┃ 東京のニュースは?                                                                                                                              ┃
┃                                                                                                                                                 ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Team Tool Calls ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃                                                                                                                                                 ┃
┃ • delegate_task_to_member(member_id=news-agent, task=Retrieve the latest news about Tokyo. Provide a summary                                    ┃
┃   including key headlines and important updates related to Tokyo.)                                                                              ┃
┃                                                                                                                                                 ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Response (27.4s) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃                                                                                                                                                 ┃
┃ こちらが最新の東京に関するニュース概要です:                                                                                                    ┃
┃                                                                                                                                                 ┃
┃ 1. **経済成長**:                                                                                                                                ┃
┃ 東京はアジアの経済ハブとして重要な地位を保ち、技術、金融、製造などの分野で着実な成長を示しています。デジタル変革とグリーン技術への注力が国際的  ┃
┃ な投資を引き付けています。                                                                                                                      ┃
┃                                                                                                                                                 ┃
┃ 2. **インフラの発展**: 公共交通システムの拡張や鉄道網のアップグレードなど、都市の持続可能な開発に向けた主要なインフラプロジェクトが進行中です。 ┃
┃                                                                                                                                                 ┃
┃ 3. **観光とイベント**: 世界的な旅行の再開に伴い、東京の観光業が復活しています。国際博覧会などのイベントが世界中からの訪問者を引き寄せています。 ┃
┃                                                                                                                                                 ┃
┃ 4. **技術と革新**:                                                                                                                              ┃
┃ 人工知能やロボット工学、スマートシティソリューションにおけるイニシアチブを進め、東京は技術革新のリーダーとしての評価を維持しています。          ┃
┃                                                                                                                                                 ┃
┃ 5. **環境イニシアチブ**:                                                                                                                        ┃
┃ 気候変動と環境持続可能性に対処するため、炭素排出削減や再生可能エネルギーの促進、緑地の拡充を目指した政策が実施されています。                    ┃
┃                                                                                                                                                 ┃
┃ 6. **文化と社会の動向**:                                                                                                                        ┃
┃ 東京では祭りやアート展、料理イベントなどが開催され、多様な文化が紹介されています。また、住宅の手頃さや都市居住条件などの社会問題も積極的に対処  ┃
┃ されています。                                                                                                                                  ┃
┃                                                                                                                                                 ┃
┃ このニュースは、東京が地域的および国際的に重要であることを強調するもので、多様で活発な動きを示しています。                                      ┃
┃                                                                                                                                                 ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

 

以上