View a markdown version of this page

管理 A/B 測試 - Amazon Bedrock AgentCore

管理 A/B 測試

更新 A/B 測試以啟動、暫停或停止它。您可以使用 UpdateABTest操作來變更執行狀態。

注意

AgentCore CLI 生命週期命令 (viewpauseresumestoppromotearchive) 會依與 一起傳遞的任務 ID 來識別測試-i, --id,而非名稱。從 agentcore run ab-test --json( id 欄位) 取得 ID,或使用 列出測試agentcore view ab-test。任務 ID 使用 格式 name-suffix。例如:customerSupportTargetTest-Ab1Cd2Ef3G。任務記錄會在本機以 JSON 形式儲存在專案.cli/jobs/ab-tests/中的 下。

程式碼範例

檢視、暫停、繼續和停止

範例
AgentCore CLI

列出所有 A/B 測試任務,或詳細檢視任務 (也顯示調用 URL 和結果):

agentcore view ab-test agentcore view ab-test <ab-test-id>

繼續暫停的測試:

agentcore resume ab-test -i <ab-test-id>

暫停執行中的測試。流量會停止分割,且所有請求都會路由至控制變體。可以繼續。

agentcore pause ab-test -i <ab-test-id>

永久停止測試。所有流量都會還原至控制變體。這無法復原。

agentcore stop ab-test -i <ab-test-id>
AWS SDK (boto3)

開始測試 (將執行狀態設定為 RUNNING):

import boto3 import uuid client = boto3.client("bedrock-agentcore", region_name="us-west-2") response = client.update_ab_test( abTestId="customerSupportPromptTest-Ab1Cd2Ef3G", executionStatus="RUNNING", clientToken=str(uuid.uuid4()), ) print(f"Execution status: {response['executionStatus']}")

暫停執行中的測試:

response = client.update_ab_test( abTestId="customerSupportPromptTest-Ab1Cd2Ef3G", executionStatus="PAUSED", clientToken=str(uuid.uuid4()), ) print(f"Execution status: {response['executionStatus']}")

永久停止執行中的測試:

response = client.update_ab_test( abTestId="customerSupportPromptTest-Ab1Cd2Ef3G", executionStatus="STOPPED", clientToken=str(uuid.uuid4()), ) print(f"Execution status: {response['executionStatus']}")

提升處理變體

當結果達到統計顯著性時,請提升處理變體。 會promote停止測試並將處理變體寫入 agentcore.jsonagentcore deploy之後執行 將其推出。

範例
AgentCore CLI
agentcore promote ab-test -i <ab-test-id> agentcore deploy
AWS SDK (boto3)

開發套件沒有單一的「提升」操作。停止測試,然後自行將獲勝變體套用到您的資源 (例如,更新控制組態套件或閘道目標以符合處理方式)。

刪除 A/B 測試

刪除 A/B 測試及其相關聯的中繼資料。測試必須處於STOPPED執行狀態,才能將其刪除。刪除測試不會影響測試參考的組態套件、AgentCore Gateway 或線上評估組態。

範例
AgentCore CLI
agentcore archive ab-test -i <ab-test-id>
AWS SDK (boto3)

停止然後刪除:

import boto3 import uuid client = boto3.client("bedrock-agentcore", region_name="us-west-2") # First stop the test if it's running client.update_ab_test( abTestId="customerSupportPromptTest-Ab1Cd2Ef3G", executionStatus="STOPPED", clientToken=str(uuid.uuid4()), ) # Then delete response = client.delete_ab_test( abTestId="customerSupportPromptTest-Ab1Cd2Ef3G" ) print(f"Deleted: {response['abTestId']}")

執行狀態轉換

說明

NOT_STARTED

RUNNING

開始測試。AgentCore Gateway 會開始分割流量。

RUNNING

PAUSED

暫停測試。流量會停止分割;要控制的所有流量路由。

PAUSED

RUNNING

繼續暫停的測試。

RUNNING

STOPPED

永久停止測試。流量路由會立即結束。

PAUSED

STOPPED

永久停止暫停的測試。