View a markdown version of this page

建立組態套件 - Amazon Bedrock AgentCore

建立組態套件

建立組態套件,以存放代理程式動態組態的版本化快照。套件是使用mainline分支上的初始版本建立的。

注意

CLI add config-bundle命令會將套件定義儲存至agentcore.json本機。若要在服務上實際建立它,之後您必須執行 agentcore deploy

程式碼範例

範例
AgentCore CLI

使用內嵌元件 JSON 建立 ,然後部署:

agentcore add config-bundle \ --name myAgentConfig \ --description "Initial config" \ --branch mainline \ --commit-message "Initial bundle creation" \ --components '{"arn:aws:bedrock-agentcore:us-west-2:123456789012:runtime/MyAgent-abc123": {"configuration": {"system_prompt": "You are a helpful assistant.", "model_id": "global.anthropic.claude-sonnet-4-5-20250929-v1:0"}}}' agentcore deploy

--components 金鑰可以是 ARNs或格式為 {{runtime:<name>}}或 的預留位置{{gateway:<name>}}。預留位置會在部署時間解析為實際 ARNs,因此請針對專案中管理的資源使用預留位置表單。原始 ARN 金鑰需要資源已存在:

agentcore add config-bundle \ --name myAgentConfig \ --components '{"{{runtime:MyAgent}}": {"configuration": {"system_prompt": "You are a helpful assistant."}}}' agentcore deploy

新增 --description--branch--commit-message以設定版本中繼資料,或--json將結果輸出為 JSON。

從元件檔案建立 ,然後部署:

agentcore add config-bundle \ --name myAgentConfig \ --components-file ./components.json agentcore deploy

範例 components.json

{ "arn:aws:bedrock-agentcore:us-west-2:123456789012:runtime/MyAgent-abc123": { "configuration": { "system_prompt": "You are a helpful customer support assistant for Acme Store. When handling requests: 1) Identify ALL actions needed before starting any. 2) Execute each action in sequence. 3) Before ending any conversation, summarize what was done.", "model_id": "global.anthropic.claude-sonnet-4-5-20250929-v1:0" } } }
AWS SDK (boto3)
import boto3 import uuid client = boto3.client("bedrock-agentcore-control", region_name="us-west-2") RUNTIME_ARN = "arn:aws:bedrock-agentcore:us-west-2:123456789012:runtime/MyAgent-abc123" response = client.create_configuration_bundle( bundleName="myAgentConfig", components={ RUNTIME_ARN: { "configuration": { "system_prompt": "You are a helpful customer support assistant.", "model_id": "global.anthropic.claude-sonnet-4-5-20250929-v1:0", "temperature": 0.7, } } }, description="Initial configuration for MyAgent", branchName="mainline", commitMessage="Initial bundle creation", clientToken=str(uuid.uuid4()), ) print(f"Bundle ID: {response['bundleId']}") print(f"Bundle ARN: {response['bundleArn']}") print(f"Version ID: {response['versionId']}")

請求參數

參數 Type 必要 描述

bundleName

String

套件的名稱。必須符合 [a-zA-Z][a-zA-Z0-9_]{0,99}。名稱在您的帳戶中必須是唯一的。

components

Map

元件識別符與元件組態的映射。金鑰通常是所設定 AgentCore 資源的 ARN (例如,執行期 ARN)。每個值都包含具有任意鍵值對的configuration物件。

description

String

套件的描述。最多 500 個字元。

branchName

String

用於版本追蹤的分支名稱。預設為 mainline。必須符合 [a-zA-Z][a-zA-Z0-9_/-]{0,127}

commitMessage

String

初始版本的遞交訊息。最多 500 個字元。

createdBy

物件

建立此版本的來源。包含 name(必要) 和 arn(選用)。

clientToken

String

等冪性字符。如果您使用相同的字符重試,服務會傳回現有的套件,而不是建立新的套件。

tags

Map

資源標籤。最多 50 個標籤。

回應

欄位 Type Description

bundleArn

String

已建立組態套件的 ARN。

bundleId

String

套件的唯一識別符。格式:{name}-{10-char-suffix}

versionId

String

使用套件建立之初始版本的 UUID。

createdAt

時間戳記

套件建立時。

錯誤

錯誤 HTTP 狀態 說明

ValidationException

400

無效的請求參數。檢查欄位限制條件和命名模式。

ConflictException

409

具有相同名稱或用戶端字符的套件已存在。

ServiceQuotaExceededException

402

您已達到帳戶的組態套件數量上限。

AccessDeniedException

403

許可不足。驗證 IAM 政策是否包含 bedrock-agentcore:CreateConfigurationBundle

ThrottlingException

429

超過請求率。以指數退避重試。

InternalServerException

500

服務端錯誤。重試 請求。