Architecture
AgentCore has 6 modular components:
- Runtime - Serverless hosting (direct_code_deploy or container)
- Gateway - Tool access via MCP (Lambda, OpenAPI, Smithy targets)
- Memory - STM (session) and LTM (persistent) storage
- Identity - Auth via IAM, Cognito, AWS JWT, external OAuth
- Observability - CloudWatch + OpenTelemetry tracing
- Policy - Cedar-based governance and authorization
Entry Point Pattern
All agents use BedrockAgentCoreApp with @app.entrypoint decorator:
from bedrock_agentcore import BedrockAgentCoreApp
app = BedrockAgentCoreApp()
@app.entrypoint
def invoke(payload: dict) -> dict:
prompt = payload.get("prompt", "")
result = your_agent_logic(prompt)
return {"result": result}
if __name__ == "__main__":
app.run()
Key CLI Commands
All commands: uv run agentcore [command]
Runtime: configure, deploy, invoke, status, destroy, stop-session
Gateway: gateway create-mcp-gateway, gateway create-mcp-gateway-target
Memory: memory create, memory list, memory status
Identity: identity setup-cognito, identity setup-aws-jwt
Policy: policy create-policy-engine, policy create-policy
See references/cli-reference.md for full command list.
Rules
- Agent names: underscores only (
my_agent not my-agent)
- Never hardcode API keys - use Secrets Manager
- Windows: prefix with
PYTHONIOENCODING=utf-8
- Memory mode order:
STM_AND_LTM (not LTM_AND_STM)
- Deploy a new agent
- Update existing deployment
- Add Google OAuth
- Create chat UI
- Set up Gateway (MCP tools)
- Configure Memory
- Set up Identity/Auth
- View logs/observability
- Troubleshoot errors
- Something else
Wait for response before proceeding.
After reading the workflow, follow it exactly.
- architecture.md - All AgentCore components explained
- cli-reference.md - Complete CLI command reference
- prerequisites.md - AWS setup, Python, uv requirements
- memory-modes.md - Memory configuration details
- common-errors.md - Error messages and fixes
- iam-policies.md - IAM role configuration
1---2name: deploy-agentcore3description: Deploy Python agents to AWS Bedrock AgentCore. Use when deploying agents to AWS, setting up serverless agent hosting, configuring AgentCore components (Runtime, Gateway, Memory, Identity, Policy), or troubleshooting deployment errors.4---5
6<essential_principles>
7AWS Bedrock AgentCore is a serverless platform for AI agents at scale.
8
9## Architecture
10
11AgentCore has 6 modular components:
12- **Runtime** - Serverless hosting (direct_code_deploy or container)
13- **Gateway** - Tool access via MCP (Lambda, OpenAPI, Smithy targets)
14- **Memory** - STM (session) and LTM (persistent) storage
15- **Identity** - Auth via IAM, Cognito, AWS JWT, external OAuth
16- **Observability** - CloudWatch + OpenTelemetry tracing
17- **Policy** - Cedar-based governance and authorization
18
19## Entry Point Pattern
20
21All agents use `BedrockAgentCoreApp` with `@app.entrypoint` decorator:
22
23```python
24from bedrock_agentcore import BedrockAgentCoreApp
25
26app = BedrockAgentCoreApp()
27
28@app.entrypoint
29def invoke(payload: dict) -> dict:
30 prompt = payload.get("prompt", "")
31 result = your_agent_logic(prompt)
32 return {"result": result}
33
34if __name__ == "__main__":
35 app.run()
36```
37
38## Key CLI Commands
39
40All commands: `uv run agentcore [command]`
41
42Runtime: configure, deploy, invoke, status, destroy, stop-session
43Gateway: gateway create-mcp-gateway, gateway create-mcp-gateway-target
44Memory: memory create, memory list, memory status
45Identity: identity setup-cognito, identity setup-aws-jwt
46Policy: policy create-policy-engine, policy create-policy
47
48See references/cli-reference.md for full command list.
49
50## Rules
51
52- Agent names: underscores only (`my_agent` not `my-agent`)
53- Never hardcode API keys - use Secrets Manager
54- Windows: prefix with `PYTHONIOENCODING=utf-8`
55- Memory mode order: `STM_AND_LTM` (not LTM_AND_STM)
56</essential_principles>
57
58<intake>
59What would you like to do?
60
611. Deploy a new agent
622. Update existing deployment
633. Add Google OAuth
644. Create chat UI
655. Set up Gateway (MCP tools)
666. Configure Memory
677. Set up Identity/Auth
688. View logs/observability
699. Troubleshoot errors
7010. Something else
71
72Wait for response before proceeding.
73</intake>
74
75<routing>
76| Response | Workflow |
77|----------|----------|
78| 1, "deploy", "new" | workflows/deploy-agent.md |
79| 2, "update", "redeploy" | workflows/update-deployment.md |
80| 3, "oauth", "google" | workflows/add-oauth.md |
81| 4, "ui", "chat", "streamlit" | workflows/create-chat-ui.md |
82| 5, "gateway", "mcp", "tools" | workflows/setup-gateway.md |
83| 6, "memory", "stm", "ltm" | workflows/setup-memory.md |
84| 7, "identity", "auth", "cognito", "jwt" | workflows/setup-identity.md |
85| 8, "logs", "observability", "cloudwatch" | workflows/view-logs.md |
86| 9, "error", "troubleshoot", "fix" | workflows/troubleshoot.md |
87| 10, other | Clarify, then select |
88
89After reading the workflow, follow it exactly.
90</routing>
91
92<reference_index>
93All domain knowledge in `references/`:
94
95- architecture.md - All AgentCore components explained
96- cli-reference.md - Complete CLI command reference
97- prerequisites.md - AWS setup, Python, uv requirements
98- memory-modes.md - Memory configuration details
99- common-errors.md - Error messages and fixes
100- iam-policies.md - IAM role configuration
101</reference_index>
102
103<workflows_index>
104| Workflow | Purpose |
105|----------|---------|
106| deploy-agent.md | Deploy Python agent to AgentCore |
107| update-deployment.md | Redeploy with code changes |
108| add-oauth.md | Add Google OAuth for cloud environment |
109| create-chat-ui.md | Create Streamlit chat interface |
110| setup-gateway.md | Create MCP gateway with targets |
111| setup-memory.md | Configure memory modes |
112| setup-identity.md | Set up auth (Cognito, JWT, OAuth) |
113| view-logs.md | Access CloudWatch logs and metrics |
114| troubleshoot.md | Fix common deployment errors |
115</workflows_index>
116
117<templates_index>
118| Template | Purpose |
119|----------|---------|
120| entry_claude_sdk.py | Entry point for Claude SDK agents |
121| entry_langchain.py | Entry point for LangChain agents |
122| entry_custom.py | Entry point for custom Python agents |
123| entry_minimal.py | Bare minimum entry point |
124| policy_minimal.json | IAM policy for Secrets Manager only |
125| policy_oauth.json | IAM policy for OAuth (Secrets + S3) |
126| policy_full.json | IAM policy with all common permissions |
127| chat_ui.py | Streamlit chat interface |
128</templates_index>
129
130<success_criteria>
131Deployment successful when:
132- `uv run agentcore deploy` completes without errors
133- `uv run agentcore invoke` returns expected response
134- Agent handles sessions correctly
135- External API keys work via Secrets Manager
136</success_criteria>