Skip to content

Bedrock Agent Error : "The server encountered an error processing the Lambda response."

0

Hello,

In Management Console, I built a Bedrock Agent with an Action Group that contains a Lambda that returns JSON data.
When I tested the Agent with Management Console, I have the below error:

The server encountered an error processing the Lambda response. Check the Lambda response and retry the request

I do not see the Lambda response anywhere in the Agent system (in Trace window, the Orchestration and Knowledge Base tab, displays lots of information, but no Lambda response), while the Lambda flow looks good. Could you please specify how to see the Lambda response in the Agent system, or why don't I see it ?
In Lambda CloudWatch I have the JSON response below, that considers also this issue and this doc:

{
    "messageVersion": "1.0",
    "response": {
        "actionGroup": "default",
        "function": "weather_data_crawler_action-tfeuw",
        "functionResponse": {
            "responseBody": {
                "TEXT": {
                    "body": "[{\"dt\":\"2025.07.10 18:00:00\",\"temp\":27.7,\"feels_like\":27.02,\"pressure\":1008,\"humidity\":33,\"dew_point\":9.98,\"uvi\":1.57,\"clouds\":0,\"visibility\":10000,\"wind_speed\":2.6,\"wind_deg\":317,\"wind_gust\":5.39,\"weather\":[{\"id\":800,\"main\":\"Clear\",\"description\":\"clear sky\",\"icon\":\"01d\"}],\"pop\":0}]"
                }
            }
        }
    }
}

In Orchestration and Knowledge Base tab from Management Console Test page, the body above, from the Lambda response, did not appeared. Should the body be formatted differently ?
I've tried also the below format (body as JSON), but the same error appeared:

{
    "messageVersion": "1.0",
    "response": {
        "actionGroup": "default",
        "function": "weather_data_crawler_action-tfeuw",
        "functionResponse": {
            "responseBody": {
                "TEXT": {
                    "body": [
                        {
                            "dt": "2025.07.22 16:00:00",
                            "temp": 38.8,
                            "feels_like": 40.14,
                            "pressure": 1005,
                            "humidity": 28,
                            "dew_point": 17.01,
                            "uvi": 5,
                            "clouds": 0,
                            "visibility": 10000,
                            "wind_speed": 3.21,
                            "wind_deg": 237,
                            "wind_gust": 5.02,
                            "weather": [
                                {
                                    "id": 800,
                                    "main": "Clear",
                                    "description": "clear sky",
                                    "icon": "01d"
                                }
                            ],
                            "pop": 0
                        }
                    ]
                }
            }
        }
    }
}

I've tried also the below format (only JSON text), but the same error appeared:

[
	{
		"dt": "2025.07.22 16:00:00",
		"temp": 38.8,
		"feels_like": 40.14,
		"pressure": 1005,
		"humidity": 28,
		"dew_point": 17.01,
		"uvi": 5,
		"clouds": 0,
		"visibility": 10000,
		"wind_speed": 3.21,
		"wind_deg": 237,
		"wind_gust": 5.02,
		"weather": [
			{
				"id": 800,
				"main": "Clear",
				"description": "clear sky",
				"icon": "01d"
			}
		],
		"pop": 0
	}
]

Thank you,

asked a year ago391 views

2 Answers
0

Good morning,

Did you have any success with the proposed changes above?

{ "messageVersion": "1.0", "response": { "actionGroup": "default", "function": "weather_data_crawler_action-tfeuw", "functionResponse": { "responseState": "SUCCESS", "responseBody": { "application/json": { "weather_data": [ { "dt": "2025.07.22 16:00:00", "temp": 38.8, "feels_like": 40.14, "pressure": 1005, "humidity": 28, "weather": [{"description": "clear sky"}] } ] } } } } }

AWS

answered a year ago

  • Hello,

    According to the documentation the format of the response is:

    {
        "messageVersion": "1.0",
        "response": {
            "actionGroup": "string",
            "function": "string",
            "functionResponse": {
                "responseState": "FAILURE | REPROMPT",
                "responseBody": {
                    "TEXT": { 
                        "body": "JSON-formatted string"
                    }
                }
            }
        }
    

    responseBody – Contains an object that defines the response from execution of the function. The key is the content type (currently only TEXT is supported) and the value is an object containing the body of the response.

    Do you think that other formats would work ?

  • Hello,
    I've tried also with the proposed changes, displayed below. The same error appeared.

    {
        "messageVersion": "1.0",
        "response": {
            "actionGroup": "default",
            "function": "weather_data_crawler_action-tfeuw",
            "functionResponse": {
                "responseState": "SUCCESS",
                "responseBody": {
                    "application/json": {
                        "weather_data": [
                            {
                                "dt": "2025.07.25 13:00:00",
                                "temp": 36.23,
                                "feels_like": 36.52,
                                "pressure": 1011,
                                "humidity": 30,
                                "dew_point": 15.9,
                                "uvi": 8.92,
                                "clouds": 0,
                                "visibility": 10000,
                                "wind_speed": 0.42,
                                "wind_deg": 208,
                                "wind_gust": 1.66,
                                "weather": [
                                    {
                                        "id": 800,
                                        "main": "Clear",
                                        "description": "clear sky",
                                        "icon": "01d"
                                    }
                                ],
                                "pop": 0
                            }
                        ]
                    }
                }
            }
        }
    }
    
0

The error "The server encountered an error processing the Lambda response" you're experiencing with your Bedrock Agent could be due to several issues. Let me help you troubleshoot this problem.

First, there might be a permissions issue between your Bedrock Agent and Lambda function. You need to ensure that your Bedrock Agent has the necessary permissions to invoke the Lambda function by adding a resource-based policy statement to your Lambda function:

  1. Go to your Lambda function in the AWS Console
  2. Select the "Configuration" tab
  3. Click on "Permissions" in the left menu
  4. Scroll down to "Resource-based Policy Statements" and click "Add Permissions"
  5. Select "AWS Service" radio button
  6. Choose "Other" from the "Service" dropdown
  7. Enter a Statement ID (any identifier)
  8. Enter "bedrock.amazonaws.com" for the Principal
  9. Enter your Bedrock Agent's ARN as the Source ARN
  10. Select "lambda:InvokeFunction" as the Action
  11. Click "Save"

Regarding the Lambda response format, the issue might be with how you're structuring your response. For Bedrock Agents, try simplifying your response format to:

{
"messageVersion": "1.0",
"response": {
"actionGroup": "default",
"function": "weather_data_crawler_action-tfeuw",
"functionResponse": {
"responseState": "SUCCESS",
"responseBody": {
"application/json": {
"weather_data": [
{
"dt": "2025.07.22 16:00:00",
"temp": 38.8,
"feels_like": 40.14,
"pressure": 1005,
"humidity": 28,
"weather": [{"description": "clear sky"}]
}
]
}
}
}
}
}

Another potential issue could be with your action group name. Make sure your action group name doesn't contain hyphens (-) as these can cause issues with Bedrock Agents. Use underscores (_) instead.

To see more detailed error information, you can enable more comprehensive logging for both your Lambda function and the Bedrock Agent. Check the CloudWatch logs for both services to get more insight into where the error is occurring.

If you're still encountering issues after trying these solutions, you might want to run the agent container locally with the same payload for better diagnostics or consider implementing a custom parser Lambda function to handle the response.
Sources
Bedrock Agent hidden error | AWS re:Post
Error when Bedrock agent invoke lambda | AWS re:Post
Troubleshoot AgentCore Runtime - Amazon Bedrock AgentCore
Bedrock error "The server encountered an error processing the Lambda response. Check the Lambda response and retry the request" | AWS re:Post
Issue with Bedrock Agents and Lambda Function – Model Timeout/Error | AWS re:Post

answered a year 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.