Migrate agentic workloads to Amazon Bedrock AgentCore
This article details a two‑stage migration of an existing LangGraph customer‑support agent to Amazon Bedrock AgentCore, first moving the runtime, gateway, and memory components while keeping the graph unchanged, then optionally refactoring the loop into model‑driven planning with Strands Agents. The migration touches four core constructs—AgentCore Runtime (BedrockAgentCoreApp), an AWS Lambda gateway published via Model Context Protocol (MCP), tool binding via `ToolNode` and `llm.bind_tools`, and durable state managed by `AgentCoreMemorySessionManager`. Engineers gain a hosted, managed agent environment with built‑in tool orchestration and persistent session state, reducing operational burdens such as session isolation, state persistence, authentication, and OS patching.
⚡ Key Takeaways
- Migration stages: Stage 1 moves the agent to Bedrock AgentCore Runtime, Gateway, and Memory without altering the graph; Stage 2 rebuilds the loop using model‑driven planning on Strands Agents.
- Runtime component: `BedrockAgentCoreApp` with an `@app.entrypoint` function runs on a microVM per session.
- Tool integration: Tools are listed via `MCPClient.list_tools_sync()` and bound using `ToolNode(tools)` and `llm.bind_tools(tools)`.
- State management: Persistent session state is handled by `AgentCoreMemorySessionManager(AgentCoreMemoryConfig(...))` with `MemorySaver()` keyed on `actor_id`.
- Optional upgrade: Stage 3 hands the loop to an AgentCore harness, a capability documented separately.
By offloading session isolation, state durability, authentication, and OS maintenance to Bedrock AgentCore, engineers can focus on core reasoning logic and scale agents more reliably in production.
✅ Practical Steps
- Replace your LangGraph agent constructor with `Agent(model=..., system_prompt=..., tools=...)` and configure the runtime using `BedrockAgentCoreApp` and an `@app.entrypoint` function.
- Bind your tool set by retrieving them with `MCPClient.list_tools_sync()` and applying `ToolNode(tools)` and `llm.bind_tools(tools)`.
- Enable durable session state by instantiating `AgentCoreMemorySessionManager(AgentCoreMemoryConfig(...))` and using `MemorySaver()` with the appropriate `actor_id` in the invoke config.
Want the full story? Read the original article.
Read on AWS ML Blog ↗