aws-agentcore-langgraph — aws-代理core-langgraph
v1.0.2部署 production LangGraph 代理s on AWS Bedrock 代理Core. Use for (1) multi-代理 系统s with 编排器 and specia列出 代理 patterns, (2) building 状态ful 代理s with persistent cross-会话 memory, (3) connecting external 工具s via 代理Core Gateway (MCP, Lambda, APIs), (4) managing 分享d 上下文 across distributed 代理s, or (5) 部署ing complex 代理 eco系统s via 命令行工具 with production observability and scaling.
运行时依赖
安装命令
点击复制技能文档
AWS 代理Core + LangGraph
Multi-代理 系统s on AWS Bedrock 代理Core with LangGraph orchestration. Source: https://github.com/aws/bedrock-代理core-启动er-工具kit
安装 pip 安装 bedrock-代理core bedrock-代理core-启动er-工具kit langgraph uv 工具 安装 bedrock-代理core-启动er-工具kit # 安装s 代理core 命令行工具
Quick 启动 from langgraph.graph 导入 状态Graph, 启动 from langgraph.graph.message 导入 添加_messages from langgraph.prebuilt 导入 工具Node, 工具s_condition # routing + 工具 execution from bedrock_代理core.运行time 导入 Bedrock代理Core应用 from typing 导入 Annotated from typing_扩展s 导入 TypedDict
class 状态(TypedDict): messages: Annotated[列出, 添加_messages]
构建器 = 状态Graph(状态) 构建器.添加_node("代理", 代理_node) 构建器.添加_node("工具s", 工具Node(工具s)) # prebuilt 工具 executor 构建器.添加_conditional_edges("代理", 工具s_condition) # 路由s to 工具s or END 构建器.添加_edge(启动, "代理") graph = 构建器.compile()
应用 = Bedrock代理Core应用() # Wraps as HTTP 服务 on port 8080 (/invocations, /ping) @应用.entrypoint def invoke(payload, 上下文): 结果 = graph.invoke({"messages": [("user", payload.获取("prompt", ""))]}) return {"结果": 结果["messages"][-1].content} 应用.运行()
命令行工具 Commands Command Purpose 代理core 配置 -e 代理.py --region us-east-1 设置up 代理core 配置 -e 代理.py --region us-east-1 --name my_代理 --non-interactive Scripted 设置up 代理core launch --部署ment-type contAIner 部署 (contAIner mode) 代理core launch --disable-memory 部署 without memory sub系统 代理core dev Hot-reload local dev server 代理core invoke '{"prompt": "Hello"}' Test 代理core destroy 清理up Core Patterns Multi-代理 Orchestration 编排器 delegates to specia列出s (customer 服务, e-commerce, 健康care, financial, etc.) Specia列出s: inline functions or separate 部署ed 代理s; all 分享 会话_id for 上下文 Memory (STM/LTM) from bedrock_代理core.memory 导入 Memory命令行工具ent memory = Memory命令行工具ent() memory.创建_event(会话_id, actor_id, event_type, payload) # Store 事件 = memory.列出_事件(会话_id) # Retrieve (returns 列出)
STM: Turn-by-turn within 会话 | LTM: Facts/decisions across 会话s/代理s ~10s eventual consistency after writes Gateway 工具s python -m bedrock_代理core.gateway.部署 --stack-name my-代理s --region us-east-1
from bedrock_代理core.gateway 导入 Gateway工具命令行工具ent gateway = Gateway工具命令行工具ent() 结果 = gateway.call("工具_name", param1=value1, param2=value2)
Transport: Fallback Mock (local), Local MCP servers, Production Gateway (Lambda/REST/MCP) Auto-配置s BEDROCK_代理CORE_GATEWAY_URL after 部署 Decision Tree Multiple 代理s coordinating? → 编排器 + specia列出s pattern Persistent cross-会话 memory? → 代理Core Memory (not LangGraph 检查points) External APIs/Lambda? → 代理Core Gateway Single 代理, simple? → Quick 启动 above Complex multi-step 记录ic? → 状态Graph + 工具s_condition + 工具Node
Key Concepts 代理Core 运行time: HTTP 服务 on port 8080 (handles /invocations, /ping) 代理Core Memory: Managed cross-会话/cross-代理 memory LangGraph Routing: 工具s_condition for 代理→工具 routing, 工具Node for execution 代理Core Gateway: 转换s APIs/Lambda into MCP 工具s with auth Naming Rules 启动 with letter, only letters/numbers/underscores, 1-48 chars: my_代理 not my-代理 Troubleshooting Issue Fix on-demand throughput isn't supported Use us.anthropic.claude-* inference 性能分析s 模型 use case detAIls not submitted Fill Anthropic form in Bedrock Console Invalid 代理 name Use underscores not hyphens Memory empty after write WAIt ~10s (eventual consistency) ContAIner not reading .env 设置 ENV in Dockerfile, not .env Memory not working after 部署 检查 记录s for "Memory enabled/disabled" 列出_事件 returns empty 检查 actor_id/会话_id match; event['payload'] is a 列出 Gateway "Unknown 工具" Lambda must strip ___ prefix from bedrock代理Core工具Name 平台 mismatch 警告 Normal - CodeBuild handles ARM64 cross-平台 builds References 代理core-命令行工具.md - 命令行工具 commands, 部署ment, lifecycle 代理core-运行time.md - 流ing, a同步, observability 代理core-memory.md - STM/LTM patterns, API reference 代理core-gateway.md - 工具 integration, MCP, Lambda langgraph-patterns.md - 状态Graph de签名, routing reference-architecture-advertising-代理s-use-case.pdf - Example multi-代理 architecture