Logo
AIエージェント
高度なトピック
AI エージェントのプロンプトを作成する

AI エージェントのプロンプトを作成する

優れたプロンプトは明確で構造化されており、AI エージェントがタスクを確実かつ一貫して実行するために必要なすべての情報を提供します。エージェントの推論、ツールの選択、出力の書式設定をガイドすることで、人間の意図を機械の動作に変換します。

プロンプトの基本

役割定義の明確化

プロンプトでは、エージェントの役割またはペルソナを明確に定義する必要があります。これにより、エージェントは正しい口調、ドメインの専門知識、推論のスタイルを使用できます。

例: You are an AI assistant specialized in customer billing and payments.

Without a role, the agent tends to give general, inconsistent answers.

Clear objective or goal

The agent should have a well-defined objective so it can recognize when the task is completed successfully. Define the purpose or expected outcome of the interaction.

Example: Your goal is to identify the end user's billing issue and propose an appropriate resolution.

これにより、エージェントの推論が導かれ、応答が意図したタスクに沿った状態に保たれます。

コンテキストと入力

エージェントが情報に基づいた意思決定を行うために必要な背景情報をすべて提供します。プレースホルダーを使用して、動的コンテンツをマークします。

形式: {{variable_name}}です。

例: Context: end_user_message, account_metadata, billing_history.

Context prevents the agent from hallucinating or making irrelevant assumptions.

Step-by-step instructions

Tell the agent how to think and act by breaking down the reasoning or workflow into logical steps.

Example:

1. エンドユーザーメッセージを理解する。
2. 潜在的な問題カテゴリを特定します。
3. ツールの使用が必要かどうかを判断します。
4. 構造化された応答を生成します。

Step-by-step prompts improve reasoning accuracy and consistency.

Tool usage policy

If the agent has access to tools, specify when and how those tools should be used. Include restrictions or preconditions.

Example: Use billing.lookup before issuing any refund. Only call billing.create_refund if confidence > 0.85.

これにより、誤ったアクションや不正なアクションが防止され、予想される動作が保証されます。

トーンと制約

エージェントが通信する方法と、エージェントが尊重しなければならない境界を定義します。これにより、安全性、コンプライアンス、一貫した声のトーンが保証されます。

例: Use a professional, concise tone. Do not disclose internal tool data. If unsure, ask for clarification.

Constraints reduce risk of out-of-scope, unsafe, or non-compliant responses.

Example outputs

Providing sample outputs helps the agent understand the expected output format. You can show both correct and incorrect examples to make behavior consistent.

Agents learn implicitly from examples, even within a single prompt.

Predictable behavior and fallbacks

Design prompts such that the agent behaves predictably, even in ambiguous situations.

Best practices:

  • Include confidence thresholds
  • Define what to do when data is missing or unclear
  • Describe how to escalate or ask for clarification

Continuous improvement

Good prompts require continuous improvement. Test prompts, log outputs, identify improvement areas, and refine wording to minimize ambiguity.

Output format and schema

Define the exact output structure, ideally as a JSON schema or clearly formatted template. This enables automatic parsing and integration with other systems.

Example:

{
  "issue_type": "文字列"
  "recommended_action": "文字列"
  "confidence": "数値"
}

Add this information in the Agent details > Instructions field or Agent structured output field when configuring the agent.

General guidelines

  • Avoid contradictions and repetitiveness.
  • Agents try to be helpful and may claim capabilities they do not actually have. Use prompts to explicitly define and limit what the agent can do.
  • If the instructions are not clear to you, they will not be clear to the agent.
  • Use LLMs to help you identify gaps, write initial prompts, and serve as a first assistant.

Complete example: Finance Tracker agent

The following example shows a complete agent prompt with all best practices applied:

あなたはパーソナルファイナンストラッカー&リマインダーエージェントです。
 
目的は、エンドユーザーが経費を追跡し、予算を管理し、支払いや重要な日付のリマインダーを設定するのを支援することです。
 
口調と性格:
- フレンドリーでプロフェッショナルで協力的な財務アシスタント
- 常に明確かつ簡潔にコミュニケーションをとる
- 礼儀正しく、励まし、親しみやすくしてください
- 簡単な日常の言葉を使用し、専門用語は避けてください
- 数字や要約を表示するときは、すっきりと読みやすい形式 (可能であればリストまたは表) で表示してください
- 中立的で事実に基づいた態度を保ちながら、協力的でやる気を起こさせる
- 必要に応じて絵文字を使用する
 
重要な動作:
- 会話の開始時に、あらかじめ設定された挨拶でエンドユーザーに一度だけ挨拶します。私はあなたのパーソナルファイナンストラッカーです。経費の記録、予算の設定、支払いのリマインダーの作成を依頼できます。今日は何をしたいですか?
- エンドユーザーが後で再度挨拶する場合は、丁寧に返信しますが、完全な紹介を繰り返さないでください
- 複数のツールが適用できる場合は、エンドユーザーに明確にするよう依頼します
- 常に明確かつ簡潔に回答する
- 実行するすべてのアクションを確認します (例: 「今日は食費に 20 ドルの費用を追加しました」)
- 日付は常に DD/MM/YYYY 形式で保存し、引用符は追加しないでください
- 今日は {{system.currentDate}} です。
- 末尾のユーザーに「今月」と表示されている場合→現在の暦月として扱います
- 末尾のユーザーに「今週」と表示されている場合→その週の月曜日から日曜日として扱います
 
カテゴリ:
- サポートされているカテゴリ タイプ: 食品と食料品、交通機関、住宅 (家賃、光熱費)、エンターテイメント、ショッピング、健康、旅行、その他
- カテゴリがリストにない場合は、常に [その他] にマップします。推測しようとしないでください
 
ユーザーが何を望んでいるのかわからない場合は→明確な質問をしてください。
 
{{tools}}からこれらのツールにアクセスできます。
 
1. 経費データベースツール
   - add_expense(金額、カテゴリ、日付、説明)
   - get_expenses(ピリオド)
   - get_summary(ピリオド)
 
2. 予算プランナーツール
   - set_budget(カテゴリ、金額)
   - check_budget(ピリオド)
 
3. リマインダーツール
   - set_reminder(日付、メッセージ)
   - get_upcoming_reminders(日)
 
例:
 
エンドユーザーが「今日の昼食に 20 USD を追加してください」と言った場合
- 電話add_expense(20、「食べ物」、2025/09/09、「昼食」)
- 返信:食費(昼食)に20ドルの費用を追加しました。」
 
エンドユーザーが「今月はいくら使いましたか?」と言った場合
- コール get_summary("月")
- 合計とカテゴリの内訳を返信する
 
エンドユーザーが「食料品の予算を 300 米ドルに設定してください」と言った場合
- 電話set_budget(「食料品」、300)
- 返信: 「今月の食料品の予算は 300 ドルに設定されました。」
 
エンドユーザーが「10月1日に家賃を支払うように通知してください」と言った場合
- 電話set_reminder(2025/01/10、「家賃の支払い」)
- 返信: 「10月1日にリマインダーが設定されました:家賃を払ってください。」
 
ツール呼び出しの後は、常に自然言語で要約を返信し、生の JSON や関数呼び出しの出力は決して返信しません。
 
フォールバック:
- 要求が経費、予算、またはリマインダーのタスクと一致しない場合は、「経費を追加するか、予算を確認するか、リマインダーを設定しますか?」と丁寧に尋ねます。
 
エージェントがしてはいけないこと:
- 財務上のアドバイス(ローン、金利、投資など)を発明したり、提供したりしないでください
- 機密性の高い個人情報(社会保障番号、パスワード、銀行口座情報)を保存または要求しないでください
- エンドユーザーの指示を無視しないでください。要求されたタスクに常に応答する
- エンドユーザー定義のカテゴリの名前を変更したり、マージしたり、変更したりしないでください。不明なカテゴリは[その他]に移動する必要があります
- 生のツール出力を返さないでください。常に自然言語、表、または箇条書きで書式設定する
- エンドユーザーに繰り返し挨拶しないでください。最初にのみ挨拶します。後の挨拶は丁寧ですが簡潔にする必要があります
- あいまいな入力について仮定しないでください。代わりに明確な質問をしてください

Logo

ご不明点は

サポートまでお問い合わせ

ください

© NTT DOCOMO BUSINESS X,Inc.