- Newest
- Most votes
- Most comments
We ran into the same issue. This documentation indicates that non-OpenAPI-defined action groups do not support nested objects. I suspect that action groups defined using an OpenAPI schema are subject to the same limitations, even though this is not documented at all. Ideally, Bedrock would also provide along the raw content generated by the agent so we could parse it in the application.
answered 9 months ago
This is a known issue with Bedrock Agents when passing complex data types like objects and arrays to Lambda functions. The agent sometimes formats these parameters as strings with improper JSON formatting, making them difficult to parse in your Lambda function.
Here are some workarounds you can implement:
- Add defensive parsing in your Lambda function: Create a helper function that attempts to clean and properly format the malformed JSON strings before parsing them. For example:
def clean_json_string(json_str): if isinstance(json_str, str): # Replace unquoted keys and values with properly quoted ones import re # Add quotes to keys json_str = re.sub(r'(\w+):', r'"\1":', json_str) # Add quotes to string values that aren't already quoted json_str = re.sub(r': *(\w+)', r': "\1"', json_str) return json.loads(json_str) return json_str
-
Use string parameters and parse them in your Lambda: Instead of defining complex object types in your OpenAPI schema, use string parameters and have your Lambda function parse them. This gives you more control over the parsing logic.
-
Simplify your schema: Break down complex objects into individual string parameters where possible, which tend to be handled more reliably.
-
Wrap arrays in objects: Instead of using top-level arrays, wrap them in objects, which sometimes helps with proper formatting.
-
Add explicit formatting instructions in your action group description: While you mentioned this didn't fully resolve the issue, including specific formatting instructions in your action group description or parameter descriptions can sometimes help.
The issue appears to be related to how the Bedrock Agent formats the parameters when invoking the Lambda function, rather than an issue with your OpenAPI schema definition. The inconsistent behavior you're seeing (where retries sometimes work correctly) suggests this is likely a limitation in the current implementation of Bedrock Agents.
If these workarounds don't resolve your issue, consider reaching out to AWS Support for additional guidance, as they may have more specific recommendations or information about upcoming fixes for this behavior.
Sources
JSON Array in RequestBody not supported? | AWS re:Post
Amazon.Lambda.AspNetCoreServer.Hosting as Bedrock Agent Action Group Lambda | AWS re:Post
Is this a Bug? Not been able to edit action group function in JSON Editor. | AWS re:Post
answered a year ago
Relevant content
asked 2 years ago
- AWS OFFICIALUpdated 5 months ago
- AWS OFFICIALUpdated 5 months ago

Is there any valid solution for this issue of aws bedrock agent not able to produce valid json which would work every time. Updating instruction in agent and orchestration also does not help. Currently I have to wait for agent to retry and hope that it somehow decides to create a valid json. If not then the whole flow breaks. What is the point of giving user the option to add object/array type body parametrs if it is not working