AWS AgentCore + LangGraph
Multi-agent systems on AWS Bedrock AgentCore with LangGraph orchestration. Source: https://github.com/aws/bedrock-agentcore-starter-toolkit
Install
pip install bedrock-agentcore bedrock-agentcore-starter-toolkit langgraph
uv tool install bedrock-agentcore-starter-toolkit # installs agentcore CLI
Quick Start
from langgraph.graph import StateGraph, START
from langgraph.graph.message import add_messages
from langgraph.prebuilt import ToolNode, tools_condition # routing + tool execution
from bedrock_agentcore.runtime import BedrockAgentCoreApp
from typing import Annotated
from typing_extensions import TypedDict
class State(TypedDict):
messages: Annotated[list, add_messages]
builder = StateGraph(State)
builder.add_node("agent", agent_node)
builder.add_node("tools", ToolNode(tools)) # prebuilt tool executor
builder.add_conditional_edges("agent", tools_condition) # routes to tools or END
builder.add_edge(START, "agent")
graph = builder.compile()
app = BedrockAgentCoreApp() # Wraps as HTTP service on port 8080 (/invocations, /ping)
@app.entrypoint
def invoke(payload, context):
result = graph.invoke({"messages": [("user", payload.get("prompt", ""))]})
return {"result": result["messages"][-1].content}
app.run()
CLI Commands
| Command |
Purpose |
agentcore configure -e agent.py --region us-east-1 |
Setup |
agentcore configure -e agent.py --region us-east-1 --name my_agent --non-interactive |
Scripted setup |
agentcore launch --deployment-type container |
Deploy (container mode) |
agentcore launch --disable-memory |
Deploy without memory subsystem |
agentcore dev |
Hot-reload local dev server |
agentcore invoke '{"prompt": "Hello"}' |
Test |
agentcore destroy |
Cleanup |
Core Patterns
Multi-Agent Orchestration
- Orchestrator delegates to specialists (customer service, e-commerce, healthcare, financial, etc.)
- Specialists: inline functions or separate deployed agents; all share
session_id for context
Memory (STM/LTM)
from bedrock_agentcore.memory import MemoryClient
memory = MemoryClient()
memory.create_event(session_id, actor_id, event_type, payload) # Store
events = memory.list_events(session_id) # Retrieve (returns list)
- STM: Turn-by-turn within session | LTM: Facts/decisions across sessions/agents
- ~10s eventual consistency after writes
Gateway Tools
python -m bedrock_agentcore.gateway.deploy --stack-name my-agents --region us-east-1
from bedrock_agentcore.gateway import GatewayToolClient
gateway = GatewayToolClient()
result = gateway.call("tool_name", param1=value1, param2=value2)
- Transport: Fallback Mock (local), Local MCP servers, Production Gateway (Lambda/REST/MCP)
- Auto-configures
BEDROCK_AGENTCORE_GATEWAY_URL after deploy
Decision Tree
Multiple agents coordinating? → Orchestrator + specialists pattern
Persistent cross-session memory? → AgentCore Memory (not LangGraph checkpoints)
External APIs/Lambda? → AgentCore Gateway
Single agent, simple? → Quick Start above
Complex multi-step logic? → StateGraph + tools_condition + ToolNode
Key Concepts
- AgentCore Runtime: HTTP service on port 8080 (handles
/invocations, /ping)
- AgentCore Memory: Managed cross-session/cross-agent memory
- LangGraph Routing:
tools_condition for agent→tool routing, ToolNode for execution
- AgentCore Gateway: Transforms APIs/Lambda into MCP tools with auth
Naming Rules
- Start with letter, only letters/numbers/underscores, 1-48 chars:
my_agent not my-agent
Troubleshooting
| Issue |
Fix |
on-demand throughput isn't supported |
Use us.anthropic.claude-* inference profiles |
Model use case details not submitted |
Fill Anthropic form in Bedrock Console |
Invalid agent name |
Use underscores not hyphens |
| Memory empty after write |
Wait ~10s (eventual consistency) |
| Container not reading .env |
Set ENV in Dockerfile, not .env |
| Memory not working after deploy |
Check logs for "Memory enabled/disabled" |
list_events returns empty |
Check actor_id/session_id match; event['payload'] is a list |
| Gateway "Unknown tool" |
Lambda must strip ___ prefix from bedrockAgentCoreToolName |
| Platform mismatch warning |
Normal - CodeBuild handles ARM64 cross-platform builds |
References
- agentcore-cli.md - CLI commands, deployment, lifecycle
- agentcore-runtime.md - Streaming, async, observability
- agentcore-memory.md - STM/LTM patterns, API reference
- agentcore-gateway.md - Tool integration, MCP, Lambda
- langgraph-patterns.md - StateGraph design, routing
- reference-architecture-advertising-agents-use-case.pdf - Example multi-agent architecture
1---
2name: aws-agentcore-langgraph
3description: Deploy production LangGraph agents on AWS Bedrock AgentCore. Use for (1) multi-agent systems with orchestrator and specialist agent patterns, (2) building stateful agents with persistent cross-session memory, (3) connecting external tools via AgentCore Gateway (MCP, Lambda, APIs), (4) managing shared context across distributed agents, or (5) deploying complex agent ecosystems via CLI with production observability and scaling.
4metadata:
5 source: https://skillmd.com/skills/modbender/aws-agentcore-langgraph
6---
7
8# AWS AgentCore + LangGraph
9
10Multi-agent systems on AWS Bedrock AgentCore with LangGraph orchestration. Source: https://github.com/aws/bedrock-agentcore-starter-toolkit
11
12## Install
13```bash
14pip install bedrock-agentcore bedrock-agentcore-starter-toolkit langgraph
15uv tool install bedrock-agentcore-starter-toolkit # installs agentcore CLI
16```
17
18## Quick Start
19```python
20from langgraph.graph import StateGraph, START
21from langgraph.graph.message import add_messages
22from langgraph.prebuilt import ToolNode, tools_condition # routing + tool execution
23from bedrock_agentcore.runtime import BedrockAgentCoreApp
24from typing import Annotated
25from typing_extensions import TypedDict
26
27class State(TypedDict):
28 messages: Annotated[list, add_messages]
29
30builder = StateGraph(State)
31builder.add_node("agent", agent_node)
32builder.add_node("tools", ToolNode(tools)) # prebuilt tool executor
33builder.add_conditional_edges("agent", tools_condition) # routes to tools or END
34builder.add_edge(START, "agent")
35graph = builder.compile()
36
37app = BedrockAgentCoreApp() # Wraps as HTTP service on port 8080 (/invocations, /ping)
38@app.entrypoint
39def invoke(payload, context):
40 result = graph.invoke({"messages": [("user", payload.get("prompt", ""))]})
41 return {"result": result["messages"][-1].content}
42app.run()
43```
44
45## CLI Commands
46| Command | Purpose |
47|---------|---------|
48| `agentcore configure -e agent.py --region us-east-1` | Setup |
49| `agentcore configure -e agent.py --region us-east-1 --name my_agent --non-interactive` | Scripted setup |
50| `agentcore launch --deployment-type container` | Deploy (container mode) |
51| `agentcore launch --disable-memory` | Deploy without memory subsystem |
52| `agentcore dev` | Hot-reload local dev server |
53| `agentcore invoke '{"prompt": "Hello"}'` | Test |
54| `agentcore destroy` | Cleanup |
55
56## Core Patterns
57
58### Multi-Agent Orchestration
59- Orchestrator delegates to specialists (customer service, e-commerce, healthcare, financial, etc.)
60- Specialists: inline functions or separate deployed agents; all share `session_id` for context
61
62### Memory (STM/LTM)
63```python
64from bedrock_agentcore.memory import MemoryClient
65memory = MemoryClient()
66memory.create_event(session_id, actor_id, event_type, payload) # Store
67events = memory.list_events(session_id) # Retrieve (returns list)
68```
69- **STM**: Turn-by-turn within session | **LTM**: Facts/decisions across sessions/agents
70- ~10s eventual consistency after writes
71
72### Gateway Tools
73```bash
74python -m bedrock_agentcore.gateway.deploy --stack-name my-agents --region us-east-1
75```
76```python
77from bedrock_agentcore.gateway import GatewayToolClient
78gateway = GatewayToolClient()
79result = gateway.call("tool_name", param1=value1, param2=value2)
80```
81- Transport: Fallback Mock (local), Local MCP servers, Production Gateway (Lambda/REST/MCP)
82- Auto-configures `BEDROCK_AGENTCORE_GATEWAY_URL` after deploy
83
84## Decision Tree
85```
86Multiple agents coordinating? → Orchestrator + specialists pattern
87Persistent cross-session memory? → AgentCore Memory (not LangGraph checkpoints)
88External APIs/Lambda? → AgentCore Gateway
89Single agent, simple? → Quick Start above
90Complex multi-step logic? → StateGraph + tools_condition + ToolNode
91```
92
93## Key Concepts
94- **AgentCore Runtime**: HTTP service on port 8080 (handles `/invocations`, `/ping`)
95- **AgentCore Memory**: Managed cross-session/cross-agent memory
96- **LangGraph Routing**: `tools_condition` for agent→tool routing, `ToolNode` for execution
97- **AgentCore Gateway**: Transforms APIs/Lambda into MCP tools with auth
98
99## Naming Rules
100- Start with letter, only letters/numbers/underscores, 1-48 chars: `my_agent` not `my-agent`
101
102## Troubleshooting
103| Issue | Fix |
104|-------|-----|
105| `on-demand throughput isn't supported` | Use `us.anthropic.claude-*` inference profiles |
106| `Model use case details not submitted` | Fill Anthropic form in Bedrock Console |
107| `Invalid agent name` | Use underscores not hyphens |
108| Memory empty after write | Wait ~10s (eventual consistency) |
109| Container not reading .env | Set ENV in Dockerfile, not .env |
110| Memory not working after deploy | Check logs for "Memory enabled/disabled" |
111| `list_events` returns empty | Check actor_id/session_id match; `event['payload']` is a list |
112| Gateway "Unknown tool" | Lambda must strip `___` prefix from `bedrockAgentCoreToolName` |
113| Platform mismatch warning | Normal - CodeBuild handles ARM64 cross-platform builds |
114
115## References
116- [agentcore-cli.md](references/agentcore-cli.md) - CLI commands, deployment, lifecycle
117- [agentcore-runtime.md](references/agentcore-runtime.md) - Streaming, async, observability
118- [agentcore-memory.md](references/agentcore-memory.md) - STM/LTM patterns, API reference
119- [agentcore-gateway.md](references/agentcore-gateway.md) - Tool integration, MCP, Lambda
120- [langgraph-patterns.md](references/langgraph-patterns.md) - StateGraph design, routing
121- [reference-architecture-advertising-agents-use-case.pdf](references/reference-architecture-advertising-agents-use-case.pdf) - Example multi-agent architecture