fix(tools): add items schema for array-type parameters#690
fix(tools): add items schema for array-type parameters#690nick-stebbings wants to merge 2 commits intonearai:mainfrom
Conversation
…on tools
- http tool body param and json tool input param were missing items: {}
causing schema validation errors with strict JSON Schema validators
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a compatibility issue with strict JSON Schema validators by enhancing the schema definitions for array-type parameters in Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request addresses an issue with JSON schema validation for array-type parameters in HttpTool and JsonTool by adding the type and items properties. The changes are correct and align with the goal of supporting strict schema validators. However, these changes break existing unit tests that were specifically designed to check for the absence of the type field. I've left comments on the respective files pointing out the failing tests and suggesting how to update them. Addressing these test failures is critical.
Tests were asserting type field is absent (old freeform approach). Updated
to validate the new union type array with items:{} structure.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Updated: Fixed 2 broken tests — |
Summary
The
bodyparameter inHttpTooland thedataparameter inJsonToolaccept arrays among other types, but their JSON Schema declarations were missing both thetypeconstraint and theitemsproperty. Strict JSON Schema validators (e.g. OpenAI's structured output validation) reject array-type schemas withoutitems.Adds
"type"(union of all JSON types) and"items": {}(accepts any array element) to both parameters. Preserves upstream's descriptions andsource_tool_call_idfield.Changes
src/tools/builtin/http.rs— Addtypearray anditems: {}tobodyparameter schemasrc/tools/builtin/json.rs— Addtypearray anditems: {}todataparameter schemaTest plan