Skip to content

ClassCat® AI Research

クラスキャット – Agno, AgentOS, MCP, LangChain/LangGraph, CrewAI

Menu
  • ホーム
    • ClassCat® AI Research ホーム
    • クラスキャット・ホーム
  • OpenAI API
    • OpenAI Python ライブラリ 1.x : 概要
    • OpenAI ブログ
      • GPT の紹介
      • GPT ストアの紹介
      • ChatGPT Team の紹介
    • OpenAI platform 1.x
      • Get Started : イントロダクション
      • Get Started : クイックスタート (Python)
      • Get Started : クイックスタート (Node.js)
      • Get Started : モデル
      • 機能 : 埋め込み
      • 機能 : 埋め込み (ユースケース)
      • ChatGPT : アクション – イントロダクション
      • ChatGPT : アクション – Getting started
      • ChatGPT : アクション – アクション認証
    • OpenAI ヘルプ : ChatGPT
      • ChatGPTとは何ですか?
      • ChatGPT は真実を語っていますか?
      • GPT の作成
      • GPT FAQ
      • GPT vs アシスタント
      • GPT ビルダー
    • OpenAI ヘルプ : ChatGPT > メモリ
      • FAQ
    • OpenAI ヘルプ : GPT ストア
      • 貴方の GPT をフィーチャーする
    • OpenAI Python ライブラリ 0.27 : 概要
    • OpenAI platform
      • Get Started : イントロダクション
      • Get Started : クイックスタート
      • Get Started : モデル
      • ガイド : GPT モデル
      • ガイド : 画像生成 (DALL·E)
      • ガイド : GPT-3.5 Turbo 対応 微調整
      • ガイド : 微調整 1.イントロダクション
      • ガイド : 微調整 2. データセットの準備 / ケーススタディ
      • ガイド : 埋め込み
      • ガイド : 音声テキスト変換
      • ガイド : モデレーション
      • ChatGPT プラグイン : イントロダクション
    • OpenAI Cookbook
      • 概要
      • API 使用方法 : レート制限の操作
      • API 使用方法 : tiktoken でトークンを数える方法
      • GPT : ChatGPT モデルへの入力をフォーマットする方法
      • GPT : 補完をストリームする方法
      • GPT : 大規模言語モデルを扱う方法
      • 埋め込み : 埋め込みの取得
      • GPT-3 の微調整 : 分類サンプルの微調整
      • DALL-E : DALL·E で 画像を生成して編集する方法
      • DALL·E と Segment Anything で動的マスクを作成する方法
      • Whisper プロンプティング・ガイド
  • Gemini API
    • Tutorials : クイックスタート with Python (1) テキスト-to-テキスト生成
    • (2) マルチモーダル入力 / 日本語チャット
    • (3) 埋め込みの使用
    • (4) 高度なユースケース
    • クイックスタート with Node.js
    • クイックスタート with Dart or Flutter (1) 日本語動作確認
    • Gemma
      • 概要 (README)
      • Tutorials : サンプリング
      • Tutorials : KerasNLP による Getting Started
  • Keras 3
    • 新しいマルチバックエンド Keras
    • Keras 3 について
    • Getting Started : エンジニアのための Keras 入門
    • Google Colab 上のインストールと Stable Diffusion デモ
    • コンピュータビジョン – ゼロからの画像分類
    • コンピュータビジョン – 単純な MNIST convnet
    • コンピュータビジョン – EfficientNet を使用した微調整による画像分類
    • コンピュータビジョン – Vision Transformer による画像分類
    • コンピュータビジョン – 最新の MLPモデルによる画像分類
    • コンピュータビジョン – コンパクトな畳込み Transformer
    • Keras Core
      • Keras Core 0.1
        • 新しいマルチバックエンド Keras (README)
        • Keras for TensorFlow, JAX, & PyTorch
        • 開発者ガイド : Getting started with Keras Core
        • 開発者ガイド : 関数型 API
        • 開発者ガイド : シーケンシャル・モデル
        • 開発者ガイド : サブクラス化で新しい層とモデルを作成する
        • 開発者ガイド : 独自のコールバックを書く
      • Keras Core 0.1.1 & 0.1.2 : リリースノート
      • 開発者ガイド
      • Code examples
      • Keras Stable Diffusion
        • 概要
        • 基本的な使い方 (テキスト-to-画像 / 画像-to-画像変換)
        • 混合精度のパフォーマンス
        • インペインティングの簡易アプリケーション
        • (参考) KerasCV – Stable Diffusion を使用した高性能画像生成
  • TensorFlow
    • TF 2 : 初級チュートリアル
    • TF 2 : 上級チュートリアル
    • TF 2 : ガイド
    • TF 1 : チュートリアル
    • TF 1 : ガイド
  • その他
    • 🦜️🔗 LangChain ドキュメント / ユースケース
    • Stable Diffusion WebUI
      • Google Colab で Stable Diffusion WebUI 入門
      • HuggingFace モデル / VAE の導入
      • LoRA の利用
    • Diffusion Models / 拡散モデル
  • クラスキャット
    • 会社案内
    • お問合せ
    • Facebook
    • ClassCat® Blog
Menu

Agno 2.x : エージェント – コンテキスト・エンジニアリング

Posted on 10/27/202510/27/2025 by Masashi Okumura

エージェントに対するプロンプトの作成方法やその他のコンテキスト・エンジニアリング技術を学習します。
コンテキスト・エンジニアリングは、言語モデルの動作や出力をガイドするために (言語モデルに) 送信される情報 (コンテキスト) の設計や制御のプロセスです。実際には、コンテキストの構築は一つの質問に集約されます: 「どの情報が最も望ましい結果を獲得しやすいか?」

Agno 2.x : Learn : エージェント – コンテキスト・エンジニアリング

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

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

  • Learn : Agents – Context Engineering

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

 

 

Agno 2.x : Learn : エージェント – コンテキスト・エンジニアリング

エージェントに対するプロンプトの作成方法やその他のコンテキスト・エンジニアリング技術を学習します。

コンテキスト・エンジニアリングは、言語モデルの動作や出力をガイドするために (言語モデルに) 送信される情報 (コンテキスト) の設計や制御のプロセスです。実際には、コンテキストの構築は一つの質問に集約されます: 「どの情報が最も望ましい結果を獲得しやすいか?」

Agno では、これは、エージェントの説明、指示やその他の関連設定を含む、システムメッセージを注意深く作成することを意味します。このコンテキストを思慮深く構築することにより、以下を行うことができます :

  • エージェントを特定の動作や役割りに向けて誘導する。

  • エージェントの機能を制限、または拡張する。

  • 出力が一貫性があり、関連性があり、そしてアプリケーションのニーズに合致していることを保証します。

  • マルチステップ推論、ツール使用や構造化出力のような高度なユースケースを可能にする。

効果的なコンテキスト・エンジニアリングは、反復的なプロセスです : システムメッセージを洗練し、さまざまな説明や指示を試行錯誤し、スキーマ・委任やツール統合のような機能を使用します。

Agno のコンテキストは以下から構成されます :

  • システム・メッセージ : システムメッセージは、エージェントに送信される主要コンテキストで、すべての追加コンテキストも含みます。

  • ユーザ・メッセージ : ユーザメッセージはエージェントに送信されるメッセージです。

  • チャット履歴 : チャット履歴は、エージェントとユーザ間の会話の履歴です。

  • 追加入力 : コンテキストに追加される、任意の few-shot サンプルやその他の追加入力です。

 

システムメッセージ・コンテキスト

以下は、システムメッセージを作成するために使用される主要パラメータの一部です :

  1. Description (説明) : エージェントの全体的な動作をガイドする説明。

  2. Instructions (指示) : 目標を達成する方法についての正確でタスク固有の指示のリスト。

  3. Expected Output (期待される出力) : エージェントからの期待される出力の説明。

システムメッセージはエージェントの説明、指示やその他の設定から構築されます。

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

agent = Agent(
    model=OpenAIChat(id="gpt-4.1"),
    description="あなたは有名な短編小説家で、ある雑誌に執筆を依頼されました。",
    instructions=["常に2行構成の物語を書いてください。"],
    markdown=True,
    debug_mode=True,  # Set to True to view the detailed logs and see the compiled system message
)
agent.print_response("ホラーストーリーを話してください。", stream=True)

出力例

┏━ Message ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃                                                                                                                                                 ┃
┃ ホラーストーリーを話してください。                                                                                                              ┃
┃                                                                                                                                                 ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Response (2.8s) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃                                                                                                                                                 ┃
┃ 誰もいないはずの暗い部屋の隅から、絞り出すような声で自分の名前が呼ばれた。                                                                      ┃
┃ 振り返ると、鏡の中の自分がゆっくりと笑い始めていた。                                                                                            ┃
┃                                                                                                                                                 ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

これは以下のシステムメッセージを生成します :

DEBUG あなたは有名な短編小説家で、ある雑誌に執筆を依頼されました。                                                                                 
      <instructions>                                                                                                                               
      常に2行構成の物語を書いてください。                                                                                                          
      </instructions>                                                                                                                              
                                                                                                                                                   
      <additional_information>                                                                                                                     
      - Use markdown to format your answers.                                                                                                       
      </additional_information>                                                                                                                    

See the full Agent reference for more information.

 

システムメッセージがどのように構築されるか

次のエージェントの例を見てみましょう :

from agno.agent import Agent

agent = Agent(
    name="役に立つアシスタント",
    role="アシスタント",
    description="あなたは役に立つアシスタントです",
    instructions=["ユーザーの質問に対応してください"],
    additional_context="""
    ここに、ユーザーの質問に答える方法の例があります:
      Request:フランスの首都は何ですか?
      Response:フランスの首都はパリです。
    """,
    expected_output="あなたは応答を `Response: ` という形式でフォーマットする必要があります",
    markdown=True,
    add_datetime_to_context=True,
    add_location_to_context=True,
    add_name_to_context=True,
    add_session_summary_to_context=True,
    add_memories_to_context=True,
    add_session_state_to_context=True,
)

出力例

DEBUG ***************************************************** Agent ID: 役に立つアシスタント ****************************************************    
DEBUG Creating new AgentSession: a9efd7b8-6090-4d6d-b7fd-ebcb67a380fe                                                                              
WARNING  Database not provided. Memories will not be stored.                                                                                       
WARNING  Memory Db not provided.                                                                                                                   
DEBUG ************************************ Agent Run Start: f72610c7-1c5e-4cca-8c21-5e60f269ae9f ************************************              
DEBUG ------------------------------------------------- OpenAI Response Stream Start ------------------------------------------------              
DEBUG -------------------------------------------------------- Model: gpt-4.1 -------------------------------------------------------              
DEBUG ============================================================ system ===========================================================              
DEBUG あなたは役に立つアシスタントです                                                                                                             
                                                                                                                                                   
                                                                                                                                        
      アシスタント                                                                                                                                 
                                                                                                                                       
                                                                                                                                                   
                                                                                                                                     
      ユーザーの質問に対応してください                                                                                                             
                                                                                                                                    
                                                                                                                                                   
                                                                                                                           
      - Use markdown to format your answers.                                                                                                       
      - The current time is 2025-10-27 15:45:10.844852.                                                                                            
      - Your approximate location is: Roppongi, 13, Japan.                                                                                         
      - Your name is: 役に立つアシスタント.                                                                                                        
                                                                                                                          
                                                                                                                                                   
                                                                                                                                  
      あなたは応答を `Response: ` という形式でフォーマットする必要があります                                                             
                                                                                                                                 
                                                                                                                                                   
                                                                                                                                                   
          ここに、ユーザーの質問に答える方法の例があります:                                                                                       
              Request:フランスの首都は何ですか?                                                                                                  
              Response:フランスの首都はパリです。                                                                                                 
                                                                                                                                                   
      You have the capability to retain memories from previous interactions with the user, but have not had any interactions with the user yet.    
                                                                                                                                                   
                                                                                                                                    
      {'current_session_id': 'a9efd7b8-6090-4d6d-b7fd-ebcb67a380fe', 'current_run_id': 'f72610c7-1c5e-4cca-8c21-5e60f269ae9f'}                     
                                                                                                                                   
DEBUG ============================================================= user ============================================================              
DEBUG 次回のサッカーW杯はどこで開催されますか?                                                                                                    
DEBUG ========================================================== assistant ==========================================================              
DEBUG Response: 次回のサッカーW杯(2026年 FIFAワールドカップ)は、アメリカ、カナダ、メキシコの3か国で共同開催されます。                            
DEBUG **********************************************************  METRICS  **********************************************************              
DEBUG * Tokens:                      input=307, output=43, total=350                                                                               
DEBUG * Duration:                    2.3154s                                                                                                       
DEBUG * Tokens per second:           18.5709 tokens/s                                                                                              
DEBUG **********************************************************  METRICS  **********************************************************              
DEBUG -------------------------------------------------- OpenAI Response Stream End -------------------------------------------------              
DEBUG Added RunOutput to Agent Session                                                                                                             
DEBUG ************************************* Agent Run End: f72610c7-1c5e-4cca-8c21-5e60f269ae9f *************************************              
┏━ Message ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃                                                                                                                                                 ┃
┃ 次回のサッカーW杯はどこで開催されますか?                                                                                                       ┃
┃                                                                                                                                                 ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Response (4.3s) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃                                                                                                                                                 ┃
┃ Response: 次回のサッカーW杯(2026年 FIFAワールドカップ)は、アメリカ、カナダ、メキシコの3か国で共同開催されます。                               ┃
┃                                                                                                                                                 ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

 

追加のコンテキスト

additional_context パラメータを使用して、システムメッセージの最後にコンテキストを追加できます。

ここでは、additional_context は、エージェントが特定のデータベース・テーブルにアクセスできることを示す、システムメッセージへのノート (注釈) を追加しています。

from textwrap import dedent

from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.duckdb import DuckDbTools

duckdb_tools = DuckDbTools(
    #create_tables=False, export_tables=False, summarize_tables=False
)
duckdb_tools.create_table_from_path(
    path="https://phidata-public.s3.amazonaws.com/demo_data/IMDB-Movie-Data.csv",
    table="movies",
)

agent = Agent(
    model=OpenAIChat(id="gpt-4.1"),
    debug_mode=True,
    tools=[duckdb_tools],
    markdown=True,
    additional_context=dedent("""\
    あなたは以下のテーブルにアクセスできます :
    - movies: IMDB の映画に関する情報を含む。
    """),
)
agent.print_response("映画の平均評価 (rating) はどれくらいですか?", stream=True)

出力例

INFO Running: CREATE TABLE IF NOT EXISTS movies AS SELECT * FROM read_csv('https://phidata-public.s3.amazonaws.com/demo_data/IMDB-Movie-Data.csv', 
     ignore_errors=false, auto_detect=true)                                                                                                        
DEBUG **************************************** Agent ID: 4783dd06-1109-43ab-8eb3-484b0f7c055d ***************************************              
DEBUG Creating new AgentSession: 6f0d241b-a364-4d36-9474-0a1736f484ec                                                                              
DEBUG Processing tools for model                                                                                                                   
DEBUG Added tool show_tables from duckdb_tools                                                                                                     
DEBUG Added tool describe_table from duckdb_tools                                                                                                  
DEBUG Added tool inspect_query from duckdb_tools                                                                                                   
DEBUG Added tool run_query from duckdb_tools                                                                                                       
DEBUG Added tool create_table_from_path from duckdb_tools                                                                                          
DEBUG Added tool summarize_table from duckdb_tools                                                                                                 
DEBUG Added tool export_table_to_path from duckdb_tools                                                                                            
DEBUG Added tool load_local_path_to_table from duckdb_tools                                                                                        
DEBUG Added tool load_local_csv_to_table from duckdb_tools                                                                                         
DEBUG Added tool load_s3_path_to_table from duckdb_tools                                                                                           
DEBUG Added tool load_s3_csv_to_table from duckdb_tools                                                                                            
DEBUG Added tool create_fts_index from duckdb_tools                                                                                                
DEBUG Added tool full_text_search from duckdb_tools                                                                                                
DEBUG ************************************ Agent Run Start: 0e262d4b-cbea-4c79-915a-91222fabe539 ************************************              
DEBUG ------------------------------------------------- OpenAI Response Stream Start ------------------------------------------------              
DEBUG -------------------------------------------------------- Model: gpt-4.1 -------------------------------------------------------              
DEBUG ============================================================ system ===========================================================              
DEBUG <additional_information>                                                                                                                     
      - Use markdown to format your answers.                                                                                                       
      </additional_information>                                                                                                                    
                                                                                                                                                   
      あなたは以下のテーブルにアクセスできます :                                                                                                   
      - movies: IMDB の映画に関する情報を含む。                                                                                                    
DEBUG ============================================================= user ============================================================              
DEBUG 映画の平均評価 (rating) はどれくらいですか?                                                                                                 
DEBUG ========================================================== assistant ==========================================================              
DEBUG Tool Calls:                                                                                                                                  
        - ID: 'call_P7H9QrY0bP9LJwwt1E6iB0pZ'                                                                                                      
          Name: 'summarize_table'                                                                                                                  
          Arguments: 'table: movies'                                                                                                               
DEBUG **********************************************************  METRICS  **********************************************************              
DEBUG * Tokens:                      input=781, output=16, total=797                                                                               
DEBUG * Duration:                    1.3008s                                                                                                       
DEBUG * Tokens per second:           12.3005 tokens/s                                                                                              
DEBUG **********************************************************  METRICS  **********************************************************              
DEBUG Running: summarize_table(table=movies)                                                                                                       
INFO Running: SUMMARIZE movies                                                                                                                     
DEBUG Query result: column_name,column_type,min,max,approx_unique,avg,std,q25,q50,q75,count,null_percentage                                        
      Rank,BIGINT,1,1000,1232,500.5,288.8194360957494,250,500,750,1000,0.00                                                                        
      Title,VARCHAR,(500) Days of Summer,Zootopia,1080,None,None,None,None,None,1000,0.00                                                          
      Genre,VARCHAR,Action,Thriller,War,215,None,None,None,None,None,1000,0.00                                                                     
      Description,VARCHAR,"21" is the fact-based story about six MIT students who were trained to become experts in card counting and subsequently 
      took Vegas casinos for millions in winnings.,Young, up-and-coming martial artist, Bruce Lee, challenges legendary kung fu master Wong Jack   
      Man to a no-holds-barred fight in Northern California.,691,None,None,None,None,None,1000,0.00                                                
      Director,VARCHAR,Aamir Khan,Zackary Adler,541,None,None,None,None,None,1000,0.00                                                             
      Actors,VARCHAR,Aamir Khan, Anushka Sharma, Sanjay Dutt,Boman Irani,Zooey Deschanel, Joseph Gordon-Levitt, Geoffrey Arend, Chloë Grace        
      Moretz,1116,None,None,None,None,None,1000,0.00                                                                                               
      Year,BIGINT,2006,2016,12,2012.783,3.2059615077522667,2010,2014,2016,1000,0.00                                                                
      Runtime (Minutes),BIGINT,66,191,110,113.172,18.810908172288404,100,111,123,1000,0.00                                                         
      Rating,DOUBLE,1.9,9.0,53,6.723200000000003,0.945428789277963,6.190384615384616,6.8,7.4,1000,0.00                                             
      Votes,BIGINT,61,1791916,903,169808.255,188762.6475182208,36703,110488,239967,1000,0.00                                                       
      Revenue                                                                                                                                      
      (Millions),DOUBLE,0.0,936.63,825,82.95637614678897,103.25354047492468,13.14705627705628,48.27991124260355,113.60702479338843,1000,12.80      
      Metascore,BIGINT,11,100,77,58.98504273504273,17.194757023263847,47,59,72,1000,6.40                                                           
DEBUG Table description: column_name,column_type,min,max,approx_unique,avg,std,q25,q50,q75,count,null_percentage                                   
      Rank,BIGINT,1,1000,1232,500.5,288.8194360957494,250,500,750,1000,0.00                                                                        
      Title,VARCHAR,(500) Days of Summer,Zootopia,1080,None,None,None,None,None,1000,0.00                                                          
      Genre,VARCHAR,Action,Thriller,War,215,None,None,None,None,None,1000,0.00                                                                     
      Description,VARCHAR,"21" is the fact-based story about six MIT students who were trained to become experts in card counting and subsequently 
      took Vegas casinos for millions in winnings.,Young, up-and-coming martial artist, Bruce Lee, challenges legendary kung fu master Wong Jack   
      Man to a no-holds-barred fight in Northern California.,691,None,None,None,None,None,1000,0.00                                                
      Director,VARCHAR,Aamir Khan,Zackary Adler,541,None,None,None,None,None,1000,0.00                                                             
      Actors,VARCHAR,Aamir Khan, Anushka Sharma, Sanjay Dutt,Boman Irani,Zooey Deschanel, Joseph Gordon-Levitt, Geoffrey Arend, Chloë Grace        
      Moretz,1116,None,None,None,None,None,1000,0.00                                                                                               
      Year,BIGINT,2006,2016,12,2012.783,3.2059615077522667,2010,2014,2016,1000,0.00                                                                
      Runtime (Minutes),BIGINT,66,191,110,113.172,18.810908172288404,100,111,123,1000,0.00                                                         
      Rating,DOUBLE,1.9,9.0,53,6.723200000000003,0.945428789277963,6.190384615384616,6.8,7.4,1000,0.00                                             
      Votes,BIGINT,61,1791916,903,169808.255,188762.6475182208,36703,110488,239967,1000,0.00                                                       
      Revenue                                                                                                                                      
      (Millions),DOUBLE,0.0,936.63,825,82.95637614678897,103.25354047492468,13.14705627705628,48.27991124260355,113.60702479338843,1000,12.80      
      Metascore,BIGINT,11,100,77,58.98504273504273,17.194757023263847,47,59,72,1000,6.40                                                           
DEBUG ============================================================= tool ============================================================              
DEBUG Tool call Id: call_P7H9QrY0bP9LJwwt1E6iB0pZ                                                                                                  
DEBUG column_name,column_type,min,max,approx_unique,avg,std,q25,q50,q75,count,null_percentage                                                      
      Rank,BIGINT,1,1000,1232,500.5,288.8194360957494,250,500,750,1000,0.00                                                                        
      Title,VARCHAR,(500) Days of Summer,Zootopia,1080,None,None,None,None,None,1000,0.00                                                          
      Genre,VARCHAR,Action,Thriller,War,215,None,None,None,None,None,1000,0.00                                                                     
      Description,VARCHAR,"21" is the fact-based story about six MIT students who were trained to become experts in card counting and subsequently 
      took Vegas casinos for millions in winnings.,Young, up-and-coming martial artist, Bruce Lee, challenges legendary kung fu master Wong Jack   
      Man to a no-holds-barred fight in Northern California.,691,None,None,None,None,None,1000,0.00                                                
      Director,VARCHAR,Aamir Khan,Zackary Adler,541,None,None,None,None,None,1000,0.00                                                             
      Actors,VARCHAR,Aamir Khan, Anushka Sharma, Sanjay Dutt,Boman Irani,Zooey Deschanel, Joseph Gordon-Levitt, Geoffrey Arend, Chloë Grace        
      Moretz,1116,None,None,None,None,None,1000,0.00                                                                                               
      Year,BIGINT,2006,2016,12,2012.783,3.2059615077522667,2010,2014,2016,1000,0.00                                                                
      Runtime (Minutes),BIGINT,66,191,110,113.172,18.810908172288404,100,111,123,1000,0.00                                                         
      Rating,DOUBLE,1.9,9.0,53,6.723200000000003,0.945428789277963,6.190384615384616,6.8,7.4,1000,0.00                                             
      Votes,BIGINT,61,1791916,903,169808.255,188762.6475182208,36703,110488,239967,1000,0.00                                                       
      Revenue                                                                                                                                      
      (Millions),DOUBLE,0.0,936.63,825,82.95637614678897,103.25354047492468,13.14705627705628,48.27991124260355,113.60702479338843,1000,12.80      
      Metascore,BIGINT,11,100,77,58.98504273504273,17.194757023263847,47,59,72,1000,6.40                                                           
DEBUG ********************************************************  TOOL METRICS  *******************************************************              
DEBUG * Duration:                    0.0309s                                                                                                       
DEBUG ********************************************************  TOOL METRICS  *******************************************************              
DEBUG ========================================================== assistant ==========================================================              
DEBUG 映画の平均評価(rating)は **6.72** です。                                                                                                   
DEBUG **********************************************************  METRICS  **********************************************************              
DEBUG * Tokens:                      input=1363, output=16, total=1379                                                                             
DEBUG * Duration:                    1.2552s                                                                                                       
DEBUG * Tokens per second:           12.7468 tokens/s                                                                                              
DEBUG **********************************************************  METRICS  **********************************************************              
DEBUG -------------------------------------------------- OpenAI Response Stream End -------------------------------------------------              
DEBUG Added RunOutput to Agent Session                                                                                                             
DEBUG ************************************* Agent Run End: 0e262d4b-cbea-4c79-915a-91222fabe539 *************************************              
┏━ Message ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃                                                                                                                                                 ┃
┃ 映画の平均評価 (rating) はどれくらいですか?                                                                                                    ┃
┃                                                                                                                                                 ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Response (2.6s) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃                                                                                                                                                 ┃
┃ 映画の平均評価(rating)は 6.72 です。                                                                                                          ┃
┃                                                                                                                                                 ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

 

ツール指示

エージェントで Toolkit を使用している場合、instructions パラメータを使用してシステムメッセージにツール指示を追加できます :

from agno.agent import Agent
from agno.tools.slack import SlackTools

slack_tools = SlackTools(
    instructions=["Use `send_message` to send a message to the user.  If the user specifies a thread, use `send_message_thread` to send a message to the thread."],
    add_instructions=True,
)
agent = Agent(
    tools=[slack_tools],
)

これらの指示は <additional_information> タグの後にシステムメッセージに注入されます。

 

エージェント型メモリ

エージェントで enable_agentic_memory を True に設定すると、エージェントはツールを使用してユーザメモリを create/update できるようになります。これは以下をシステムメッセージに追加します :

<updating_user_memories>
- You have access to the `update_user_memory` tool that you can use to add new memories, update existing memories, delete memories, or clear all memories.
- If the user's message includes information that should be captured as a memory, use the `update_user_memory` tool to update your memory database.
- Memories should include details that could personalize ongoing interactions with the user.
- Use this tool to add new memories or update existing memories that you identify in the conversation.
- Use this tool if the user asks to update their memory, delete a memory, or clear all memories.
- If you use the `update_user_memory` tool, remember to pass on the response to the user.
</updating_user_memories>

 

エージェント型知識フィルタ

エージェントで知識 (knowledge) 機能を有効にしている場合、enable_agentic_knowledge_filters パラメータを使用して、エージェントに知識フィルタを選択させることができます。これは以下をシステムメッセージに追加します :

The knowledge base contains documents with these metadata filters: [filter1, filter2, filter3].
Always use filters when the user query indicates specific metadata.

Examples:
1. If the user asks about a specific person like "Jordan Mitchell", you MUST use the search_knowledge_base tool with the filters parameter set to {{'<valid key like user_id>': '<valid value based on the user query>'}}.
2. If the user asks about a specific document type like "contracts", you MUST use the search_knowledge_base tool with the filters parameter set to {{'document_type': 'contract'}}.
4. If the user asks about a specific location like "documents from New York", you MUST use the search_knowledge_base tool with the filters parameter set to {{'<valid key like location>': 'New York'}}.

General Guidelines:
- Always analyze the user query to identify relevant metadata.
- Use the most specific filter(s) possible to narrow down results.
- If multiple filters are relevant, combine them in the filters parameter (e.g., {{'name': 'Jordan Mitchell', 'document_type': 'contract'}}).
- Ensure the filter keys match the valid metadata filters: [filter1, filter2, filter3].

You can use the search_knowledge_base tool to search the knowledge base and get the most relevant documents. Make sure to pass the filters as [Dict[str: Any]] to the tool. FOLLOW THIS STRUCTURE STRICTLY.

Learn about agentic knowledge filters in more detail in the knowledge filters section.

 

システムメッセージを直接設定する

system_message パラメータを使用してシステムメッセージを手動で設定できます。これはすべての他の設定を無視して、提供したシステムメッセージを使用します。

from agno.agent import Agent
agent.print_response("What is the capital of France?")

agent = Agent(system_message="Share a 2 sentence story about")
agent.print_response("Love in the year 12000.")

 

ユーザメッセージ・コンテキスト

Agent.run() や Agent.print_response() に送信される入力はユーザメッセージとして使用されます。

​

 

追加のユーザメッセージ・コンテキスト

以下のエージェントのパラメータを使用して、コンテキストをユーザメッセージに追加できます :

以下のエージェント・パラメータはユーザメッセージを構築する方法を設定します :

  • add_knowledge_to_context
  • add_dependencies_to_context
from agno.agent import Agent
agent = Agent(add_knowledge_to_context=True, add_dependencies_to_context=True)
agent.print_response("What is the capital of France?", dependencies={"name": "John Doe"})

モデルに送信されるユーザメッセージはこのようになります :

What is the capital of France?

Use the following references from the knowledge base if it helps:
<references>
- Reference 1
- Reference 2
</references>

<additional context>
{"name": "John Doe"}
</additional context>

See dependencies for how to do dependency injection for your user message.

 

チャット履歴

エージェントでデータベース・ストレージが有効であれば、セッション履歴は自動的に保存されます (セッション 参照)。

add_history_to_context を使用して会話履歴をコンテキストに追加することもできるようになりました。

from agno.agent.agent import Agent
from agno.db.postgres import PostgresDb
from agno.models.openai import OpenAIChat

db_url = "postgresql+psycopg://ai:ai@localhost:5432/ai"

db = PostgresDb(db_url=db_url)

agent = Agent(
    model=OpenAIChat(id="gpt-4.1"),
    db=db,
    session_id="chat_history",
    instructions="あなたは、宇宙や海についての質問に答えることができる、役に立つアシスタントです。",
    add_history_to_context=True,
    num_history_runs=2,  # Optionally limit the number of history responses to add to the context
)

agent.print_response("静かの海はどこにありますか?")

agent.print_response("私の最初の質問は何でしたか?")

出力例

┏━ Message ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃                                                                                                                                                 ┃
┃ 静かの海はどこにありますか?                                                                                                                    ┃
┃                                                                                                                                                 ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Response (6.4s) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃                                                                                                                                                 ┃
┃ 「静かの海」(しずかのうみ)は、**月**にあります。                                                                                              ┃
┃                                                                                                                                                 ┃
┃ これは、月の表面にある広い平原の一つで、ラテン語では「Mare                                                                                      ┃
┃ Tranquillitatis(マーレ・トランクィリタティス)」と呼ばれています。「静かの海」は、1969年に人類が初めて月面に降り立ったアポロ11号の着陸地点とし ┃
┃ ても有名です。                                                                                                                                  ┃
┃                                                                                                                                                 ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Message ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃                                                                                                                                                 ┃
┃ 私の最初の質問は何でしたか?                                                                                                                    ┃
┃                                                                                                                                                 ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Response (4.7s) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃                                                                                                                                                 ┃
┃ あなたの最初の質問は、「What was my first question?」です。                                                                                     ┃
┃                                                                                                                                                 ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

これは会話履歴をコンテキストに追加します、これは次のメッセージ向けにコンテキストを追加するために使用できます。

 

以上





クラスキャット

最近の投稿

  • Agno 2.x : エージェント – コンテキスト・エンジニアリング
  • Agno 2.x : エージェント – 入出力
  • Agno 2.x : エージェント – エージェント・セッション
  • Agno 2.x : エージェント – エージェントの実行とデバッグ
  • Agno 2.x : エージェント – 概要・構築

タグ

AG2 (14) Agno (46) AutoGen (13) ClassCat Press Release (20) ClassCat TF/ONNX Hub (11) DGL 0.5 (14) Edward (17) FLUX.1 (16) Gemini (20) HuggingFace Transformers 4.5 (10) HuggingFace Transformers 4.29 (9) Keras 2 Examples (98) Keras 2 Guide (16) Keras 3 (10) Keras Release Note (17) Kubeflow 1.0 (10) LangChain (45) LangChain v1.0 (10) LangGraph (24) LangGraph 0.5 (9) MediaPipe 0.8 (11) Model Context Protocol (16) NNI 1.5 (16) OpenAI Agents SDK (8) OpenAI Cookbook (13) OpenAI platform (10) OpenAI platform 1.x (10) OpenAI ヘルプ (8) TensorFlow 2.0 Advanced Tutorials (33) TensorFlow 2.0 Advanced Tutorials (Alpha) (15) TensorFlow 2.0 Advanced Tutorials (Beta) (16) TensorFlow 2.0 Guide (10) TensorFlow 2.0 Guide (Alpha) (16) TensorFlow 2.0 Guide (Beta) (9) TensorFlow 2.0 Release Note (12) TensorFlow 2.0 Tutorials (20) TensorFlow 2.0 Tutorials (Alpha) (14) TensorFlow 2.0 Tutorials (Beta) (12) TensorFlow 2.4 Guide (24) TensorFlow Deploy (8) TensorFlow Probability (9) TensorFlow Programmer's Guide (22) TensorFlow Release Note (18) TensorFlow Tutorials (33) TF-Agents 0.4 (11)
2025年10月
月 火 水 木 金 土 日
 12345
6789101112
13141516171819
20212223242526
2728293031  
« 9月    
© 2025 ClassCat® AI Research | Powered by Minimalist Blog WordPress Theme