Fix array parameter handling in tool declarations for Gemini and OpenAI #358
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
items
field for array parameters in tool declarationsGenerateContentRequest.tools[0].function_declarations[2].parameters.properties[fields].items: missing field
Problem
Both Gemini and OpenAI APIs require an
items
field for array-type parameters in tool/function declarations to specify the type of array elements. Without this field, tools with array parameters fail with missing field errors or may not work correctly.Solution
Modified the parameter formatting methods in both providers to automatically add the
items
field for all array-type parameters:items: { type: 'STRING' }
informat_parameters
methoditems: { type: 'string' }
inparam_schema
methodChanges
lib/ruby_llm/providers/gemini/tools.rb
to add items field for array typeslib/ruby_llm/providers/openai/tools.rb
to add items field for array typesspec/ruby_llm/providers/gemini/tools_spec.rb
spec/ruby_llm/providers/openai/tools_spec.rb
Test Plan
This resolves issues when using tools with array parameters in both Gemini and OpenAI models, enabling proper function calling with arrays across multiple providers.
🤖 Generated with Claude Code