Skip to content

Instantly share code, notes, and snippets.

import boto3
import json
agent_arn = launch_result.agent_arn
agentcore_client = boto3.client(
'bedrock-agentcore',
region_name=region
)
boto3_response = agentcore_client.invoke_agent_runtime(
agentRuntimeArn=agent_arn,
## Query 1: Current weather (general)

```python
print(
    agentcore_runtime.invoke(
        {"prompt": "How is the weather now?"}
    )
)
from strands import Agent, tool
import argparse
import json
from bedrock_agentcore.runtime import BedrockAgentCoreApp
from strands.models import BedrockModel
app = BedrockAgentCoreApp()
# Create a custom tool
@tool
invoke_response = agentcore_runtime.invoke({"prompt": "How is the weather now?"})
print(invoke_response)
🚀 CodeBuild mode: building in cloud (RECOMMENDED - DEFAULT)
• Build ARM64 containers in the cloud with CodeBuild
• No local Docker required
💡 Available deployment modes:
• runtime.launch() → CodeBuild (current)
• runtime.launch(local=True) → Local development
• runtime.launch(local_build=True) → Local build + cloud deploy (NEW)
Starting CodeBuild ARM64 deployment for agent 'strands_claude_weather' to account XXXX (us-west-2)
Setting up AWS resources (ECR repository, execution roles)...
Getting or creating ECR repository for agent: strands_claude_weather
launch_result = agentcore_runtime.launch()
ConfigureResult(config_path=PosixPath('/home/sagemaker-user/amazon-bedrock-agentcore-workshop/01-AgentCore-runtime/01-hosting-agent/01-strands-with-bedrock-model/.bedrock_agentcore.yaml'), dockerfile_path=PosixPath('/home/sagemaker-user/amazon-bedrock-agentcore-workshop/01-AgentCore-runtime/01-hosting-agent/01-strands-with-bedrock-model/Dockerfile'), dockerignore_path=PosixPath('/home/sagemaker-user/amazon-bedrock-agentcore-workshop/01-AgentCore-runtime/01-hosting-agent/01-strands-with-bedrock-model/.dockerignore'), runtime='Docker', region='us-west-2', account_id='XXXX', execution_role=None, ecr_repository=None, auto_create_ecr=True)
from bedrock_agentcore_starter_toolkit import Runtime
from boto3.session import Session
boto_session = Session()
region = boto_session.region_name
agentcore_runtime = Runtime()
agent_name = "strands_claude_weather"
response = agentcore_runtime.configure(
entrypoint="strands_claude.py",
auto_create_execution_role=True,
%python strands_claude.py '{"prompt": "What is the weather now?"}'
Tool #1: weather
The weather is currently **sunny** in most places, with the exception of **Berlin**, which is not sunny at the moment.
Is there anything else you'd like to know about the weather?
%python strands_claude.py '{"prompt": "What is the weather in Berlin now?"}'
I can help you check the weather. Let me get that information for you.
Tool #1: weather
Based on the current weather information, it appears that the weather is **not sunny in Berlin** - in fact, the results indicate that conditions are sunny everywhere except Berlin. Unfortunately, the specific weather conditions in Berlin aren't detailed in the available data, but we can infer that Berlin is experiencing non-sunny weather at the moment. It could be cloudy, rainy, or overcast.
from strands import Agent, tool
import argparse
import json
from strands.models import BedrockModel
# Create a custom tool
@tool
def weather():
""" Get weather """ # Dummy implementation
return "sunny (except Berlin)"