- Newest
- Most votes
- Most comments
Hi there. According to the docs, for an action group with function details:
responseStateis optional. If set, it should be set to FAILURE or REPROMPT.responseBodyonly supportsTEXTas content-type. The value is an object containing the body of the response.
Have you tried to use these values? There is an example of the link shared above, hopefully can also help.
Regards.
The error you're encountering suggests that there might be an issue with how the Bedrock Agent is processing the Lambda function's response. Here are a few things to check and try:
-
Response Format: Ensure your Lambda function is returning data in a format that the Bedrock Agent can parse. The default parser used by Bedrock Agents expects a specific format. Your current response looks close, but you might need to adjust it slightly.
-
Content Type: You mentioned changing "text/plain" to JSON. This is a good step, as Bedrock Agents often work better with structured data. Try formatting your response like this:
{ "messageVersion": "1.0", "response": { "actionGroup": "test", "function": "get-ec2-cost-function", "functionResponse": { "responseState": "SUCCESS", "responseBody": { "content": { "instance_type": "r5a.large", "location": "Asia Pacific (Seoul)", "costs": { "Linux": "$0.136/hr", "RHEL": "$0.165/hr", "Windows": "$0.228/hr", "Ubuntu Pro": "$0.14/hr" } } } } } } -
Permissions: Double-check that your Bedrock Agent has the necessary permissions to invoke the Lambda function. You may need to add a resource-based policy statement to your Lambda function allowing the Bedrock Agent to invoke it.
-
Error Logging: Enable more detailed logging for both your Lambda function and the Bedrock Agent if possible. This might provide more insight into where exactly the error is occurring.
-
Custom Parser: If the default parser is still having trouble with your Lambda function's output, you might want to consider implementing a custom parser Lambda function to handle the response.
-
Agent Configuration: Review your agent's configuration, especially the action group setup and the OpenAPI spec provided for the Lambda function. Ensure all parameters and data types are correctly defined.
If these steps don't resolve the issue, you may need to open a support case with AWS for further assistance. They may be able to provide more detailed information about the error occurring during the Lambda response processing.
Sources
Bedrock Agent hidden error | AWS re:Post
Error when Bedrock agent invoke lambda | AWS re:Post
Error raised while calling invoke agent operation | AWS re:Post
Here's my response code added to the lambda, def format_bedrock_response(sop): return { "messageVersion": "1.0", "response": { "actionGroup": "test123", "function": "sopjiraselectorfunction", "functionResponse": { "responseBody": { "application/json": { "sop_title": str(sop.get("sop_title", "")), "sop_url": str(sop.get("sop_url", "")), "confidence": str(sop.get("confidence", "")), "reason": str(sop.get("reason", "")) } } } } } The response is coming in json in Lambda output: Status: Succeeded Test Event Name: sopselectorjira
Response: { "messageVersion": "1.0", "response": { "actionGroup": "test123", "function": "sopjiraselectorfunction", "functionResponse": { "responseBody": { "text/plain": { "sop_title": "Service Latency SOP", "sop_url": "https://xxxx.atlassian.net/wiki/spaces/xxxx/pages/xxxxx", "confidence": "high", "reason": "The incident is specifically about a 'Service Latency Spike', and the 'Service Latency SOP' directly addresses handling latency issues in services, making it the most relevant SOP for this incident." } } } } }
The area below shows the last 4 KB of the execution log.
But in bedrock, it returns the following message. " The server encountered an error processing the Lambda response. Check the Lambda response and retry the request" Please advise if any changes need to be done to def section for the bedrock response in lambda. Your help is highly appreciated.
answered 4 months ago
Relevant content
- AWS OFFICIALUpdated 10 months ago

Appreciate the heads-up! I hadn’t paid close attention to responseState and its impact on flow logic—really helpful to see it laid out like this. I’ll double-check my implementation against the example you mentioned. Thanks again!