Skip to content

fix(tools): add items schema for array-type parameters#690

Open
nick-stebbings wants to merge 2 commits intonearai:mainfrom
nick-stebbings:pr/tools-schema-fix
Open

fix(tools): add items schema for array-type parameters#690
nick-stebbings wants to merge 2 commits intonearai:mainfrom
nick-stebbings:pr/tools-schema-fix

Conversation

@nick-stebbings
Copy link

Summary

The body parameter in HttpTool and the data parameter in JsonTool accept arrays among other types, but their JSON Schema declarations were missing both the type constraint and the items property. Strict JSON Schema validators (e.g. OpenAI's structured output validation) reject array-type schemas without items.

Adds "type" (union of all JSON types) and "items": {} (accepts any array element) to both parameters. Preserves upstream's descriptions and source_tool_call_id field.

Changes

  • src/tools/builtin/http.rs — Add type array and items: {} to body parameter schema
  • src/tools/builtin/json.rs — Add type array and items: {} to data parameter schema

Test plan

  • Validate the schema output against a strict JSON Schema validator
  • Verify HttpTool accepts body as object, array, string, number, boolean, null
  • Verify JsonTool accepts data as all the same types

…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>
@github-actions github-actions bot added the scope: tool/builtin Built-in tools label Mar 7, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 HttpTool and JsonTool. By explicitly adding type and items properties to the body and data parameters respectively, the schemas now correctly represent that these parameters can accept various JSON types, including arrays, thus preventing validation rejections from tools like OpenAI's structured output validation.

Highlights

  • HttpTool body parameter schema: The JSON schema for the body parameter in HttpTool was updated to explicitly include a type array covering all JSON types and an items: {} property, ensuring compatibility with strict JSON Schema validators for array-type inputs.
  • JsonTool data parameter schema: The JSON schema for the data parameter in JsonTool was updated to explicitly include a type array covering all JSON types and an items: {} property, ensuring compatibility with strict JSON Schema validators for array-type inputs.
Changelog
  • src/tools/builtin/http.rs
    • Added type property with a union of all JSON types to the body parameter schema.
    • Added items: {} to the body parameter schema.
  • src/tools/builtin/json.rs
    • Added type property with a union of all JSON types to the data parameter schema.
    • Added items: {} to the data parameter schema.
Activity
  • No review comments or explicit activity beyond the initial pull request creation and description have been recorded. The author has outlined a test plan for validation.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions github-actions bot added size: XS < 10 changed lines (excluding docs) risk: medium Business logic, config, or moderate-risk modules contributor: new First-time contributor labels Mar 7, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@nick-stebbings
Copy link
Author

Updated: Fixed 2 broken tests — test_http_tool_schema_body_is_freeform and test_json_tool_schema_data_is_freeform were asserting type is absent (the old freeform approach). Renamed and updated to validate the new union type array with items:{} structure.

@github-actions github-actions bot added size: S 10-49 changed lines and removed size: XS < 10 changed lines (excluding docs) labels Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor: new First-time contributor risk: medium Business logic, config, or moderate-risk modules scope: tool/builtin Built-in tools size: S 10-49 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant