Home / AI & GenAI

AI & GenAITroubleshootingIntermediate

Amazon Bedrock Agents action group fails: Lambda permissions, response format and stale agent versions

An Amazon Bedrock agent never calls its Lambda, returns DependencyFailedException, or ignores a change you just made. Check the resource policy, the response shape and which version the alias runs.

Deepak Bhardwaj7 min read

Applies toAmazon Bedrock Agents (classic, bedrock-agent and bedrock-agent-runtime APIs), AWS Lambda, AWS CLI v2, boto3

The agent answers "I couldn't complete that", the client gets DependencyFailedException, or the trace says the server could not process the Lambda response. Sometimes the Lambda is never invoked at all. Sometimes it works in the console test window but not from your application.

Nearly every case is one of four things: Bedrock is not allowed to invoke the function, the function returns the wrong JSON shape, the function errors or times out, or your app calls an alias that still points to an old agent version.

Quick triage table

Symptom Likely cause Fix
No Lambda log entries at all for the request Missing or wrong resource-based policy on the function Add a lambda:InvokeFunction permission for bedrock.amazonaws.com scoped to the agent ARN
Lambda runs, agent fails with "error processing the Lambda response" Response JSON doesn't match the action group type Return the OpenAPI or function-details shape exactly, messageVersion 1.0
DependencyFailedException on every call to one tool Function throws, times out, or returns responseState: FAILURE Read the Lambda logs; raise the timeout; return REPROMPT for bad input
Works in console test, not from the app App uses an alias pointing to an older version; console uses the draft Prepare the agent, create a new version and move the alias
New action or parameter ignored Agent not prepared after the change Run prepare-agent and wait for PREPARED
Model picks the wrong tool or invents parameters Vague function descriptions Rewrite descriptions and parameter docs, then prepare again

Check 1: which agent version is the app calling?

Get the facts before you change anything.

AGENT_ID=ABCDEFGHIJ
aws bedrock-agent get-agent --agent-id "$AGENT_ID" \
  --query 'agent.{status:agentStatus,updated:updatedAt,role:agentResourceRoleArn}'

aws bedrock-agent list-agent-aliases --agent-id "$AGENT_ID" \
  --query 'agentAliasSummaries[].{id:agentAliasId,name:agentAliasName,routing:routingConfiguration}'

aws bedrock-agent list-agent-versions --agent-id "$AGENT_ID" \
  --query 'agentVersionSummaries[].{version:agentVersion,status:agentStatus,updated:updatedAt}'

The console test window uses the test alias (TSTALIASID), which runs the working draft (DRAFT). Your application should use a named alias that points to a numbered version. If you edited an action group and only tested in the console, production still runs the old version.

agentStatus must be PREPARED after any change. If it shows NOT_PREPARED, the draft has edits the agent hasn't picked up yet.

aws bedrock-agent prepare-agent --agent-id "$AGENT_ID"
aws bedrock-agent get-agent --agent-id "$AGENT_ID" --query 'agent.agentStatus'

Check 2: is Bedrock allowed to invoke the function?

If CloudWatch Logs has no invocation for the request, look at the function's resource-based policy.

FN=orders-lookup
aws lambda get-policy --function-name "$FN" --query Policy --output text | python -m json.tool

You need a statement with principal bedrock.amazonaws.com, action lambda:InvokeFunction, and a source ARN for the agent. The source ARN names the agent (agent/<agent-id>), not the alias. A policy scoped to the wrong agent ID is common after someone recreates the agent.

aws lambda add-permission \
  --function-name "$FN" \
  --statement-id bedrock-agent-invoke \
  --action lambda:InvokeFunction \
  --principal bedrock.amazonaws.com \
  --source-account 123456789012 \
  --source-arn "arn:aws:bedrock:us-east-1:123456789012:agent/$AGENT_ID"

Then check which function the action group actually points to. A function ARN with a version or alias qualifier needs the permission on that qualifier.

aws bedrock-agent list-agent-action-groups --agent-id "$AGENT_ID" --agent-version DRAFT
aws bedrock-agent get-agent-action-group --agent-id "$AGENT_ID" --agent-version DRAFT \
  --action-group-id <action-group-id> \
  --query 'agentActionGroup.{state:actionGroupState,executor:actionGroupExecutor}'

An action group with actionGroupState set to DISABLED is never offered to the model.

Check 3: does the Lambda return the right shape?

This is the most common cause when the function runs but the agent still fails. The shape depends on how the action group was defined, and Bedrock supports only messageVersion 1.0.

Function-details action groups

The event carries function and a parameters list of name/type/value objects. The response wraps a functionResponse, and the body key must be TEXT:

import json

def handler(event, context):
    params = {p["name"]: p["value"] for p in event.get("parameters", [])}
    order_id = params.get("orderId")

    if not order_id:
        body, state = "orderId is required. Ask the user for the order number.", "REPROMPT"
    else:
        body, state = json.dumps({"orderId": order_id, "status": "shipped"}), None

    function_response = {"responseBody": {"TEXT": {"body": body}}}
    if state:
        function_response["responseState"] = state

    return {
        "messageVersion": "1.0",
        "response": {
            "actionGroup": event["actionGroup"],
            "function": event["function"],
            "functionResponse": function_response,
        },
        "sessionAttributes": event.get("sessionAttributes", {}),
        "promptSessionAttributes": event.get("promptSessionAttributes", {}),
    }

OpenAPI schema action groups

The event carries apiPath, httpMethod and requestBody. Echo apiPath and httpMethod back, include a numeric httpStatusCode, and key responseBody by content type:

return {
    "messageVersion": "1.0",
    "response": {
        "actionGroup": event["actionGroup"],
        "apiPath": event["apiPath"],
        "httpMethod": event["httpMethod"],
        "httpStatusCode": 200,
        "responseBody": {"application/json": {"body": json.dumps(result)}},
    },
}

Typical mistakes: returning the function-details shape for an OpenAPI action group (or the reverse), using text/plain instead of TEXT, returning a dict instead of a string in body, and changing apiPath instead of echoing it.

Tip

Use responseState: REPROMPT for bad or missing input so the model can ask the user again. FAILURE makes the agent throw DependencyFailedException for the session, so keep it for real dependency outages.

The response payload is limited to the Lambda synchronous response size. Trim large results before returning them. Long tool outputs also cost tokens on every later turn.

Check 4: read the trace and the Lambda logs together

The AWS CLI doesn't support streaming Bedrock operations such as InvokeAgent, so call it from boto3 with trace enabled:

import uuid, json, boto3

rt = boto3.client("bedrock-agent-runtime", region_name="us-east-1")
resp = rt.invoke_agent(
    agentId="ABCDEFGHIJ",
    agentAliasId="PRODALIAS1",
    sessionId=str(uuid.uuid4()),
    inputText="What is the status of order 4711?",
    enableTrace=True,
)

for event in resp["completion"]:
    if "trace" in event:
        trace = event["trace"]["trace"]
        if "failureTrace" in trace:
            print("FAILURE:", trace["failureTrace"].get("failureReason"))
        elif "orchestrationTrace" in trace:
            o = trace["orchestrationTrace"]
            for key in ("invocationInput", "observation"):
                if key in o:
                    print(key, json.dumps(o[key], default=str)[:800])
    elif "chunk" in event:
        print("ANSWER:", event["chunk"]["bytes"].decode())

Trace field names vary by SDK version, so print the whole trace object if a key is missing. invocationInput shows which action group and parameters the model chose. observation shows what came back. failureTrace gives the reason the run stopped.

Match it against the function's logs:

aws logs tail "/aws/lambda/$FN" --since 30m --format short
aws lambda get-function-configuration --function-name "$FN" --query '{timeout:Timeout,memory:MemorySize,role:Role}'

A function with the default 3-second timeout that calls a slow backend will time out regularly. Raise the timeout and set a shorter timeout on the backend call so the function can still return a clean REPROMPT or error message.

Fix: ship the change to the alias your app uses

After fixing the function or the action group:

aws bedrock-agent prepare-agent --agent-id "$AGENT_ID"

# Creating an alias without routing config snapshots the draft as a new version
aws bedrock-agent create-agent-alias --agent-id "$AGENT_ID" --agent-alias-name release-2026-11-23

# Or move the existing production alias to a specific version
aws bedrock-agent update-agent-alias --agent-id "$AGENT_ID" \
  --agent-alias-id PRODALIAS1 --agent-alias-name prod \
  --routing-configuration agentVersion=4

Warning

Moving the production alias changes behaviour for every client immediately. Note the current version from list-agent-aliases first so you can move it back in one command.

Prevent it next time

  • Keep a contract test for each Lambda that checks the response shape for each action group type and a REPROMPT path.
  • Deploy the Lambda permission with the agent in the same IaC stack, so a recreated agent gets a matching source ARN.
  • Never point applications at TSTALIASID. Use named aliases with numbered versions and record the version in your release notes.
  • Alarm on Lambda Errors and Duration near the timeout for every action group function.
  • Run a scripted invoke_agent smoke test with enableTrace=True after every alias change and fail the release on any failureTrace.