View a markdown version of this page

A/B 测试先决条件 - Amazon Bedrock AgentCore

A/B 测试先决条件

在创建 A/B 测试之前,请确保以下资源已准备就绪。

所需的资源

资源 说明

AgentCore 网关

一个活动 AgentCore 网关,其中至少有一个 HTTP 目标指向您的代理运行时。 AgentCore 网关处理变体之间的流量分配。

代理运行时

至少有一个使用 Amazon Bedrock AgentCore SDK(版本 1.8+)部署的代理运行时。SDK BaggageSpanProcessor 会自动将 A/B 测试实验详情(实验 ARN 和变体名称)附加到运行时发出的所有 OpenTelemetry 跨度。

  • 基于配置包的变体:一个运行时就足够了。这两个变体在同一个运行时运行,配置包版本不同。

  • Target-based 变体:为每个变体部署一个运行时(总共两个)。

在线评估配置

一种有效的在线评估配置,用于指定要对会话运行哪些评估器。

  • 基于配置包的变体:一个在线评估配置,指向两个变体运行的单个运行时。

  • Target-based 变体:每个用于 A/B 测试的运行时端点都有一个在线评估配置(总共两个),因为每个端点都有自己的日志组。

配置包(可选)

使用基于配置包的变体时是必需的。两个捆绑包版本或两个单独的捆绑包:一个用于控制,一个用于治疗。

软件开发工具包要求

需要使用 Amazon Bedrock AgentCore SDK 版本 1.8 或更高版本。SDK BaggageSpanProcessor 包含一个读取 Gate AgentCore way 传播的实验行李标头,并自动使用实验 ARN 和变体名称标记所有运行时间 OpenTelemetry 跨度。在线评估管道读取这些属性以将会话分数映射到正确的变体。您的代理代码中不需要其他工具。

评估员要求

注意

A/B testing 支持内置 LLM-as-judge、自定义和基于代码的赋值器,但要求每个评估器返回一个用于统计显著性计算的数值。对于自定义 LLM-as-judge 赋值器,请ratingScale使用numerical比例(不是categorical)进行配置。对于基于代码的赋值器,请在响应架构中包含value字段。

IAM 权限

A/B 测试执行角色必须信任bedrock-agentcore.amazonaws.com服务主体,并且拥有 AgentCore 网关操作、配置包读取、在线评估配置读取和 CloudWatch 日志访问权限。

注意

只有在您自带执行角色并随之传递时,才需要手动创建此角色agentcore run ab-test --role-arn <arn>。如果省略--role-arn, AgentCore CLI 将自动为测试创建执行角色。

信任策略示例:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "bedrock-agentcore.amazonaws.com" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { "aws:SourceAccount": "${aws:PrincipalAccount}" }, "ArnLike": { "aws:SourceArn": "arn:aws:bedrock-agentcore:*:${aws:PrincipalAccount}:ab-test/*" } } } ] }

权限策略示例:

{ "Version": "2012-10-17", "Statement": [ { "Sid": "AgentCoreResources", "Effect": "Allow", "Action": [ "bedrock-agentcore:GetGateway", "bedrock-agentcore:GetGatewayTarget", "bedrock-agentcore:ListGatewayTargets", "bedrock-agentcore:CreateGatewayRule", "bedrock-agentcore:UpdateGatewayRule", "bedrock-agentcore:GetGatewayRule", "bedrock-agentcore:DeleteGatewayRule", "bedrock-agentcore:ListGatewayRules", "bedrock-agentcore:GetOnlineEvaluationConfig", "bedrock-agentcore:GetEvaluator", "bedrock-agentcore:GetConfigurationBundle", "bedrock-agentcore:GetConfigurationBundleVersion", "bedrock-agentcore:ListConfigurationBundleVersions" ], "Resource": "arn:aws:bedrock-agentcore:*:${aws:PrincipalAccount}:*", "Condition": { "StringEquals": { "aws:ResourceAccount": "${aws:PrincipalAccount}" } } }, { "Sid": "CloudWatchLogsDescribe", "Effect": "Allow", "Action": [ "logs:DescribeLogGroups" ], "Resource": "*" }, { "Sid": "CloudWatchLogs", "Effect": "Allow", "Action": [ "logs:DescribeIndexPolicies", "logs:PutIndexPolicy", "logs:StartQuery", "logs:GetQueryResults", "logs:StopQuery", "logs:FilterLogEvents", "logs:GetLogEvents" ], "Resource": [ "arn:aws:logs:*:${aws:PrincipalAccount}:log-group:/aws/bedrock-agentcore/evaluations/*", "arn:aws:logs:*:${aws:PrincipalAccount}:log-group:aws/spans", "arn:aws:logs:*:${aws:PrincipalAccount}:log-group:aws/spans:*" ] } ] }