Problem/Motivation
If you have a tool call with no input (or all input is forced+hidden), you get an error back from the AWS API that toolConfig.tools[0].inputSchema.json is invalid.
Currently that ends up as null as docroot/modules/contrib/ai_provider_aws_bedrock/src/Plugin/AiProvider/BedrockProvider.php:396 is run with no $parameters.
Steps to reproduce
Call an agent with a function call with no exposed parameters.
Proposed resolution
Explored:
- Completely removing
inputSchema: AWS error due to missing required property
- Making
inputSchema.json.properties an empty array: AWS error due to array when expecting object
- Making
inputSchema.json.properties an empty object: AWS SDK error due to expecting an array :P
- Always setting parameters to
{"type":"object"} in \Drupal\ai\OperationType\Chat\Tools\ToolsFunctionInput::renderFunctionArray: OpenAI error due to peroprties being required.
So propose this is handled as a special case where we do 4, but in the AWS Bedrock provider (we already have custom code there anyway).
Remaining tasks
Implement the fix.
User interface changes
N/A
API changes
N/A
Data model changes
N/A
Comments
Comment #4
andrewbelcher commentedComment #5
marcus_johansson commentedLooks good
Comment #7
andrewbelcher commented