aws-agentcore
Scannednpx machina-cli add skill Makiya1202/ai-agents-skills/aws-agentcore --openclawAWS Bedrock AgentCore
Build production-grade AI agents on AWS infrastructure.
Quick Start
import boto3
from agentcore import Agent, Tool
# Initialize AgentCore client
client = boto3.client('bedrock-agent-runtime')
# Define a tool
@Tool(name="search_database", description="Search the product database")
def search_database(query: str, limit: int = 10) -> dict:
# Tool implementation
return {"results": [...]}
# Create agent
agent = Agent(
model_id="anthropic.claude-3-sonnet",
tools=[search_database],
instructions="You are a helpful product search assistant."
)
# Invoke agent
response = agent.invoke("Find laptops under $1000")
AgentCore Components
AgentCore provides these primitives:
| Component | Purpose |
|---|---|
| Runtime | Serverless agent execution (framework-agnostic) |
| Gateway | Convert APIs/Lambda to MCP-compatible tools |
| Memory | Multi-strategy memory (semantic, user preference) |
| Identity | Auth with Cognito, Okta, Google, EntraID |
| Tools | Code Interpreter, Browser Tool |
| Observability | Deep analysis and tracing |
Lambda Tool Integration
# Lambda function as tool
import json
def lambda_handler(event, context):
action = event.get('actionGroup')
function = event.get('function')
parameters = event.get('parameters', [])
# Parse parameters
params = {p['name']: p['value'] for p in parameters}
if function == 'get_weather':
result = get_weather(params['city'])
elif function == 'book_flight':
result = book_flight(params['origin'], params['destination'])
return {
'response': {
'actionGroup': action,
'function': function,
'functionResponse': {
'responseBody': {
'TEXT': {'body': json.dumps(result)}
}
}
}
}
Agent Orchestration
from agentcore import SupervisorAgent, SubAgent
# Create specialized sub-agents
research_agent = SubAgent(
name="researcher",
model_id="anthropic.claude-3-sonnet",
instructions="You research and gather information."
)
writer_agent = SubAgent(
name="writer",
model_id="anthropic.claude-3-sonnet",
instructions="You write clear, engaging content."
)
# Create supervisor
supervisor = SupervisorAgent(
model_id="anthropic.claude-3-opus",
sub_agents=[research_agent, writer_agent],
routing_strategy="supervisor" # or "intent_classification"
)
response = supervisor.invoke("Write a blog post about AI agents")
Guardrails Integration
from agentcore import Agent, Guardrail
# Define guardrail
guardrail = Guardrail(
guardrail_id="my-guardrail-id",
guardrail_version="1"
)
agent = Agent(
model_id="anthropic.claude-3-sonnet",
guardrails=[guardrail],
tools=[...],
)
AgentCore Gateway
Convert existing APIs to MCP-compatible tools:
# gateway_setup.py
from bedrock_agentcore import GatewayClient
gateway = GatewayClient()
# Create gateway from OpenAPI spec
gateway.create_target(
name="my-api",
type="OPENAPI",
openapi_spec_path="./api-spec.yaml"
)
# Create gateway from Lambda function
gateway.create_target(
name="my-lambda-tool",
type="LAMBDA",
function_arn="arn:aws:lambda:us-east-1:123456789:function:my-tool"
)
AgentCore Memory
from agentcore import Agent, Memory
# Create memory with multiple strategies
memory = Memory(
name="customer-support-memory",
strategies=["semantic", "user_preference"]
)
agent = Agent(
model_id="anthropic.claude-3-sonnet",
memory=memory,
tools=[...],
)
# Memory persists across sessions
response = agent.invoke(
"What did we discuss last time?",
session_id="user-123"
)
Official Use Cases Repository
AWS provides production-ready implementations:
Repository: https://github.com/awslabs/amazon-bedrock-agentcore-samples
Available Use Cases (02-use-cases/)
| Use Case | Description |
|---|---|
| A2A Multi-Agent Incident Response | Agent-to-Agent with Strands + OpenAI SDK |
| Customer Support Assistant | Memory, Knowledge Base, Google OAuth |
| Market Trends Agent | LangGraph with browser tools |
| DB Performance Analyzer | PostgreSQL integration |
| Device Management Agent | IoT with Cognito auth |
| Enterprise Web Intelligence | Browser tools for research |
| Text to Python IDE | AgentCore Code Interpreter |
| Video Games Sales Assistant | Amplify + CDK deployment |
Quick Start with Use Cases
git clone https://github.com/awslabs/amazon-bedrock-agentcore-samples.git
cd amazon-bedrock-agentcore-samples/02-use-cases/customer-support-assistant
# Follow README for deployment
Resources
Source
git clone https://github.com/Makiya1202/ai-agents-skills/blob/master/skills/aws-agentcore/SKILL.mdView on GitHub Overview
AWS Bedrock AgentCore lets you build production-grade AI agents on AWS infrastructure. It provides runtime execution, tool integration (including Lambda and code tools), memory strategies, identity/auth, and orchestration with subagents, plus gateway and observability for scalable AI workflows.
How This Skill Works
Define Tools (e.g., Lambda-backed or code interpreter tools), assemble agents and subagents, and run them in the AgentCore runtime. Use the Gateway to convert APIs or Lambdas into MCP-compatible tools, and leverage Memory, Identity, Guardrails, and Observability for persistence, authentication, safety, and traceability. Orchestrate complex tasks with SupervisorAgent and SubAgent to delegate work across specialized roles.
When to Use It
- You need scalable AI agents running on AWS infrastructure with Bedrock integration
- You want to expose existing APIs or Lambda functions as MCP-compatible tools
- You require agent orchestration across specialized subagents (e.g., researcher and writer)
- You need memory strategies (semantic, user preferences) to enrich responses
- You want built-in guardrails and observability to monitor and control agent behavior
Quick Start
- Step 1: Initialize AgentCore client with boto3: client = boto3.client('bedrock-agent-runtime')
- Step 2: Define a tool using @Tool decorator, e.g., @Tool(name='search_database', description='Search the product database')
- Step 3: Create and invoke an agent: agent = Agent(model_id='anthropic.claude-3-sonnet', tools=[search_database], instructions='You are a helpful product search assistant.'); response = agent.invoke('Find laptops under $1000')
Best Practices
- Start with small, focused Tools and clearly define their inputs/outputs
- Use Guardrails to enforce safety and avoid unwanted actions
- Select appropriate memory strategies (e.g., semantic + user_preference) for context
- Leverage Gateway to minimize API surface and standardize tool interfaces
- Enable Observability with tracing to diagnose tool calls and agent decisions
Example Use Cases
- Deploy a customer-support agent on AWS Bedrock that uses memory to recall user preferences
- Coordinate research and writing tasks with SubAgents (e.g., researcher and writer) under a SupervisorAgent
- Convert an internal REST API into an MCP-compatible tool via AgentCore Gateway
- Integrate a Lambda-backed tool to fetch real-time data (weather, inventory) within agent flows
- Enforce authentication and authorization using Identity primitives (Cognito/Okta) for agent actions