0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

AgnoのAgentプロンプト設定の謎をソースコードから追跡してみた

Last updated at Posted at 2025-03-16

Agnoのエージェントを設定する際、プロンプト関連の引数が複数あり、どう設定すれば良いか迷いました。具体的にはdescriptioninstructionsintroductionという似たような引数があり、特にinstructionsintroductionに何を設定するべきなのか理解できません。

公式ドキュメントを見ても、説明がやや曖昧で理解が難しかったため、直接ソースコードを参照して調査しました。

プロンプト生成の仕組み

ソースコードを調べたところ、Agentクラスのget_system_prompt(self)メソッドでプロンプトが生成される仕組みを確認しました。生成されるプロンプトの基本構造は以下のようになっています。

"""
{description}\n
<your_goal>
{goal}
</your_goal>

<your_role>
{self.role}
</your_role>

<instructions>
 - {instructions}
</instructions>

<additional_information>
- The current time is {datetime.now()}
- Your name is: {self.name}.
</additional_information>

"""

プロンプト引数の整理

ソースコードから読み取れるAgentの主なプロンプト引数を整理しました。

引数 Type 意味
system_prompt str | Callable | Message システムプロンプトを独自に設定する(以下のパラメータは無視)
create_default_system_message bool システムプロンプトを生成する/しない
description str | None システムプロンプトの冒頭に追加される
goal str | None Agentの目標を設定
role str | None Agentが演じる役割を設定
add_datetime_to_instructions bool プロンプト内に現在日時を追加するかどうか
name str | None Agentの名前を設定
add_name_to_instructions bool プロンプト内に名前を表示するかどうか
instructions str | list[str] | Callable Agentが具体的に実行すべき手順や指示

system_prompt について

system_promptを指定すると、上記の表のsystem_prompt以外の引数は全部無視して、system_promptの内容が、プロンプトとして設定されます。

create_default_system_message について

create_default_system_messageをFalseに設定すると、上記の表のcreate_default_system_message以降を無視してシステムプロンプトは生成されません。

introduction について

introduction引数には特別な使われ方をします。この引数が使用される条件は、storageが指定されたセッションが最初に生成される時のみです。この時にAgentが最初に生成するメッセージとして使用されます。具体的なユースケースは明確ではありませんが、マルチエージェント連携時の初期導入メッセージなどに使われる可能性があります。

詳しくはソースコードをご覧ください。

以上がAgnoエージェントのプロンプト設定の謎解明のための調査結果でした。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?