View a markdown version of this page

구성 번들 시작하기 - Amazon Bedrock AgentCore

구성 번들 시작하기

이 연습에서는 0에서 에이전트가 런타임에 읽는 버전이 지정된 구성 번들로 안내합니다. 번들을 생성하고, 새 버전을 생성하도록 업데이트하고, 구성을 읽고, 버전 기록을 봅니다.

시작하기 전 준비 사항

다음 사항을 갖추었는지 확인하세요.

  • 에이전트가 AgentCore 런타임에 배포된 AgentCore CLI 프로젝트(또는 아래 부록에 따라 구성 번들을 지원하는 프로젝트 생성)

  • AWS bedrock-agentcore 및에 대한 권한이 있는 자격 증명bedrock-agentcore-control(사전 조건 참조)

boto3 예제에는 다음 상수가 사용됩니다. 다음과 같이 고유한 값으로 바꿉니다.

REGION = "us-west-2" BUNDLE_ID = "myAgentConfig-a1b2c3d4e5" # from create response COMPONENT_ARN = "arn:aws:bedrock-agentcore:us-west-2:123456789012:runtime/MyAgent-abc123"

1단계: 구성 번들 생성

에이전트의 초기 구성으로 번들을 생성합니다. 번들은 구성 요소 ARN으로 키-값 페어(시스템 프롬프트, 모델 ID, 온도, 도구 설명)를 저장합니다.

AgentCore CLI
agentcore add config-bundle \ --name myAgentConfig \ --components '{"arn:aws:bedrock-agentcore:us-west-2:123456789012:runtime/MyAgent-abc123": {"configuration": {"system_prompt": "You are a helpful customer support assistant for Acme Store.", "model_id": "global.anthropic.claude-sonnet-4-5-20250929-v1:0"}}}' agentcore deploy

배포 후 CLI는 번들 ID와 초기 버전 ID를 인쇄합니다.

AWS SDK (boto3)
import boto3 import uuid client = boto3.client("bedrock-agentcore-control", region_name=REGION) response = client.create_configuration_bundle( bundleName="myAgentConfig", components={ COMPONENT_ARN: { "configuration": { "system_prompt": "You are a helpful customer support assistant for Acme Store.", "model_id": "global.anthropic.claude-sonnet-4-5-20250929-v1:0", "temperature": 0.7, } } }, description="Acme Store agent configuration", commitMessage="Initial configuration", clientToken=str(uuid.uuid4()), ) bundle_id = response["bundleId"] version_id = response["versionId"] print(f"Created bundle: {bundle_id}") print(f"Initial version: {version_id}")

2단계: 번들 업데이트

배치 평가를 실행하고 에이전트의 응답이 너무 상세하다는 것을 식별한 후 시스템 프롬프트를 업데이트합니다. 각 업데이트는 변경 불가능한 새 버전을 생성합니다.

AgentCore CLI

에서 번들 구성을 편집agentcore.json한 다음 재배포합니다.

# Edit the system_prompt in agentcore.json, then: agentcore deploy

CLI는 기존 번들을 감지하고 새 버전을 자동으로 생성합니다.

AWS SDK (boto3)
response = client.update_configuration_bundle( bundleId=bundle_id, components={ COMPONENT_ARN: { "configuration": { "system_prompt": ( "You are a helpful customer support assistant for Acme Store. " "Be concise. Confirm actions taken in one sentence." ), "model_id": "global.anthropic.claude-sonnet-4-5-20250929-v1:0", "temperature": 0.5, } } }, parentVersionIds=[version_id], commitMessage="Reduce verbosity: shorter prompt, lower temperature", clientToken=str(uuid.uuid4()), ) new_version_id = response["versionId"] print(f"New version: {new_version_id}")

3단계: 번들 읽기

현재 구성을 검색하여 업데이트가 적용되었는지 확인합니다.

AgentCore CLI
agentcore config-bundle versions --name myAgentConfig

출력에는 커밋 메시지가 포함된 버전 기록이 표시됩니다.

Version                               Branch     Created              Message
────────────────────────────────────────────────────────────────────────────────
a1b2c3d4-...                          mainline   2026-04-28 03:00     Reduce verbosity: shorter prompt, lower temperature
e5f6a7b8-...                          mainline   2026-04-28 02:30     Initial configuration
AWS SDK (boto3)
response = client.get_configuration_bundle(bundleId=bundle_id) config = response["components"][COMPONENT_ARN]["configuration"] print(f"Version: {response['versionId']}") print(f"System prompt: {config['system_prompt']}") print(f"Model: {config['model_id']}") print(f"Temperature: {config.get('temperature')}")

4단계: 버전 비교

두 버전을 구분하여 변경된 내용을 정확히 확인합니다.

AgentCore CLI
agentcore config-bundle diff --name myAgentConfig --from <version-1> --to <version-2>
AWS SDK (boto3)
# Fetch both versions v1 = client.get_configuration_bundle_version(bundleId=bundle_id, versionId=version_id) v2 = client.get_configuration_bundle_version(bundleId=bundle_id, versionId=new_version_id) # Compare v1_config = v1["components"][COMPONENT_ARN]["configuration"] v2_config = v2["components"][COMPONENT_ARN]["configuration"] for key in set(list(v1_config.keys()) + list(v2_config.keys())): if v1_config.get(key) != v2_config.get(key): print(f"{key}:") print(f" before: {v1_config.get(key)}") print(f" after: {v2_config.get(key)}")

다음 단계

부록: 구성 번들 통합이 포함된 에이전트 코드

다음 에이전트 코드는 BeforeModelCallEvent 후크 패턴을 사용하여 런타임 시 활성 구성 번들을 읽습니다. 에이전트는 모듈 수준에서 한 번 생성되며 후크는 각 모델 호출 전에 시스템 프롬프트를 동적으로 업데이트합니다. 구성 번들 변경 사항은 다시 시작하지 않고 즉시 적용됩니다.

  • SDK 요구 사항: bedrock-agentcore-sdk-python 버전 1.8 이상이 필요합니다. 의 get_config_bundle() 메서드는이 버전부터 BedrockAgentCoreContext 사용할 수 있습니다.

이를 에이전트의 로 저장합니다. main.py

"""Agent with Configuration Bundle integration — hooks pattern.""" from strands import Agent, tool from strands.models.bedrock import BedrockModel from strands.hooks.events import BeforeModelCallEvent from bedrock_agentcore.runtime import BedrockAgentCoreApp, BedrockAgentCoreContext app = BedrockAgentCoreApp() DEFAULT_MODEL_ID = "global.anthropic.claude-sonnet-4-5-20250929-v1:0" DEFAULT_SYSTEM_PROMPT = ( "You are a helpful customer support assistant for Acme Store. " "Help customers with their orders, returns, and shipping questions." ) @tool def lookup_order(order_id: str) -> str: """Look up an order by ID.""" orders = { "ORD-1001": {"status": "delivered", "item": "Blue T-Shirt (L)", "total": "$29.99"}, "ORD-1002": {"status": "in_transit", "item": "Running Shoes (10)", "total": "$89.99"}, "ORD-1003": {"status": "delayed", "item": "Wireless Headphones", "days_late": 5, "total": "$59.99"}, } return str(orders.get(order_id, {"error": f"Order {order_id} not found"})) @tool def check_shipping_status(order_id: str) -> str: """Check detailed shipping status for an order.""" statuses = { "ORD-1002": "Package is with carrier, on schedule for April 5.", "ORD-1003": "Package delayed 5 days. Policy: 3+ days late qualifies for 15% discount.", } return statuses.get(order_id, f"No active shipment found for {order_id}.") TOOLS = [lookup_order, check_shipping_status] def dynamic_config_hook(event: BeforeModelCallEvent): """Read config bundle and apply system prompt before every model call.""" config_bundle = BedrockAgentCoreContext.get_config_bundle() event.agent.system_prompt = config_bundle.get("system_prompt", DEFAULT_SYSTEM_PROMPT) agent = Agent( model=BedrockModel(model_id=DEFAULT_MODEL_ID), tools=TOOLS, system_prompt=DEFAULT_SYSTEM_PROMPT, ) agent.hooks.add_callback(BeforeModelCallEvent, dynamic_config_hook) @app.entrypoint def invoke(payload, context): result = agent(payload.get("prompt", "Hello")) return {"response": str(result)} if __name__ == "__main__": app.run()