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密钥可以是 ARN 或占位符,格式{{runtime:<name>}}为或。{{gateway:<name>}}占位符在部署时解析为真实的 ARN,因此请使用占位符表单来管理项目中管理的资源。原始 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

字符串

捆绑包的名称。必须匹配[a-zA-Z][a-zA-Z0-9_]{0,99}。您的账户中的姓名必须是唯一的。

components

Map

组件标识符到组件配置的映射。密钥通常是正在配置的 AgentCore 资源的 ARN(例如,运行时 ARN)。每个值都包含一个带有任意键值对的configuration对象。

description

字符串

捆绑包的描述。最多 500 个字符。

branchName

字符串

版本跟踪的分支名称。默认值为 mainline。必须匹配[a-zA-Z][a-zA-Z0-9_/-]{0,127}

commitMessage

字符串

初始版本的提交消息。最多 500 个字符。

createdBy

对象

创建此版本的来源。包含name(必填)和arn(可选)。

clientToken

字符串

等能令牌。如果您使用相同的令牌重试,则该服务会返回现有捆绑包,而不是创建新捆绑包。

tags

Map

资源标签。最多 50 个标签。

响应

字段 Type 说明

bundleArn

字符串

创建的配置包的 ARN。

bundleId

字符串

捆绑包的唯一标识符。格式:{name}-{10-char-suffix}

versionId

字符串

使用捆绑包创建的初始版本的 UUID。

createdAt

Timestamp

捆绑包的创建时间。

错误

错误 HTTP 状态 说明

ValidationException

400

请求参数无效。检查字段限制和命名模式。

ConflictException

409

已存在同名或客户端令牌的捆绑包。

ServiceQuotaExceededException

402

您的账户已达到配置包的最大数量。

AccessDeniedException

403

权限不足。验证 IAM 策略是否包含bedrock-agentcore:CreateConfigurationBundle

ThrottlingException

429

超出请求速率。使用指数回退进行重试。

InternalServerException

500

Service-side 错误。重试请求。