Skip to content

fix: strip uniqueItems from Gemini function_declarations (#2123)#2142

Merged
luispater merged 2 commits intorouter-for-me:devfrom
Muran-prog:fix/strip-uniqueItems-gemini-2123
Mar 16, 2026
Merged

fix: strip uniqueItems from Gemini function_declarations (#2123)#2142
luispater merged 2 commits intorouter-for-me:devfrom
Muran-prog:fix/strip-uniqueItems-gemini-2123

Conversation

@Muran-prog
Copy link
Copy Markdown
Contributor

Fixes #2123

Gemini API rejects uniqueItems in tool schemas:
400 Unknown name "uniqueItems" at 'request.tools0.function_declarations43.parameters.properties2.value'

Added uniqueItems to unsupportedConstraints in gemini_schema.go alongside minItems/maxItems - same approach as #1424 and #1531.

All existing schema sanitization tests pass.

Gemini API rejects uniqueItems in tool schemas with 400. Add it to
unsupportedConstraints alongside minItems/maxItems where it belongs.

Same class of fix as #1424 and #1531.
@gemini-code-assist
Copy link
Copy Markdown
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 the Gemini API by ensuring that the uniqueItems schema constraint is properly handled. By adding this constraint to the list of unsupported items, the system prevents API rejections and ensures smooth integration, maintaining the integrity of existing schema sanitization processes.

Highlights

  • Gemini API Compatibility: Resolved an issue where the Gemini API rejected uniqueItems in tool schemas by adding it to the list of unsupportedConstraints.
  • Schema Sanitization: The uniqueItems constraint is now stripped from function declarations when interacting with the Gemini API, aligning with previous fixes for minItems and maxItems.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • internal/util/gemini_schema.go
    • Added 'uniqueItems' to the list of unsupported schema constraints.
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.

Copy link
Copy Markdown
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 where the Gemini API rejects schemas containing the uniqueItems keyword. The fix correctly adds uniqueItems to the list of unsupported constraints, ensuring it's stripped from the schema before being sent to the API. The change is straightforward and follows the existing pattern for handling unsupported schema properties. I've suggested adding a test case to verify this new behavior and prevent future regressions.

var unsupportedConstraints = []string{
"minLength", "maxLength", "exclusiveMinimum", "exclusiveMaximum",
"pattern", "minItems", "maxItems", "format",
"pattern", "minItems", "maxItems", "uniqueItems", "format",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This change correctly adds uniqueItems to the list of unsupported constraints. To ensure this fix is robust and prevent future regressions, it would be beneficial to add a new test case to internal/util/gemini_schema_test.go. This test should verify that the uniqueItems keyword is removed from the schema and a corresponding hint is added to the description, similar to how other constraints like minItems are tested.

Covers the fix from the previous commit — verifies uniqueItems is
removed from the schema and moved to the description hint.
@Muran-prog
Copy link
Copy Markdown
Contributor Author

Added a test in the follow-up commit - verifies uniqueItems is stripped and the description hint is added.

Copy link
Copy Markdown
Collaborator

@luispater luispater left a comment

Choose a reason for hiding this comment

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

Summary

This change fixes the reported Gemini schema rejection by stripping uniqueItems alongside the other unsupported constraints and preserving it as a description hint. The implementation is consistent with the existing sanitizer flow, and the added regression test covers the shared constraint-to-description path.

Key findings

  • No blocking issues found.
  • Non-blocking: consider adding a CleanJSONSchemaForGemini regression test too, since that is the directly reported failing entry point.

Test plan

  • Reviewed the diff for internal/util/gemini_schema.go and internal/util/gemini_schema_test.go
  • Ran go test ./internal/util on the PR head
  • Ignored translator-path-guard per instructions

This is an automated Codex review result and still requires manual verification by a human reviewer.

@luispater luispater changed the base branch from main to dev March 16, 2026 12:34
@luispater luispater merged commit fb95813 into router-for-me:dev Mar 16, 2026
2 checks passed
Adamcf123 pushed a commit to Adamcf123/CLIProxyAPI that referenced this pull request Mar 24, 2026
…eItems-gemini-2123

fix: strip uniqueItems from Gemini function_declarations (router-for-me#2123)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Claude→Gemini translation fails: uniqueItems not stripped from function_declarations

2 participants