Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon Bedrock unable to interpret the lambda response appropriately

I am working with Bedrock to call a lambda via the action group:

Despite getting an appropriate response from Lambda, I get the below error:

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

Lambda response:

{'messageVersion': '1.0', 'response': {'actionGroup': 'action-group-quick-start-55acd', 'function': 'connectSQL', 'functionResponse': {'responseBody': [{'total_count': 10000}]}}}

like image 617
sashmi Avatar asked Jan 22 '26 22:01

sashmi


1 Answers

I found the fix. The issue was with the incorrect lambda response. https://docs.aws.amazon.com/bedrock/latest/userguide/agents-lambda.html#agents-lambda-response

Modified the lambda response to :

response_body = {
        'TEXT': {
            'body': "sample response"
        }
    }    
    function_response = {
        'actionGroup': event['actionGroup'],
        'function': event['function'],
        'functionResponse': {
            'responseBody': response_body
        }
    }    
    session_attributes = event['sessionAttributes']
    prompt_session_attributes = event['promptSessionAttributes']    
    action_response = {
        'messageVersion': '1.0', 
        'response': function_response,
        'sessionAttributes': session_attributes,
        'promptSessionAttributes': prompt_session_attributes
    }
like image 139
sashmi Avatar answered Jan 25 '26 18:01

sashmi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!