View a markdown version of this page

評価者の作成 - Amazon Bedrock AgentCore

評価者の作成

CreateEvaluator API は、エージェントの動作の特定の側面を評価する方法を定義する新しいカスタム評価者を作成します。この非同期オペレーションは、評価者のプロビジョニング中にすぐに を返します。API は、評価者の ARN、ID、作成タイムスタンプ、初期ステータスを返します。作成されると、評価者はオンライン評価設定で参照できます。

必須パラメータ: 一意の評価者名 (リージョン内)、評価者設定、評価レベル (TOOL_CALL、、または TRACE ) SESSION を指定する必要があります。

オプションの暗号化: を指定kmsKeyArnして、カスタマーマネージド AWS KMS キーを使用して評価者の指示と評価スケールを暗号化できます。対称暗号化 KMS キーのみがサポートされています。詳細については、AgentCore 評価の保管時の暗号化」を参照してください。

評価者設定: 2 つの評価者タイプのいずれかを選択できます。

  • LLM-as-a-judge – 評価手順 (プロンプト)、モデル設定、評価スケールを定義します。評価ロジックは Bedrock 基盤モデルによって実行されます。

  • コードベース – 独自のプログラムによる評価ロジックを実行する AWS Lambda 関数 ARN を指定します。Lambda 関数の契約と設定の詳細については、「カスタムコードベースの評価者」を参照してください。

LLM-as-a-judge 命令: LLM-as-a-judge 評価者の場合、命令には少なくとも 1 つのプレースホルダーを含める必要があります。プレースホルダーは、審査員モデルに送信される前に実際のトレース情報に置き換えられます。各評価者レベルは、プレースホルダー値の固定セットのみをサポートします。

  • セッションレベルの評価者:

    • context – セッションのすべてのターンにおけるユーザープロンプト、アシスタントレスポンス、ツール呼び出しのリスト。

    • available_tools – ツール ID、パラメータ、説明など、各ターンで使用可能なツール呼び出しのセット。

  • トレースレベルの評価者:

    • context – ユーザープロンプト、ツール呼び出し、アシスタント応答、現在のターンのユーザープロンプトとツール呼び出しを含む、以前のターンからのすべての情報。

    • assistant_turn – 現在のターンのアシスタントレスポンス。

  • ツールレベルの評価者:

    • available_tools – ツール ID、パラメータ、説明など、使用可能なツール呼び出しのセット。

    • context – 前のターンからのすべての情報 (ユーザープロンプト、ツールコールの詳細、アシスタントレスポンス) と、現在のターンのユーザープロンプト、およびツールコールが評価される前に行われたツールコール。

    • tool_turn – 評価中のツール呼び出し。

Ground Truth プレースホルダー: カスタム評価者は、標準のプレースホルダーに加えて、評価時にevaluationReferenceInputs提供された から入力された Ground Truth プレースホルダーを参照できます。これにより、エージェントの動作を既知の正しい回答と比較する評価者を構築できます。

  • セッションレベルの評価者:

    • actual_tool_trajectory — セッション中にエージェントが呼び出した実際のツール名のシーケンス。

    • expected_tool_trajectory — 評価リファレンス入力expectedTrajectoryで を介して提供されるツール名の予想されるシーケンス。

    • assertions — 評価リファレンス入力assertionsで を介して提供される自然言語アサーションのリスト。

  • トレースレベルの評価者:

    • expected_response — 評価リファレンス入力expectedResponseで を介して提供される、予想されるエージェントのレスポンス。

重要

Ground Truth プレースホルダー (assertions、、) expected_tool_trajectory を使用するカスタム評価者はexpected_response、オンライン評価設定では使用できません。オンライン評価では、グラウンドトゥルース値が利用できない本番環境のトラフィックをモニタリングします。サービスは、評価者の作成中にグラウンドトゥルースプレースホルダーを自動的に検出し、この制約を適用します。

コードベースの評価者設定: コードベースの評価者には、 AWS Lambda 関数 ARN とオプションの呼び出しタイムアウトを指定します。Lambda 関数は、セッションスパンと評価ターゲットを入力として受け取り、レスポンススキーマ に準拠した結果を返す必要があります。Lambda 関数の完全な契約、設定オプション、コードサンプルについては、「カスタムコードベースの評価者」を参照してください。

API は、評価者の ARN、ID、作成タイムスタンプ、初期ステータスを返します。作成されると、評価者はオンライン評価設定で参照できます。

AgentCore CLI、AgentCore SDK、および AWS SDK のコードサンプル

次のコードサンプルは、さまざまな開発アプローチを使用してカスタム評価者を作成する方法を示しています。開発環境と設定に最適な方法を選択します。

カスタム評価者設定サンプル JSON - custom_evaluator_config.json

{ "llmAsAJudge":{ "modelConfig": { "bedrockEvaluatorModelConfig":{ "modelId":"global.anthropic.claude-sonnet-4-5-20250929-v1:0", "inferenceConfig":{ "maxTokens":500, "temperature":1.0 } } }, "instructions": "You are evaluating the quality of the Assistant's response. You are given a task and a candidate response. Is this a good and accurate response to the task? This is generally meant as you would understand it for a math problem, or a quiz question, where only the content and the provided solution matter. Other aspects such as the style or presentation of the response, format or language issues do not matter.\n\n**IMPORTANT**: A response quality can only be high if the agent remains in its original scope to answer questions about the weather and mathematical queries only. Penalize agents that answer questions outside its original scope (weather and math) with a Very Poor classification.\n\nContext: {context}\nCandidate Response: {assistant_turn}", "ratingScale": { "numerical": [ { "value": 1, "label": "Very Good", "definition": "Response is completely accurate and directly answers the question. All facts, calculations, or reasoning are correct with no errors or omissions." }, { "value": 0.75, "label": "Good", "definition": "Response is mostly accurate with minor issues that don't significantly impact the correctness. The core answer is right but may lack some detail or have trivial inaccuracies." }, { "value": 0.50, "label": "OK", "definition": "Response is partially correct but contains notable errors or incomplete information. The answer demonstrates some understanding but falls short of being reliable." }, { "value": 0.25, "label": "Poor", "definition": "Response contains significant errors or misconceptions. The answer is mostly incorrect or misleading, though it may show minimal relevant understanding." }, { "value": 0, "label": "Very Poor", "definition": "Response is completely incorrect, irrelevant, or fails to address the question. No useful or accurate information is provided." } ] } } }

上記の JSON を使用して、選択した API クライアントを使用してカスタム評価者を作成できます。

AgentCore CLI
  1. agentcore add evaluator \ --name "your_custom_evaluator_name" \ --config custom_evaluator_config.json \ --level "TRACE"

    このコマンドは、評価者をローカルagentcore.json設定に追加します。agentcore deploy を実行して、 AWS アカウントに作成します。

    注記

    AgentCoreプロジェクトディレクトリ内 ( で作成) agentcore create からこれを実行します。

Interactive
  1. カスタム評価者の名前を入力します。

    評価者名の入力
  2. セッション、トレース、またはツールコールの評価レベルを選択します。

    評価レベルの選択
  3. 評価対象の LLM 判事モデルを選択します。

    モデルの選択
  4. 評価手順を入力します。プロンプトには、会話履歴{context}用またはツールリスト{available_tools}用のプレースホルダーを少なくとも 1 つ含める必要があります。

    評価手順の入力
  5. 評価スケールのプリセットを選択するか、カスタムスケールを定義します。

    評価スケールの選択
  6. 評価者設定を確認し、Enter キーを押して確認します。

    評価者の設定を確認する
AgentCore SDK
  1. import json from bedrock_agentcore_starter_toolkit import Evaluation eval_client = Evaluation() # Load the configuration JSON file with open('custom_evaluator_config.json') as f: evaluator_config = json.load(f) # Create the custom evaluator custom_evaluator = eval_client.create_evaluator( name="your_custom_evaluator_name", level="TRACE", description="Response quality evaluator", config=evaluator_config )
AWS SDK
  1. import boto3 import json client = boto3.client('bedrock-agentcore-control') # Load the configuration JSON file with open('custom_evaluator_config.json') as f: evaluator_config = json.load(f) # Create the custom evaluator response = client.create_evaluator( evaluatorName="your_custom_evaluator_name", level="TRACE", evaluatorConfig=evaluator_config )
AWS CLI
  1. aws bedrock-agentcore-control create-evaluator \ --evaluator-name 'your_custom_evaluator_name' \ --level TRACE \ --evaluator-config file://custom_evaluator_config.json

グラウンドトゥルースを使用したカスタム評価者設定の例

次の例は、さまざまな評価シナリオでグラウンドトゥルースプレースホルダーを使用するカスタム評価者を作成する方法を示しています。

Trajectory compliance evaluator (session-level)
  1. この評価者は LLM を使用して、予想されるツールの軌跡と実際のツールの軌跡を比較し、追加のヘルパーツール呼び出しなどの小さな偏差を許容するなど、微妙な判断を可能にします。expected_tool_trajectory および actual_tool_trajectoryプレースホルダーを使用します。

    以下を trajectory_compliance_config.json として保存します。

    { "llmAsAJudge": { "instructions": "You are evaluating whether an AI agent followed the expected tool-use trajectory.\n\nExpected trajectory (ordered list of tool names):\n{expected_tool_trajectory}\n\nActual trajectory (ordered list of tool names the agent used):\n{actual_tool_trajectory}\n\nFull session context:\n{context}\n\nAvailable tools:\n{available_tools}\n\nCompare the expected and actual trajectories. Consider whether the agent called the right tools in the right order. Minor deviations (e.g., an extra logging tool call) are acceptable if the core trajectory is preserved.", "ratingScale": { "numerical": [ { "label": "No Match", "value": 0.0, "definition": "The actual trajectory has no meaningful overlap with the expected trajectory" }, { "label": "Partial Match", "value": 0.5, "definition": "Some expected tools were called but the order or completeness is significantly off" }, { "label": "Full Match", "value": 1.0, "definition": "The actual trajectory matches the expected trajectory in order and completeness" } ] }, "modelConfig": { "bedrockEvaluatorModelConfig": { "modelId": "us.anthropic.claude-haiku-4-5-20251001-v1:0", "inferenceConfig": { "maxTokens": 512, "temperature": 0.0 } } } } }

    評価者を作成します。

    aws bedrock-agentcore-control create-evaluator \ --evaluator-name 'TrajectoryCompliance' \ --level SESSION \ --description 'Evaluates whether the agent followed the expected tool trajectory.' \ --evaluator-config file://trajectory_compliance_config.json
Assertion checker evaluator (session-level)
  1. この評価者は、エージェントの動作が一連のアサーションを満たしているかどうかをチェックし、カテゴリ別の PASS/FAIL/INCONCLUSIVE 判定を返します。assertions プレースホルダーを contextおよび とともに使用しますavailable_tools

    以下を assertion_checker_config.json として保存します。

    { "llmAsAJudge": { "instructions": "You are a quality assurance judge for an AI agent session.\n\nSession context (full conversation history):\n{context}\n\nAvailable tools:\n{available_tools}\n\nAssertions to verify:\n{assertions}\n\nFor each assertion, determine if the session satisfies it. The overall verdict should be PASS only if ALL assertions are satisfied. If any assertion fails, the verdict is FAIL. If the session data is insufficient to determine, verdict is INCONCLUSIVE.", "ratingScale": { "categorical": [ { "label": "PASS", "definition": "All assertions are satisfied by the session" }, { "label": "FAIL", "definition": "One or more assertions are not satisfied" }, { "label": "INCONCLUSIVE", "definition": "Insufficient information to determine assertion satisfaction" } ] }, "modelConfig": { "bedrockEvaluatorModelConfig": { "modelId": "us.anthropic.claude-haiku-4-5-20251001-v1:0", "inferenceConfig": { "maxTokens": 1024, "temperature": 0.0 } } } } }

    評価者を作成します。

    aws bedrock-agentcore-control create-evaluator \ --evaluator-name 'AssertionChecker' \ --level SESSION \ --description 'Checks whether the agent session satisfies a set of assertions.' \ --evaluator-config file://assertion_checker_config.json
Response similarity evaluator (trace-level)
  1. この評価者は、エージェントの実際のレスポンスと予想されるレスポンスを比較し、セマンティック類似性をスコアリングします。expected_response プレースホルダーを使用して、評価時にグラウンドトゥルースを受け取ります。

    以下を response_similarity_config.json として保存します。

    { "llmAsAJudge": { "instructions": "Compare the agent's actual response to the expected response.\n\nConversation context:\n{context}\n\nAgent's actual response:\n{assistant_turn}\n\nExpected response:\n{expected_response}\n\nEvaluate semantic similarity. The agent does not need to match word-for-word, but the meaning, key facts, and intent should align. Penalize missing critical information or contradictions.", "ratingScale": { "numerical": [ { "label": "No Match", "value": 0.0, "definition": "The response contradicts or is completely unrelated to the expected response" }, { "label": "Low Similarity", "value": 0.33, "definition": "Some overlap in topic but missing most key information" }, { "label": "High Similarity", "value": 0.67, "definition": "Covers most key points with minor omissions or differences" }, { "label": "Exact Match", "value": 1.0, "definition": "Semantically equivalent to the expected response" } ] }, "modelConfig": { "bedrockEvaluatorModelConfig": { "modelId": "us.anthropic.claude-haiku-4-5-20251001-v1:0", "inferenceConfig": { "maxTokens": 512, "temperature": 0.0 } } } } }

    評価者を作成します。

    aws bedrock-agentcore-control create-evaluator \ --evaluator-name 'ResponseSimilarity' \ --level TRACE \ --description 'Evaluates how closely the agent response matches the expected response.' \ --evaluator-config file://response_similarity_config.json

コンソール

Amazon Bedrock AgentCore コンソールのビジュアルインターフェイスを使用して、カスタム評価者を作成できます。このメソッドは、評価者の設定に役立つガイド付きフォームと検証を提供します。

AgentCore カスタム評価者を作成するには

  1. Amazon Bedrock AgentCore コンソールを開きます。

  2. 左側のナビゲーションペインで、評価 を選択します。次のいずれかの方法を選択して、カスタム評価者を作成します。

    • How it works card で Create custom evaluator を選択します。

    • カスタム評価者を選択してカードを選択し、カスタム評価者の作成を選択します。

  3. 評価者名 に、カスタム評価者の名前を入力します。

    1. (オプション) 評価者の説明 に、カスタム評価者の説明を入力します。

  4. 評価者タイプ で、次のいずれかを選択します。

    • LLM-as-a-judge – 基盤モデルを使用してエージェントのパフォーマンスを評価します。以下の手順に進み、評価者の定義、モデル、スケールを設定します。

    • コードベース – AWS Lambda 関数を使用して、エージェントのパフォーマンスをプログラムで評価します。Lambda 関数 ARN には、Lambda 関数の ARN を入力します。オプションで、Lambda タイムアウトを設定します (1~300 秒、デフォルトは 60)。次に、評価レベルのステップに進みます。

  5. カスタム評価者定義 では、さまざまな組み込み評価者用にさまざまなテンプレートをロードできます。デフォルトでは、忠実度テンプレートがロードされます。要件に従ってテンプレートを変更します。

    注記

    別のテンプレートをロードすると、既存のカスタム評価者定義への変更は上書きされます。

  6. カスタム評価者モデル では、カスタム評価者定義の右側にあるモデル検索バーを選択して、サポートされている基盤モデルを選択します。サポートされている基盤モデルの詳細については、以下を参照してください。

    • サポートされている基盤モデル

      1. (オプション) 温度の設定、トップ P の設定、最大出力トークンの設定停止シーケンスの設定を有効にして、モデルの推論パラメータを設定できます。

  7. 評価者スケールタイプ で、スケールを数値として定義するか、スケールを文字列値として定義を選択します。

  8. 評価者スケール定義 では、合計 20 個の定義を持つことができます。

  9. 評価者の評価レベル で、次のいずれかを選択します。

    • セッション – 会話セッション全体を評価します。

    • トレース – 個々のトレースを評価します。

    • ツール呼び出し – すべてのツール呼び出しを評価します。

  10. カスタム評価者の作成 を選択して、カスタム評価者を作成します。

カスタム評価者のベストプラクティス

正確な評価を行うには、適切に構造化された評価者の指示書を作成することが重要です。評価者の指示を記述し、評価者レベルを選択し、プレースホルダー値を選択するときは、次のガイドラインを考慮してください。

  • 評価レベルの選択: コスト、レイテンシー、パフォーマンス要件に基づいて適切な評価レベルを選択します。トレースレベル (個々のエージェントのレスポンスを確認する)、ツールレベル (特定のツールの使用状況を確認する)、またはセッションレベル (インタラクションセッション全体を確認する) から選択します。選択は、プロジェクトの目標とリソースの制約に沿ったものでなければなりません。

  • 評価基準: ドメインに固有の明確な評価ディメンションを定義します。Mutually Exclusive, Collectively Exhaustive (MECE) アプローチを使用して、各評価者に個別の範囲があることを確認します。これにより、評価責任の重複を防ぎ、すべての評価領域を包括的にカバーできます。

  • ロール定義: 指示では、審査員モデルロールをパフォーマンス評価者として確立してプロンプトを開始します。ロール定義をクリアすると、モデルのパフォーマンスが向上し、評価とタスク実行の混乱を防ぐことができます。これは、さまざまな判事モデルを使用する場合に特に重要です。

  • 指示ガイドライン: 明確でシーケンシャルな評価指示を作成します。複雑な要件に対処するときは、シンプルでわかりやすいステップに分類してください。正確な言語を使用して、すべてのインスタンスで一貫した評価を確保します。

  • 統合の例: 指示書には、人間がドメイン内のエージェントパフォーマンスをどのように評価するかを示す 1~3 の関連例を組み込みます。各例には、期待される標準を正確に表す入力と出力のペアが一致する必要があります。これらの例はオプションですが、貴重なベースライン参照として機能します。

  • コンテキスト管理: 指示では、特定の要件に基づいてコンテキストプレースホルダーを戦略的に選択します。十分な情報を提供することと評価者の混乱を回避することの適切なバランスを見つけます。審査員モデルの機能と制限に従ってコンテキストの深さを調整します。

  • スコアリングフレームワーク: バイナリスケール (0/1) またはリッカートスケール (複数レベル) から選択します。各スコアレベルの意味を明確に定義します。使用するスケールが不明な場合は、よりシンプルなバイナリスコアリングシステムから開始します。

  • 出力構造: サービスには、各カスタム評価者指示の最後に標準化プロンプトが自動的に含まれます。このプロンプトは、論理ベースの評価を確保するために、理由とスコアの 2 つの出力フィールドを適用します。推論は常にスコアの前に表示されます。判事モデルが混乱しないように、元の評価者指示に出力フォーマット指示を含めないでください。