AWS bedrock-agentcore documentation change
Summary
Clarified memory provisioning timelines and status monitoring
Security assessment
Added elapsed time indicators and status tracking improves user awareness but doesn't directly address security controls or vulnerabilities.
Diff
diff --git a/bedrock-agentcore/latest/devguide/agentcore-get-started-toolkit.md b/bedrock-agentcore/latest/devguide/agentcore-get-started-toolkit.md index 1aea772ce..5a633998f 100644 --- a//bedrock-agentcore/latest/devguide/agentcore-get-started-toolkit.md +++ b//bedrock-agentcore/latest/devguide/agentcore-get-started-toolkit.md @@ -40 +40 @@ Before you start, make sure you have: - * **AWS permissions**. AWS root users or users with privileged roles (such as the **AdministratorAccess** role) can skip this step. Others need to attach the [starter toolkit policy](./runtime-permissions.html#runtime-permissions-starter-toolkit) and [AmazonBedrockAgentCoreFullAccess](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/BedrockAgentCoreFullAccess.html) managed policy. + * **AWS permissions**. AWS root users or users with privileged roles (such as the **AdministratorAccess** role) can skip this step. Others will need to attach the [AmazonBedrockAgentCoreFullAccess](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/BedrockAgentCoreFullAccess.html) managed policy and the AgentCore starter toolkit policy described in [Use the starter toolkit](./runtime-permissions.html#runtime-permissions-starter-toolkit). @@ -42 +42 @@ Before you start, make sure you have: - * **AWS CLI version 2.0 or later**. Configure the AWS CLI using `aws configure`. For more information, see the [AWS Command Line Interface User Guide for Version 2](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html). +###### Note @@ -44 +44,3 @@ Before you start, make sure you have: - * **Amazon Bedrock model access to Claude 3.7 Sonnet**. To enable model access, go to the AWS Management Console, choose Amazon Bedrock, choose **Model access** , and enable **Claude 3.7 Sonnet** in your AWS Region. For information about using a different model with Strands Agents, see the Model Providers section in the [Strands Agents SDK](https://strandsagents.com/latest/documentation/docs/) documentation. +For this tutorial, you only need to add the AmazonBedrockAgentCoreFullAccess and starter toolkit policies; there's no need to create an execution role as described in [Execution role for running an agent in AgentCore Runtime](./runtime-permissions.html#runtime-permissions-execution) because it will be created automatically. + + * **AWS CLI version 2.0 or later**. Configure the AWS CLI using `aws configure`. For more information, see the [AWS Command Line Interface User Guide for Version 2](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html). @@ -76 +78 @@ Install the AgentCore starter toolkit: - pip install "bedrock-agentcore-starter-toolkit>=0.1.21" strands-agents boto3 + pip install "bedrock-agentcore-starter-toolkit>=0.1.21" strands-agents strands-agents-tools boto3 @@ -87 +89,2 @@ Create `agentcore_starter_strands.py`: - from strands import Agent, tool + from strands import Agent + from strands_tools.code_interpreter import AgentCoreCodeInterpreter @@ -90 +92,0 @@ Create `agentcore_starter_strands.py`: - from bedrock_agentcore.tools.code_interpreter_client import CodeInterpreter @@ -99,31 +100,0 @@ Create `agentcore_starter_strands.py`: - ci_sessions = {} - current_session = None - - @tool - def calculate(code: str) -> str: - """Execute Python code for calculations or analysis.""" - session_id = current_session or 'default' - - if session_id not in ci_sessions: - ci_sessions[session_id] = { - 'client': CodeInterpreter(REGION), - 'session_id': None - } - - ci = ci_sessions[session_id] - if not ci['session_id']: - ci['session_id'] = ci['client'].start( - name=f"session_{session_id[:30]}", - session_timeout_seconds=1800 - ) - - result = ci['client'].invoke("executeCode", { - "code": code, - "language": "python" - }) - - for event in result.get("stream", []): - if stdout := event.get("result", {}).get("structuredContent", {}).get("stdout"): - return stdout - return "Executed" - @@ -132,6 +103 @@ Create `agentcore_starter_strands.py`: - global current_session - - if not MEMORY_ID: - return {"error": "Memory not configured"} - - actor_id = context.headers.get('X-Amzn-Bedrock-AgentCore-Runtime-Custom-Actor-Id', 'user') if hasattr(context, 'headers') else 'user' + actor_id = "quickstart-user" @@ -139,2 +105,2 @@ Create `agentcore_starter_strands.py`: - session_id = getattr(context, 'session_id', 'default') - current_session = session_id + # Get runtime session ID for isolation + session_id = getattr(context, 'session_id', None) @@ -141,0 +108,3 @@ Create `agentcore_starter_strands.py`: + # Configure memory if available + session_manager = None + if MEMORY_ID: @@ -144 +113 @@ Create `agentcore_starter_strands.py`: - session_id=session_id, + session_id=session_id or 'default', @@ -150,0 +120,8 @@ Create `agentcore_starter_strands.py`: + session_manager = AgentCoreMemorySessionManager(memory_config, REGION) + + # Create Code Interpreter with runtime session binding + code_interpreter = AgentCoreCodeInterpreter( + region=REGION, + session_name=session_id, + auto_create=True + ) @@ -154,3 +131,8 @@ Create `agentcore_starter_strands.py`: - session_manager=AgentCoreMemorySessionManager(memory_config, REGION), - system_prompt="You are a helpful assistant. Use tools when appropriate.", - tools=[calculate] + session_manager=session_manager, + system_prompt="""You are a helpful assistant with code execution capabilities. Use tools when appropriate. + Response format when using code: + 1. Brief explanation of your approach + 2. Code block showing the executed code + 3. Results and analysis + """, + tools=[code_interpreter.code_interpreter] @@ -169,0 +152 @@ Create `requirements.txt`: + strands-agents-tools @@ -194,0 +178 @@ Configure the agent with memory and execution settings: + # - Type `s` to skip memory setup @@ -216,0 +201 @@ Expected output: +During launch, you'll see the memory creation progress with elapsed time indicators. Memory provisioning may take 2-5 minutes to activate: @@ -218 +203,10 @@ Expected output: - ✅ Memory created: bedrock_agentcore_memory_ci_agent_memory-abc123 + + Creating memory resource for agent: agentcore_starter_strands + ⏳ Creating memory resource (this may take 30-180 seconds)... + Created memory: agentcore_starter_strands_mem-abc123 + Waiting for memory agentcore_starter_strands_mem-abc123 to return to ACTIVE state... + ⏳ Memory: CREATING (61s elapsed) + ⏳ Memory: CREATING (92s elapsed) + ⏳ Memory: CREATING (123s elapsed) + ✅ Memory is ACTIVE (took 159s) + ✅ Memory created and active: agentcore_starter_strands_mem-abc123 @@ -241,2 +234,0 @@ Check the agent's deployment status: - # Memory Status: CREATING (if still provisioning) - # Memory Type: STM+LTM (provisioning...) (if creating with LTM) @@ -247,4 +238,0 @@ Check the agent's deployment status: -###### Note - -Memory may take around 2-5 minutes to activate. - @@ -263,7 +250,0 @@ Test short-term memory within a single session: - # If invoked too early (memory still provisioning), you'll see: - # "Memory is still provisioning (current status: CREATING). - # Long-term memory extraction takes 60-180 seconds to activate. - # - # Please wait and check status with: - # agentcore status" - @@ -447,11 +427,0 @@ If you need to change your AWS Region configuration: -**"Memory status is not active" error** - - * Run `agentcore status` to check the memory status. - - * If the status is showing `provisioning`, wait 2-3 minutes. - - * Retry after the status shows `Memory Type: STM+LTM (3 strategies)`. - - - -