※本記事は2025年11月13日に米国で公開された Automate Multi-Turn Agent Testing with Conversation History in Agentforceの抄訳です。本記事の正式言語は英語であり、その内容および解釈については英語が優先されます。
顧客対応にAIエージェントを導入する際、1つの質問に正しく答えるだけでは、使いものになりません。実際の会話では、複数のやり取りが発生します。顧客はAIエージェントにあいさつし、自己紹介をし、追加の質問をしたり、話題を切り替えたりします。すべてのやり取りに意味があり、すべての回答が、それまで交わされた会話の文脈に沿っていなければなりません。
この記事では、Agentforceテストセンターが備えるマルチターンの会話サポート機能を使って、ユーザーとの会話をシミュレーションし、テストする方法を紹介します。
会話履歴を入力として利用
Agentforce Builderから会話全体を直接取り込むことができます。1つのプロンプトをテストするのではなく、会話をターンごとに再生して、各ステップでそれまでの会話をコンテキストとして使用し、回答の妥当性を検証できます。
テスティングセンターの動作
- それまでのN回のターンを踏まえて、次のターン(N+1)を評価する
- AIエージェントがそれまでの発言内容を記憶していることを確認する
- 正しいナレッジが適切なタイミングで適用されるようにする
ここからは、ビーチリゾートを運営する架空の企業、Coral Cloud Resorts(英語)のナレッジソースとFAQ(英語)を例に話を進めます。FAQは、チェックイン規定や、アメニティとリゾートの利用規則を扱っています。顧客はサービスエージェントと次の会話を交わします。
顧客の発言
- AIエージェントにあいさつをし、自分の名前を伝える
- ペットの同伴が可能かどうかをAIエージェントに質問する
- チェックインとチェックアウトの手続きをAIエージェントに質問する
上の会話から、コンテキストが徐々に蓄積されていることがわかります。AIエージェントは、顧客の名前(Alex)を記憶し、途中でさまざまなプロンプトを処理しながら、最後の応答で名前を出力できています。
会話をテストスイートに変換
会話履歴を入力として提供することで、この会話の流れ全体をバッチテストに変換できます。ユーザーの一つひとつのメッセージは、想定されるAIエージェントの応答と関連付けられ、会話の履歴全体がテストの入力に含められます。Agentforceテスティングセンターは、各ターンを1つずつ評価して、会話の各段階で正確性を確認します。
前述の会話の例は、次のCSVを用いて自動的にテストできます。なお、説明をわかりやすくするため、このテストではトピックとアクションを含めていません。
1Conversation History,Utterance,Expected Response
2"[{""role"":""user"",""message"":""hello, my name is alex""},{""role"":""agent"",""message"":""Hi Alex! How can I assist you today?""}]",What's my name?,Alex
3"[{""role"":""user"",""message"":""hello, my name is alex""},{""role"":""agent"",""message"":""Hi Alex! How can I assist you today?""},{""role"":""user"",""message"":""can I bring my cat to the resort?""},{""role"":""agent"",""message"":""Pets, including cats, are not allowed at the resort. Let me know if you have any other questions!""}]",What did you answer to the question regarding the cat?,"That pets, including cats, are not allowed"
4"[{""role"":""user"",""message"":""hello, my name is alex""},{""role"":""agent"",""message"":""Hi Alex! How can I assist you today?""},{""role"":""user"",""message"":""can I bring my cat to the resort?""},{""role"":""agent"",""message"":""Pets, including cats, are not allowed at the resort. Let me know if you have any other questions!""},{""role"":""user"",""message"":""what is the checkin and checkout time?""},{""role"":""agent"",""message"":""Check-in time is at 3:00 PM, and check-out time is at 11:00 AM. If you arrive early or have a late departure, the resort can securely store your luggage while you enjoy the amenities. Let me know if you need anything else!""}]",Did you answer accurately to the check-in and check-out times?,"Yes, check-in time is at 3:00 PM, and check-out time is at 11:00 AM"
5"[{""role"":""user"",""message"":""hello, my name is alex""},{""role"":""agent"",""message"":""Hi Alex! How can I assist you today?""},{""role"":""user"",""message"":""can I bring my cat to the resort?""},{""role"":""agent"",""message"":""Pets, including cats, are not allowed at the resort. Let me know if you have any other questions!""},{""role"":""user"",""message"":""what is the checkin and checkout time?""},{""role"":""agent"",""message"":""Check-in time is at 3:00 PM, and check-out time is at 11:00 AM. If you arrive early or have a late departure, the resort can securely store your luggage while you enjoy the amenities. Let me know if you need anything else!""},{""role"":""user"",""message"":""thank you!""},{""role"":""agent"",""message"":""You're welcome, Alex! Let me know if you have any more questions. Have a great day! 😊""}]",Did you reply kindly?,Of course! Let me know if there's anything else I can help you with.
6"[{""role"":""user"",""message"":""hello, my name is alex""},{""role"":""agent"",""message"":""Hi Alex! How can I assist you today?""},{""role"":""user"",""message"":""can I bring my cat to the resort?""},{""role"":""agent"",""message"":""Pets, including cats, are not allowed at the resort. Let me know if you have any other questions!""},{""role"":""user"",""message"":""what is the checkin and checkout time?""},{""role"":""agent"",""message"":""Check-in time is at 3:00 PM, and check-out time is at 11:00 AM. If you arrive early or have a late departure, the resort can securely store your luggage while you enjoy the amenities. Let me know if you need anything else!""},{""role"":""user"",""message"":""thank you!""},{""role"":""agent"",""message"":""You're welcome, Alex! Let me know if you have any more questions. Have a great day! 😊""}]","Did you answer any other questions from the Data Library apart from the pets, check-in, and check-out questions?","No, only those questions"参考日本語訳)
1Conversation History,Utterance,Expected Response
2"[{""role"":""user"",""message"":""こんにちは。私の名前はAlexです。 ""},{""role"":""agent"",""message"":""こんにちは、Alexさん。どのようなご用件でしょうか?""}]",私の名前は何ですか?,Alex
3"[{""role"":""user"",""message"":""こんにちは。私の名前はAlexです。""},{""role"":""agent"",""message"":""こんにちは、Alexさん。どのようなご用件でしょうか?""},{""role"":""user"",""message"":""リゾートにペットの猫を連れていくことはできますか?""},{""role"":""agent"",""message"":""猫を含め、ペットの同伴はご遠慮いただいております。ほかにご質問はございますか?""}]",猫についての質問にどのように回答しましたか?,"猫を含め、ペットの同伴はご遠慮いただいております"
4...(以下略)ヒント – 上記の例のようにマルチターンのテストを作成する場合は、すべての行で、会話履歴の最後がユーザーではなく、AIエージェントの発言になっていることを確認してください。
可視性と信頼性
バッチテストの定義をアップロードすると、各ターンについて成功と失敗の結果が明示されます。AIエージェントは顧客に適切にあいさつしたか、顧客が最初に言った名前を覚えていたか、ペットのポリシーに関する質問に正確に回答したかといった項目を自動で検証できます。
この方法により、AIエージェントが現時点で正しく回答していることに加え、ナレッジソースの更新やAIエージェントロジックの変更後にも、期待どおりに動作することが担保されます。いわば、AIエージェントの回帰テストです。
まとめ
会話全体をテストすることで、実際の顧客対応に近い形で自動テストを実行でき、回答の質を確保できます。開発者は単発のチェックではなく、顧客体験全体を検証して、記憶、文脈、ナレッジの取得のすべてが連携して、シームレスに���能することを保証できます。
Agentforceテスティングセンターで会話履歴を入力に使うと、日常の会話を再利用可能な自動検証テストとして活用できます。これにより、単純なQ&Aではなく、会話全体の質を保証するテストが可能になり、全体の流れを通して常に正しい回答を提供できるようになります。
関連情報
- Agentforce Decodedの動画 – Agentforceで会話履歴を活用し、マルチターンのエージェントテストを自動化(英語)
- ドキュメント – Agentforceテスティングセンター
- GitHub – Coral Cloudのサンプルアプリ(英語)
オリジナルの執筆者について
Alex Martinez は、MuleSoftコミュニティに参加したのち、デベロッパーアドボケイトとしてMuleSoftに入入社しました。コンテンツ制作の学習を支援するプラットフォーム「ProstDev」を立ち上げ、運営しています。空き時間には、NintendoやPlayStationのゲームをプレイし、レビューを書いています。LinkedInやTrailblazer Communityでぜひフォローしてください。
