Skip to main content
Versions

Examples built with AgentCore CLI @aws/agentcore@0.26.0. Commands or flags may differ in other versions. Run agentcore --version to check yours.

Troubleshooting

Common issues and solutions when building agents on AgentCore.


Local Development (agentcore dev)​

SymptomRoot CauseSolution
error starting dev server: terminalIDE terminal can't allocate TTYUse agentcore dev --logs or run in a native terminal window
.venv not found / module import errorsPython deps not installedRun cd app/<Name> && uv venv && uv sync
Port 8080 already in useAnother process on the portKill it, or use agentcore dev --port 8081
Payload shows "unknown" or garbled JSONCLI wraps input in {"prompt":"..."}Add payload unwrapping logic (see below)
ModuleNotFoundError: bedrock_agentcorePackage not in venvRun uv add bedrock-agentcore then uv sync
Hot reload not workingFile outside watched directoryEnsure changes are inside app/<Name>/

Payload Unwrapping​

When you send a prompt with agentcore dev "<json>", the CLI wraps your JSON inside {"prompt": "<your json as string>"}. If your agent expects structured event payloads, unwrap it:

import json

def unwrap_payload(payload: dict) -> dict:
"""Unwrap nested JSON from agentcore dev's prompt wrapper."""
if "prompt" in payload:
prompt_value = payload["prompt"]
if isinstance(prompt_value, str):
try:
parsed = json.loads(prompt_value)
if isinstance(parsed, dict):
return parsed
except (json.JSONDecodeError, TypeError):
pass
return payload

Memory​

SymptomRoot CauseSolution
ResourceNotFoundException: Memory not foundMemory not deployed yetDeploy first (agentcore deploy), then test locally
Agent doesn't remember across sessionsMemory mode is shortTerm onlyUse longAndShortTerm with SEMANTIC strategy
Memory stuck in CREATING statusIAM permissions or KMS issueCheck execution role permissions; use agentcore status
Different users seeing each other's memoriesactor_id hardcodedUse unique actor_id per user (from context or JWT)
Extraction jobs failingStrategy misconfiguredCheck CloudWatch logs for the memory resource

Graceful Degradation Pattern​

Memory is unavailable during local dev. Always wrap memory initialization in try/except:

session_manager = None
try:
session_manager = get_memory_session_manager(session_id, actor_id)
except Exception as exc:
log.warning("Memory unavailable: %s", exc)

# Agent works fine with session_manager=None
agent = Agent(model=model, session_manager=session_manager, tools=tools)

Gateway​

SymptomRoot CauseSolution
Gateway stuck in CREATINGIAM trust policy missingService role must trust bedrock-agentcore.amazonaws.com
Target stuck in SYNCHRONIZINGMCP server version incompatibleConfirm the target's MCP server supports a protocol version Gateway currently accepts; upgrade the Gateway's supportedVersions via UpdateGateway if needed
AccessDeniedException on tool callMissing Lambda invoke permissionAdd lambda:InvokeFunction to gateway service role
Agent can't find the toolTarget not READY, or schema invalidCheck agentcore status; verify JSON schema is valid
Tool returns unexpected formatLambda using HTTP envelopeReturn direct objects, not {statusCode, body} wrappers
$ref or $defs in tool schemaSchemas must be self-containedInline all references; no JSON Schema $ref allowed

Deployment​

SymptomRoot CauseSolution
runtimeVersion PYTHON_3_14 warningsCLI scaffolded pre-release PythonChange to PYTHON_3_13 in agentcore.json
Deploy fails with IAM errorExecution role not configuredCheck agentcore.json or let CLI create role automatically
Deploy takes very long (>10 min)Memory or Gateway provisioningMemory STM: ~60s, LTM: ~180s. Gateway: ~60s. Normal.
CREATE_FAILED on runtimeCode error or missing entrypointCheck failureReason via agentcore status
exec format error in container deployDocker image not ARM64Build with --platform linux/arm64

Cedar Policies​

SymptomRoot CauseSolution
Policy deploy failsBare resource without typeUse resource is AgentCore::Gateway (any action) or resource == AgentCore::Gateway::"<arn>" (specific actions)
Policy has no effectMode is LOG_ONLYSwitch to ENFORCE after validating in logs
ValidationException on createSchema mismatch with Gateway toolsDeploy Gateway first so tool schemas are available for validation
Numeric comparison failsUsing operators on Decimal typeUse "type": "integer" in tool schema for direct < > ops
Specific action + type constraint failsUsing resource is with action ==When specifying specific actions, you must use the full Gateway ARN: resource == AgentCore::Gateway::"<arn>"

Cedar Syntax Quick Reference​

// Allow ALL tools on a gateway (type constraint OK here — no specific action)
permit(
principal,
action,
resource is AgentCore::Gateway
);

// Allow a specific tool (MUST use Gateway ARN)
permit(
principal,
action == AgentCore::Action::"TargetName___tool_name",
resource == AgentCore::Gateway::"arn:aws:bedrock-agentcore:us-west-2:123456789012:gateway/my-gateway"
);

// Allow a specific tool only when condition is met (MUST use Gateway ARN)
permit(
principal,
action == AgentCore::Action::"TargetName___tool_name",
resource == AgentCore::Gateway::"arn:aws:bedrock-agentcore:us-west-2:123456789012:gateway/my-gateway"
)
when {
context.input.priority == "HIGH"
};

Authentication / Identity​

SymptomRoot CauseSolution
AccessDeniedException invoking agentMissing IAM permissionsCaller needs bedrock-agentcore:InvokeAgentRuntime
JWT validation failsDiscovery URL or client mismatchVerify --discovery-url and --allowed-clients match IdP
Credential provider not foundName mismatch or wrong regionNames are case-sensitive and region-scoped
OAuth callback failsCallback URL not registeredRegister the callbackUrl from provider creation response

General​

SymptomRoot CauseSolution
Unknown service in boto3boto3 too oldpip install --upgrade boto3 botocore
CLI command not recognizedOutdated CLI versionnpm install -g @aws/agentcore@0.26.0 — before upgrading, check the CLI releases page for compatibility notes
Session terminated earlyIdle timeout too shortIncrease via agentcore.json or agentcore add agent
504 Gateway Timeout on invokeAgent took too longCheck agent logs; optimize tool calls or model


Region and Service Availability​

SymptomRoot CauseSolution
UnknownServiceException or Could not connect to the endpoint URLAgentCore not available in the selected regionCheck which regions support AgentCore in the Amazon Bedrock AgentCore Developer Guide. Switch your target region in agentcore/aws-targets.json.
Deploy succeeds but runtime endpoint returns 503Service capacity or rollout lag in a new regionWait a few minutes and retry. If the issue persists, open a support case.

IAM Access Errors​

AgentCore uses two distinct IAM roles. Errors often come from confusing which role is missing a permission.

RoleWhen it is usedCommon missing permissions
Deployment role (your caller identity)Running agentcore deploy, agentcore add, agentcore destroybedrock-agentcore:CreateAgentRuntime, iam:PassRole, ecr:*, cloudformation:*
Execution role (attached to the runtime)Agent code running inside AgentCorebedrock:InvokeModel, bedrock-agentcore:GetMemory, Lambda invoke, secrets access

If you see AccessDeniedException during deploy, the deployment role is missing permissions. If you see it inside agent code at runtime, the execution role is missing permissions. Check CloudWatch logs to distinguish the two.


Model Access Errors​

SymptomRoot CauseSolution
AccessDeniedException: You don't have access to the modelBedrock model not enabled in your accountOpen the Bedrock console and request access under Model access for the specific model and region.
ValidationException: The provided model identifier is invalidModel ID mismatch or model not available in the regionVerify the exact model ID in the Bedrock console for your target region.

Deployment Rollback​

If a deploy fails partway through or introduces a regression, you can return to the previous working state:

  1. Run agentcore status to identify which resources are in a failed or updating state.
  2. For CloudFormation-backed resources, open the AWS CloudFormation console and choose Roll back on the failed stack, or run agentcore destroy to tear down and re-deploy from a known-good agentcore.json.
  3. To redeploy the previous configuration, restore agentcore.json from version control and run agentcore deploy again.
  4. If a runtime is stuck in UPDATE_FAILED, delete it manually in the AgentCore console or via CLI, then redeploy.

Cleanup Failures​

Running agentcore destroy removes the CDK stack, but some resources may persist if deletion fails or if they were created outside the managed stack.

ResourceWhy it may persistHow to verify removal
ECR repositoriesNon-empty repositories are not deleted by defaultCheck the ECR console; delete images then delete the repository manually
Secrets Manager secretsSecrets have a minimum 7-day recovery windowLook for secrets named after your project in the Secrets Manager console; use Force delete if needed
CloudWatch log groupsLog groups are retained by defaultSearch for /aws/agentcore/ prefixed groups in the CloudWatch console and delete manually
IAM rolesRoles with attached policies may block deletionCheck IAM for roles prefixed with your project name; detach policies and delete

After running agentcore destroy, verify cleanup with:

agentcore status

A clean teardown shows no resources in the output.


Safe Log Inspection​

Before sharing logs or pasting them into support channels:

  • Redact AWS account IDs, ARNs, and region identifiers if your account details are sensitive.
  • Remove any bearer tokens, API keys, or client secrets that may appear in request headers logged at DEBUG level.
  • Avoid pasting full agentcore.json contents if they reference internal endpoint URLs or secret names that reveal infrastructure details.

To inspect logs without exposing sensitive data in your terminal history, pipe output to a file first:

agentcore logs --runtime MyAgent > /tmp/agent-logs.txt
# Then redact before sharing

Getting Help​