Subchapter 14.6
references/migrate.mdMarkdown6 KBView on GitHub
Move an existing Amazon Bedrock Agent to AgentCore Runtime.
Scripts
Process Payment Tool$ARGUMENTS is optional:
/migrate # interactive — walks through the migration
/migrate strands # migrate targeting Strands framework
/migrate langgraph # migrate targeting LangGraph frameworkThe agentcore create --type import command reads your existing Bedrock Agent’s configuration and generates an AgentCore project that reproduces its behavior in a code-first framework. Specifically:
main.py--type lambda-function-arnWhat migration does not do:
bedrock:GetAgent, bedrock:GetAgentAlias, and bedrock:ListAgentActionGroups permissionsagentcore create \
--type import \
--agent-id <AGENT_ID> \
--agent-alias-id <ALIAS_ID> \
--region <REGION> \
--name <ProjectName> \
--framework StrandsThe --framework flag determines which code-first framework the generated project uses. Strands is recommended for the closest mapping to Bedrock Agent behavior.
Project name rules apply: max 23 characters, alphanumeric only, starts with a letter.
cd <ProjectName>
cat app/<AgentName>/main.py
cat agentcore/agentcore.jsonCheck:
agentcore.json (under agentCoreGateways)Knowledge Bases: If your Bedrock Agent used Knowledge Bases, you have two options:
bedrock-agent-runtime:RetrieveAndGenerate or Retrieve directly from your agent code as a toolGuardrails → Cedar policies: Bedrock Guardrails (content filters, denied topics, word filters) don’t have a 1:1 mapping to Cedar policies. Cedar policies control which tools the agent can call and with what parameters — they’re authorization rules, not content filters. If you need content filtering, keep the guardrail logic in your agent code (pre/post-processing) or use Bedrock Guardrails as a standalone API call.
Custom orchestration: If your Bedrock Agent used custom orchestration (return-of-control, custom Lambda orchestrators), you’ll need to rebuild that logic in the framework’s native patterns — Strands tool chains, LangGraph graph nodes, etc.
# Test locally (memory and gateway won't be available yet)
agentcore dev
# Deploy when ready
agentcore deploy -y
# Verify
agentcore invoke "Hello, what can you do?"
agentcore statusOnce the AgentCore agent is working correctly:
“Model not available in target region”
The imported agent may reference a model ID that isn’t available in your AgentCore deployment region. Edit model/load.py to use a cross-region inference profile or a model available in your region.
“Action group Lambda in a different region” Gateway targets can invoke Lambda functions cross-region, but latency increases. Consider deploying the Lambda in the same region as your AgentCore agent, or accept the latency trade-off.
“Agent behavior differs after migration” The most common cause is prompt format differences between Bedrock Agent’s orchestration and the code-first framework. Bedrock Agent injects structured XML around tool results; Strands/LangGraph use different formats. Tune the system prompt to compensate.