← 返回
数据分析

aws-agentcore-langgraph

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.
在 AWS Bedrock AgentCore 上部署生产级 LangGraph 代理,适用于多代理系统(编排器+专家代理)、有状态跨会话记忆、外部工具连接(AgentCore Gateway)、分布式共享上下文管理以及通过 CLI 实现具备可观测性和弹性伸缩的复杂代理生态部署。
killerapp
数据分析 clawhub v1.0.2 1 版本 99758.7 Key: 无需
★ 4
Stars
📥 1,987
下载
💾 38
安装
1
版本
#latest

概述

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

CommandPurpose
------------------
agentcore configure -e agent.py --region us-east-1Setup
agentcore configure -e agent.py --region us-east-1 --name my_agent --non-interactiveScripted setup
agentcore launch --deployment-type containerDeploy (container mode)
agentcore launch --disable-memoryDeploy without memory subsystem
agentcore devHot-reload local dev server
agentcore invoke '{"prompt": "Hello"}'Test
agentcore destroyCleanup

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

IssueFix
------------
on-demand throughput isn't supportedUse us.anthropic.claude-* inference profiles
Model use case details not submittedFill Anthropic form in Bedrock Console
Invalid agent nameUse underscores not hyphens
Memory empty after writeWait ~10s (eventual consistency)
Container not reading .envSet ENV in Dockerfile, not .env
Memory not working after deployCheck logs for "Memory enabled/disabled"
list_events returns emptyCheck actor_id/session_id match; event['payload'] is a list
Gateway "Unknown tool"Lambda must strip ___ prefix from bedrockAgentCoreToolName
Platform mismatch warningNormal - CodeBuild handles ARM64 cross-platform builds

References

版本历史

共 1 个版本

  • v1.0.2 当前
    2026-03-28 18:38 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

data-analysis

A股量化 AkShare

mbpz
A股量化数据分析工具,基于AkShare库获取A股行情、财务数据、板块信息等。用于回答关于A股股票查询、行情数据、财务分析、选股等问题。
★ 164 📥 59,799
data-analysis

Data Analysis

ivangdavila
{"answer":"数据分析与可视化。查询数据库、生成报告、自动化电子表格,将原始数据转化为清晰可行的见解。适用于:(1) 您……"}
★ 198 📥 64,965
content-creation

copywriter

killerapp
撰写引人入胜的用户体验文案、营销内容和产品信息。适用于编写按钮标签、错误提示、落地页、邮件、行动号召、空状态、工具提示或任何面向用户的文本。
★ 14 📥 14,147