View a markdown version of this page

실측 정보 평가 - Amazon Bedrock AgentCore

실측 정보 평가

실측 정보는 실제 결과를 비교하는 "골드 표준"이라는 주어진 입력에 대해 알려진 올바른 답변 또는 예상되는 동작입니다. 에이전트 평가의 경우 실측 정보는 주관적 품질 평가를 객관적 측정으로 변환하여 회귀 감지, 벤치마크 데이터 세트 및 일반 평가자가 직접 제공할 수 없는 도메인별 정확성을 지원합니다.

실측 정보 평가를 사용하면 평가 API를 호출할 때 세션 범위와 함께 참조 입력을 제공합니다. 서비스는 이러한 참조 입력을 사용하여 에이전트의 실제 동작을 예상 동작과 비교하여 점수를 매깁니다. 특정 실측 필드를 사용하지 않는 평가자는 이를 무시하고 응답에 사용되지 않은 필드를 보고합니다.

지원되는 내장 평가자 및 실측 정보 필드

다음 표에는 실제 정보를 지원하는 내장 평가자와 사용하는 필드가 나와 있습니다.

평가자 수준 실측 정보 필드 설명

Builtin.Correctness

추적

expectedResponse

에이전트의 응답이 예상 응답과 얼마나 정확하게 일치하는지 측정합니다. LLM-as-a-Judge 점수를 사용합니다.

Builtin.GoalSuccessRate

세션

assertions

에이전트의 동작이 전체 세션에서 자연어 어설션을 충족하는지 확인합니다. LLM-as-a-Judge 점수를 사용합니다.

Builtin.TrajectoryExactOrderMatch

세션

expectedTrajectory

실제 도구 호출 시퀀스가 동일한 도구, 동일한 순서, 추가 항목 없이 예상 시퀀스와 정확히 일치하는지 확인합니다. 프로그래밍 방식 점수(LLM 호출 없음).

Builtin.TrajectoryInOrderMatch

세션

expectedTrajectory

모든 예상 도구가 실제 시퀀스 내에서 순서대로 나타나는지 확인하지만 이들 간에 추가 도구를 허용합니다. 프로그래밍 방식 점수.

Builtin.TrajectoryAnyOrderMatch

세션

expectedTrajectory

순서에 관계없이 모든 예상 도구가 실제 시퀀스에 있는지 확인합니다. 추가 도구가 허용됩니다. 프로그래밍 방식 점수.

참고

사용자 지정 평가자는 평가 지침의 자리 표시자를 통해 실측 정보 필드도 지원합니다. 자세한 내용은 사용자 지정 평가자의 실측 정보를 참조하세요.

다음 표에서는 실측 정보 필드를 설명합니다.

Field 유형 Scope 설명

expectedResponse

문자열

추적

특정 턴에 대한 예상 에이전트 응답입니다. 참조 입력 컨텍스트traceId에서를 사용하여 트레이스로 범위가 지정됩니다.

assertions

문자열 목록

세션

세션 전체에서 에이전트의 동작에 대해 참이어야 하는 자연어 문입니다.

expectedTrajectory

도구 이름 목록

세션

세션에 대한 예상 도구 호출 시퀀스입니다.

  • 실측 정보 필드는 선택 사항입니다. 이를 생략하면 평가자는 실측 모드로 돌아갑니다(예: expectedResponse 없이 Builtin.Correctness 여전히 작동하며 컨텍스트만 기반으로 평가됨).

  • 단일 요청으로 모든 실측 정보 필드를 제공할 수 있습니다. 서비스는 각 평가자의 관련 필드를 선택하고 사용되지 않은 필드에 대한 응답ignoredReferenceInputFields으로 보고합니다.

  • 모든 추적expectedResponse에 대해를 제공할 필요는 없습니다. 실측 정보가 없는 트레이스는 평가자의 실측 정보 없는 변형을 사용하여 평가됩니다.

사전 조건

  • Python 3.10 이상

  • 관찰성이 활성화된 AgentCore 런타임에 배포된 에이전트 또는 AgentCore 관찰성 로 구성된 지원되는 프레임워크로 구축된 에이전트. 지원되는 프레임워크:

    • Strands Agents

    • opentelemetry-instrumentation-langchain 또는를 사용한 LangGraph openinference-instrumentation-langchain

  • CloudWatch에서 활성화된 트랜잭션 검색 - 트랜잭션 검색 활성화를 참조하세요.

  • AWS bedrock-agentcore, bedrock-agentcore-controllogs (CloudWatch)에 대한 권한으로 구성된 자격 증명

세션 범위 다운로드에 대한 지침은 온디맨드 평가 시작하기를 참조하세요.

예시 관련 정보

이 페이지의 예제에서는 AgentCore 평가 자습서의 샘플 에이전트를 사용합니다. 에이전트에는 두 가지 도구, calculator 즉 및 weather가 있으며 관찰성이 활성화된 AgentCore 런타임에 배포됩니다.

이 예제에서는 2회전 세션을 가정합니다.

  1. 턴 1: "15 + 27이란 무엇입니까?" - 에이전트가 calculator 도구를 사용하고 결과로 응답합니다.

  2. Turn 2: "What is the weather?" - 에이전트가 weather 도구를 사용하고 현재 날씨로 응답합니다.

평가를 실행하기 전에 에이전트를 호출하고 CloudWatch가 원격 측정 데이터를 수집할 때까지 2~5분 정도 기다립니다.

이 페이지의 예제 전체에서 다음 상수가 사용됩니다. 다음과 같이 고유한 값으로 바꿉니다.

REGION = "<region-code>" AGENT_ID = "my-agent-id" SESSION_ID = "my-session-id" TRACE_ID_1 = "<trace-id-1>" # Turn 1: "What is 15 + 27?" TRACE_ID_2 = "<trace-id-2>" # Turn 2: "What's the weather?"

예상 응답과의 정확성

Builtin.Correctness는 에이전트의 응답이 예상 답변과 얼마나 정확하게 일치하는지 측정하는 트레이스 수준 평가자입니다. expectedResponse를 제공하면 평가자는 LLM-as-a-Judge 점수를 사용하여 에이전트의 실제 응답을 실측과 비교합니다.

AgentCore SDK
  1. from bedrock_agentcore.evaluation import EvaluationClient, ReferenceInputs client = EvaluationClient(region_name=REGION) # String form — matched against the last trace in the session results = client.run( evaluator_ids=["Builtin.Correctness"], agent_id=AGENT_ID, session_id=SESSION_ID, reference_inputs=ReferenceInputs( expected_response="The weather is sunny", ), ) for r in results: print(f"Trace: {r['context']['spanContext'].get('traceId', 'session')}") print(f"Score: {r['value']}, Label: {r['label']}")

    특정 트레이스를 대상으로 하려면를 예상 답변에 대한 예측 매핑 트레이IDsexpected_response로 전달합니다.

    results = client.run( evaluator_ids=["Builtin.Correctness"], agent_id=AGENT_ID, session_id=SESSION_ID, reference_inputs=ReferenceInputs( expected_response={ TRACE_ID_1: "15 + 27 = 42", TRACE_ID_2: "The weather is sunny", }, ), )
AgentCore CLI
  1. # Expected response matched against the last trace agentcore run eval \ --agent AGENT_NAME \ --session-id SESSION_ID \ --evaluator-arn "arn:aws:bedrock-agentcore:::evaluator/Builtin.Correctness" \ --expected-response "The weather is sunny" # Target a specific trace agentcore run eval \ --agent AGENT_NAME \ --session-id SESSION_ID \ --evaluator-arn "arn:aws:bedrock-agentcore:::evaluator/Builtin.Correctness" \ --trace-id TRACE_ID_1 \ --expected-response "15 + 27 = 42" # ARN mode — evaluate an agent outside the CLI project agentcore run eval \ --runtime-arn arn:aws:bedrock-agentcore:<region-code>:<account-id>:runtime/<agent-id> \ --session-id SESSION_ID \ --evaluator-arn "arn:aws:bedrock-agentcore:::evaluator/Builtin.Correctness" \ --expected-response "The weather is sunny"
Starter Toolkit SDK
  1. from bedrock_agentcore_starter_toolkit import Evaluation, ReferenceInputs eval_client = Evaluation(region=REGION) # String form — matched against the last trace results = eval_client.run( agent_id=AGENT_ID, session_id=SESSION_ID, evaluators=["Builtin.Correctness"], reference_inputs=ReferenceInputs( expected_response="The weather is sunny", ), ) for r in results.get_successful_results(): print(f"Score: {r.value:.2f}, Label: {r.label}")

    특정 트레이스를 대상으로 (trace_id, expected_response) 하려면 튜플을 전달합니다.

    results = eval_client.run( agent_id=AGENT_ID, session_id=SESSION_ID, evaluators=["Builtin.Correctness"], reference_inputs=ReferenceInputs( expected_response=(TRACE_ID_1, "15 + 27 = 42"), ), )
Starter Toolkit CLI
  1. # Expected response matched against the last trace agentcore eval run \ --agent-id AGENT_ID \ --session-id SESSION_ID \ --evaluator "Builtin.Correctness" \ --expected-response "The weather is sunny" # Target a specific trace agentcore eval run \ --agent-id AGENT_ID \ --session-id SESSION_ID \ --trace-id TRACE_ID_1 \ --evaluator "Builtin.Correctness" \ --expected-response "15 + 27 = 42" # Save results to a file agentcore eval run \ --agent-id AGENT_ID \ --session-id SESSION_ID \ --evaluator "Builtin.Correctness" \ --expected-response "The weather is sunny" \ --output results.json
AWS SDK (boto3)
  1. import boto3 client = boto3.client("bedrock-agentcore", region_name=REGION) response = client.evaluate( evaluatorId="Builtin.Correctness", evaluationInput={"sessionSpans": session_spans_and_log_events}, evaluationReferenceInputs=[ { "context": { "spanContext": { "sessionId": SESSION_ID, "traceId": TRACE_ID_1 } }, "expectedResponse": {"text": "15 + 27 = 42"} }, { "context": { "spanContext": { "sessionId": SESSION_ID, "traceId": TRACE_ID_2 } }, "expectedResponse": {"text": "The weather is sunny"} } ] ) for result in response["evaluationResults"]: print(f"Score: {result['value']}, Label: {result['label']}")

어설션을 사용한 GoalSuccessRate

Builtin.GoalSuccessRate는 에이전트의 동작이 자연어 어설션 세트를 충족하는지 확인하는 세션 수준 평가자입니다. 어설션은 전체 대화에서 도구 사용, 응답 콘텐츠, 작업 순서 또는 기타 관찰 가능한 동작을 확인할 수 있습니다.

참고

아래 예제에서는 도구 사용을 검증하는 어설션을 사용하지만 어설션은 자유 형식의 자연어입니다. 이를 사용하여 응답 톤, 사실적 정확도, 안전 규정 준수 또는 비즈니스 로직과 같은 에이전트 동작의 모든 측면에서 어설션할 수 있습니다.

AgentCore SDK
  1. from bedrock_agentcore.evaluation import EvaluationClient, ReferenceInputs client = EvaluationClient(region_name=REGION) results = client.run( evaluator_ids=["Builtin.GoalSuccessRate"], agent_id=AGENT_ID, session_id=SESSION_ID, reference_inputs=ReferenceInputs( assertions=[ "Agent used the calculator tool to compute the result", "Agent returned the correct numerical answer of 42", "Agent used the weather tool when asked about weather", ], ), ) for r in results: print(f"Score: {r['value']}, Label: {r['label']}") print(f"Explanation: {r['explanation'][:200]}")
AgentCore CLI
  1. agentcore run eval \ --agent AGENT_NAME \ --session-id SESSION_ID \ --evaluator-arn "arn:aws:bedrock-agentcore:::evaluator/Builtin.GoalSuccessRate" \ --assertion "Agent used the calculator tool to compute the result" \ --assertion "Agent returned the correct numerical answer of 42" \ --assertion "Agent used the weather tool when asked about weather" # ARN mode — evaluate an agent outside the CLI project agentcore run eval \ --runtime-arn arn:aws:bedrock-agentcore:<region-code>:<account-id>:runtime/<agent-id> \ --session-id SESSION_ID \ --evaluator-arn "arn:aws:bedrock-agentcore:::evaluator/Builtin.GoalSuccessRate" \ --assertion "Agent used the calculator tool to compute the result" \ --assertion "Agent returned the correct numerical answer of 42"
Starter Toolkit SDK
  1. from bedrock_agentcore_starter_toolkit import Evaluation, ReferenceInputs eval_client = Evaluation(region=REGION) results = eval_client.run( agent_id=AGENT_ID, session_id=SESSION_ID, evaluators=["Builtin.GoalSuccessRate"], reference_inputs=ReferenceInputs( assertions=[ "Agent used the calculator tool to compute the result", "Agent returned the correct numerical answer of 42", "Agent used the weather tool when asked about weather", ], ), ) for r in results.get_successful_results(): print(f"Score: {r.value:.2f}, Label: {r.label}")
Starter Toolkit CLI
  1. agentcore eval run \ --agent-id AGENT_ID \ --session-id SESSION_ID \ --evaluator "Builtin.GoalSuccessRate" \ --assertion "Agent used the calculator tool to compute the result" \ --assertion "Agent returned the correct numerical answer of 42" \ --assertion "Agent used the weather tool when asked about weather"
AWS SDK (boto3)
  1. import boto3 client = boto3.client("bedrock-agentcore", region_name=REGION) response = client.evaluate( evaluatorId="Builtin.GoalSuccessRate", evaluationInput={"sessionSpans": session_spans_and_log_events}, evaluationReferenceInputs=[ { "context": { "spanContext": { "sessionId": SESSION_ID } }, "assertions": [ {"text": "Agent used the calculator tool to compute the result"}, {"text": "Agent returned the correct numerical answer of 42"}, {"text": "Agent used the weather tool when asked about weather"} ] } ] ) for result in response["evaluationResults"]: print(f"Score: {result['value']}, Label: {result['label']}")

예상 궤적과 궤적 일치

궤적 평가자는 에이전트의 실제 도구 호출 시퀀스를 예상 도구 이름 시퀀스와 비교합니다. 세 가지 변형을 사용할 수 있으며, 각 변형은 일치하는 엄격성이 서로 다릅니다. 세 가지 모두 세션 수준 평가자이며 프로그래밍 방식 점수(LLM 호출이 없으므로 토큰 사용량이 0임)를 사용합니다.

평가자 일치 규칙 예제

Builtin.TrajectoryExactOrderMatch

실제는 예상과 정확히 일치해야 합니다. 동일한 도구, 동일한 순서, 추가 항목 없음

예상: [calculator, weather] , 실제: [calculator, weather] → 통과. 실제: [calculator, weather, calculator] → 실패.

Builtin.TrajectoryInOrderMatch

예상 도구는 순서대로 표시되어야 하지만 그 사이에 추가 도구가 허용됩니다.

예상: [calculator, weather] , 실제: [calculator, some_tool, weather] → 통과.

Builtin.TrajectoryAnyOrderMatch

모든 예상 도구가 있어야 하고, 순서가 중요하지 않으며, 추가 항목이 허용됩니다.

예상: [calculator, weather] , 실제: [weather, calculator] → 통과.

AgentCore SDK
  1. from bedrock_agentcore.evaluation import EvaluationClient, ReferenceInputs client = EvaluationClient(region_name=REGION) results = client.run( evaluator_ids=[ "Builtin.TrajectoryExactOrderMatch", "Builtin.TrajectoryInOrderMatch", "Builtin.TrajectoryAnyOrderMatch", ], agent_id=AGENT_ID, session_id=SESSION_ID, reference_inputs=ReferenceInputs( expected_trajectory=["calculator", "weather"], ), ) for r in results: print(f"{r['evaluatorId']}: {r['value']} ({r['label']})") print(f" {r['explanation'][:150]}")
AgentCore CLI
  1. 도구 이름은 쉼표로 구분된 목록으로 전달됩니다.

    agentcore run eval \ --agent AGENT_NAME \ --session-id SESSION_ID \ --evaluator-arn "arn:aws:bedrock-agentcore:::evaluator/Builtin.TrajectoryExactOrderMatch" \ --evaluator-arn "arn:aws:bedrock-agentcore:::evaluator/Builtin.TrajectoryInOrderMatch" \ --evaluator-arn "arn:aws:bedrock-agentcore:::evaluator/Builtin.TrajectoryAnyOrderMatch" \ --expected-trajectory "calculator,weather" # ARN mode — evaluate an agent outside the CLI project agentcore run eval \ --runtime-arn arn:aws:bedrock-agentcore:<region-code>:<account-id>:runtime/<agent-id> \ --session-id SESSION_ID \ --evaluator-arn "arn:aws:bedrock-agentcore:::evaluator/Builtin.TrajectoryExactOrderMatch" \ --expected-trajectory "calculator,weather"
Starter Toolkit SDK
  1. from bedrock_agentcore_starter_toolkit import Evaluation, ReferenceInputs eval_client = Evaluation(region=REGION) results = eval_client.run( agent_id=AGENT_ID, session_id=SESSION_ID, evaluators=[ "Builtin.TrajectoryExactOrderMatch", "Builtin.TrajectoryInOrderMatch", "Builtin.TrajectoryAnyOrderMatch", ], reference_inputs=ReferenceInputs( expected_trajectory=["calculator", "weather"], ), ) for r in results.get_successful_results(): print(f"{r.evaluator_name}: {r.value:.2f} ({r.label})")
Starter Toolkit CLI
  1. 도구 이름은 쉼표로 구분된 목록으로 전달됩니다.

    agentcore eval run \ --agent-id AGENT_ID \ --session-id SESSION_ID \ --evaluator "Builtin.TrajectoryExactOrderMatch" \ --evaluator "Builtin.TrajectoryInOrderMatch" \ --evaluator "Builtin.TrajectoryAnyOrderMatch" \ --expected-trajectory "calculator,weather"
AWS SDK (boto3)
  1. import boto3 client = boto3.client("bedrock-agentcore", region_name=REGION) for evaluator in [ "Builtin.TrajectoryExactOrderMatch", "Builtin.TrajectoryInOrderMatch", "Builtin.TrajectoryAnyOrderMatch", ]: response = client.evaluate( evaluatorId=evaluator, evaluationInput={"sessionSpans": session_spans_and_log_events}, evaluationReferenceInputs=[ { "context": { "spanContext": { "sessionId": SESSION_ID } }, "expectedTrajectory": { "toolNames": ["calculator", "weather"] } } ] ) for result in response["evaluationResults"]: print(f"{result['evaluatorId']}: {result['value']} ({result['label']})")

한 번의 요청으로 모든 실측 정보 필드 결합

단일 평가 호출로 모든 실측 정보 필드를 함께 전달할 수 있습니다. 서비스는 각 필드를 적절한 평가자에게 라우팅하고 지정된 평가자가 사용하지 않는 필드는 무시합니다. 즉, 페이로드를 수정하지 않고도 참조 입력을 한 번 구성하고 다른 평가자 간에 재사용할 수 있습니다.

AgentCore SDK
  1. from bedrock_agentcore.evaluation import EvaluationClient, ReferenceInputs client = EvaluationClient(region_name=REGION) results = client.run( evaluator_ids=[ "Builtin.Correctness", "Builtin.GoalSuccessRate", "Builtin.TrajectoryExactOrderMatch", "Builtin.TrajectoryInOrderMatch", "Builtin.TrajectoryAnyOrderMatch", ], agent_id=AGENT_ID, session_id=SESSION_ID, reference_inputs=ReferenceInputs( expected_response="The weather is sunny", assertions=[ "Agent used the calculator tool for math", "Agent used the weather tool when asked about weather", ], expected_trajectory=["calculator", "weather"], ), ) for r in results: ignored = r.get("ignoredReferenceInputFields", []) print(f"{r['evaluatorId']}: {r['value']} ({r['label']})") if ignored: print(f" Ignored fields: {ignored}")
AgentCore CLI
  1. agentcore run eval \ --agent AGENT_NAME \ --session-id SESSION_ID \ --evaluator-arn "arn:aws:bedrock-agentcore:::evaluator/Builtin.Correctness" \ --evaluator-arn "arn:aws:bedrock-agentcore:::evaluator/Builtin.GoalSuccessRate" \ --evaluator-arn "arn:aws:bedrock-agentcore:::evaluator/Builtin.TrajectoryExactOrderMatch" \ --assertion "Agent used the calculator tool for math" \ --assertion "Agent used the weather tool when asked about weather" \ --expected-trajectory "calculator,weather" \ --expected-response "The weather is sunny" \ --output results.json
Starter Toolkit SDK
  1. from bedrock_agentcore_starter_toolkit import Evaluation, ReferenceInputs eval_client = Evaluation(region=REGION) results = eval_client.run( agent_id=AGENT_ID, session_id=SESSION_ID, evaluators=[ "Builtin.Correctness", "Builtin.GoalSuccessRate", "Builtin.TrajectoryExactOrderMatch", "Builtin.TrajectoryInOrderMatch", "Builtin.TrajectoryAnyOrderMatch", ], reference_inputs=ReferenceInputs( expected_response="The weather is sunny", assertions=[ "Agent used the calculator tool for math", "Agent used the weather tool when asked about weather", ], expected_trajectory=["calculator", "weather"], ), ) for r in results.get_successful_results(): print(f"{r.evaluator_name}: {r.value:.2f} ({r.label})")
AWS SDK (boto3)
  1. import boto3 client = boto3.client("bedrock-agentcore", region_name=REGION) reference_inputs = [ { "context": { "spanContext": {"sessionId": SESSION_ID} }, "assertions": [ {"text": "Agent used the calculator tool for math"}, {"text": "Agent used the weather tool when asked about weather"} ], "expectedTrajectory": { "toolNames": ["calculator", "weather"] } }, { "context": { "spanContext": { "sessionId": SESSION_ID, "traceId": TRACE_ID_2 } }, "expectedResponse": {"text": "The weather is sunny"} } ] for evaluator in ["Builtin.Correctness", "Builtin.GoalSuccessRate", "Builtin.TrajectoryExactOrderMatch"]: response = client.evaluate( evaluatorId=evaluator, evaluationInput={"sessionSpans": session_spans_and_log_events}, evaluationReferenceInputs=reference_inputs ) for result in response["evaluationResults"]: ignored = result.get("ignoredReferenceInputFields", []) print(f"{result['evaluatorId']}: {result['value']} ({result['label']})") if ignored: print(f" Ignored fields: {ignored}")

무시된 참조 입력 필드 이해

평가자가 사용하지 않는 실측 정보 필드를 제공하는 경우 응답에는 미사용 필드를 나열하는 ignoredReferenceInputFields 배열이 포함됩니다. 이는 오류가 아니라 정보 제공용이며 평가가 성공적으로 완료됩니다.

예를 들어 expectedResponse 제공된 Builtin.Helpfulness를 사용하여를 호출하면 평가자는 실측 정보를 무시하고(유용성이 이를 사용하지 않음) 다음을 반환합니다.

{ "evaluatorId": "Builtin.Helpfulness", "value": 0.83, "label": "Very Helpful", "explanation": "...", "ignoredReferenceInputFields": ["expectedResponse"] }

이 동작은 설계상이며, 각 참조 입력에 대한 페이로드를 조정하지 않고도 단일 참조 입력 세트를 구성하고 여러 평가자 간에 사용할 수 있습니다.

사용자 지정 평가자의 실측 정보

사용자 지정 평가자는 평가 지침의 자리 표시자를 통해 실측 정보 필드를 사용할 수 있습니다. 사용자 지정 평가자를 생성할 때 다음 자리 표시자를 참조할 수 있습니다.

  • 세션 수준 사용자 지정 평가자: {context} , {available_tools} , {actual_tool_trajectory} , {expected_tool_trajectory} , {assertions}

  • 트레이스 수준 사용자 지정 평가자: {context} , {assistant_turn} , {expected_response}

예를 들어 응답 유사성을 확인하는 사용자 지정 트레이스 수준 평가자는 다음을 사용할 수 있습니다.

Compare the agent's response with the expected response. Agent response: {assistant_turn} Expected response: {expected_response} Rate how closely the agent's response matches the expected response on a scale of 0 to 1.

참조 입력expectedResponse에서이 평가자를 로 호출하면 서비스는 채점 전에 자리 표시자를 실제 실측값으로 대체합니다.

사용자 지정 평가자 생성에 대한 자세한 내용은 사용자 지정 평가자를 참조하세요.

참고

온라인 평가는 실측 정보 값을 사용할 수 없는 라이브 프로덕션 트래픽을 모니터링하기 때문에 실측 정보 자리 표시자(, {assertions} {expected_response} , {expected_tool_trajectory} )를 사용하는 사용자 지정 평가자는 온라인 평가 구성에서 사용할 수 없습니다.