Skip to content

I have already created a agent using Langraph, how to move it to AgentCore

1

I'm already created a agent using Langraph, how to move it to AgentCore

EXPERT

asked 10 months ago1.1K views

4 Answers
0

To move your existing LangGraph agent to Amazon Bedrock AgentCore, you'll need to make a few simple modifications to your code:

  1. Import the AgentCore runtime:
from bedrock_agentcore.runtime import BedrockAgentCoreApp
app = BedrockAgentCoreApp()
  1. Decorate your main agent function with the entrypoint decorator:
@app.entrypoint
async def langgraph_bedrock(payload):
# Extract the user input from the payload
user_input = payload.get("prompt")

# Call your existing agent as before
stream = agent.astream(
{"messages": [HumanMessage(content=user_input)]},
stream_mode="values"
)

# Stream responses back
async for chunk in stream:
yield(chunk)
  1. Add the runtime starter at the bottom of your file:
if __name__ == "__main__":
app.run()
  1. Deploy your agent to AgentCore Runtime using the AgentCore CLI. If you're using an MCP client like Kiro, Cursor, Claude Code, or Amazon Q CLI, you can simply ask it to "Deploy this AgentCore agent to AgentCore runtime using the AgentCore CLI" and it will execute the necessary commands.

  2. To update your agent in the future, you can use the boto3 client:

import boto3

client = boto3.client('bedrock-agentcore-control', region_name='<AWS-REGION>')

response = client.update_agent_runtime(
agentRuntimeId='<AGENTRUNTIME-ID>',
agentRuntimeArtifact={
'containerConfiguration': {
'containerUri': '<AWS-ACCOUNT-ID>.dkr.ecr.<AWS-REGION>.amazonaws.com/<AGENT-NAME>:latest'
}
},
networkConfiguration={"networkMode": "PUBLIC"},
roleArn='arn:aws:iam::<ACCOUNT-ID>:role/<AGENT-ROLE>'
)

The beauty of this approach is that most of your existing LangGraph agent code remains unchanged. AgentCore handles the infrastructure while your agent handles the intelligence.
Sources
Running deep research AI agents on Amazon Bedrock AgentCore | Artificial Intelligence
Amazon Bedrock AgentCore MCP Server: Vibe coding with your coding assistant - Amazon Bedrock AgentCore
Updating an Agent to a new version when executing on Bedrock Agentcore Runtime | AWS re:Post
Accelerate development with the Amazon Bedrock AgentCore MCP server | Artificial Intelligence

answered 10 months ago

0

Hey,

Hope you're keeping well.

LangGraph agents can be integrated with Amazon Bedrock AgentCore, but it isn’t a direct “move” — you’ll need to wrap your existing agent logic in the AgentCore runtime interface and deploy it through the AgentCore CLI or API. Start by importing BedrockAgentCoreApp in your code, define an @entrypoint function that handles input and output for your LangGraph agent, then call app.run() to start the runtime. Once updated, build and push your container image to Amazon ECR, and register it with AgentCore using boto3 or the CLI. Make sure your IAM role has bedrock-agentcore-control permissions and that your region supports AgentCore before deploying.

Thanks and regards,
Taz

answered 10 months ago

0

Hello anupsivadas, here my guide to deploy langraph to BedrockAgentCore

  1. Use the starter toolkit as your base — The toolkit already has the BedrockAgentCoreApp set up for you. It's got the basic structure, the entrypoint pattern, everything you need. Just use that as your foundation instead of building from scratch.

  2. Plug your LangGraph graph into the runtime — The toolkit shows you how to set up an @app.entrypoint function. Your LangGraph agent just goes in there. When Bedrock Agent Runtime calls your entrypoint, your graph processes the request and returns the response. Simple as that.

  3. Leverage the Bedrock Agent Runtime's features — This is where it gets good. The runtime gives you:

  • Memory management (STM & LTM) that persists across conversations
  • Tool integration via MCP and Lambda
  • Session management out of the box
  • Observability with CloudWatch
  • Security with IAM roles and API Gateway
  • Your LangGraph agent gets all of this automatically just by running on top of it.
  1. Follow the starter toolkit's structure — It's got your src/, mcp/, and cdk/ directories already laid out. Keep that structure. Your agent code goes in main.py, any custom tools you build go in mcp/, and the deployment config is in cdk/. Don't overthink it.

  2. Deploy with the toolkit's CDK — The toolkit already has all the AWS infrastructure modeled for you. Just update the config in .bedrock_agentcore.yaml, build your Docker image, push it to ECR, and let CDK deploy the whole thing. Bedrock Agent Runtime takes care of the rest.

The key thing: you're not migrating your agent, you're just hosting it on Bedrock Agent Runtime instead of running it locally or on some other platform. The LangGraph logic stays exactly the same. The starter toolkit is designed to make this transition as smooth as possible.

answered 10 months ago

0

Hey,

Hope you're keeping well.

To move a LangGraph agent into Amazon Bedrock AgentCore, start with the Bedrock AgentCore starter toolkit from AWS Samples, as it already has the runtime integration and CDK deployment setup. Replace the default main.py entrypoint logic with your LangGraph workflow, ensuring it processes the event payload from the Bedrock Agent Runtime and returns a valid response. Keep the existing directory structure so tools can be added under mcp/ and infrastructure remains in cdk/. Update the .bedrock_agentcore.yaml config, build your container image, push it to ECR, and run cdk deploy to launch it in your AWS account.

Thanks and regards,
Taz

answered 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.