Skip to content

fix(gemini): strip deprecated keyword from tool schemas sent to Gemini API#413

Closed
n24q02m wants to merge 2 commits intorouter-for-me:mainfrom
n24q02m:fix/strip-deprecated-from-gemini-schema
Closed

fix(gemini): strip deprecated keyword from tool schemas sent to Gemini API#413
n24q02m wants to merge 2 commits intorouter-for-me:mainfrom
n24q02m:fix/strip-deprecated-from-gemini-schema

Conversation

@n24q02m
Copy link

@n24q02m n24q02m commented Mar 5, 2026

Summary

Gemini API rejects function declarations containing the JSON Schema deprecated keyword with INVALID_ARGUMENT (400). Claude Code and other clients include this field in their tool definitions, causing errors on Antigravity/Gemini routes.

Changes

Add "deprecated" to the unsupported keywords list in removeUnsupportedKeywords() (internal/util/gemini_schema.go) so it is stripped before forwarding to Gemini.

Reproduction

  1. Use Claude Code (or any client that emits "deprecated": true in tool schemas) with an Antigravity account
  2. Observe INVALID_ARGUMENT / 400 error from Gemini API:
    Unknown name "deprecated" at 'request.tools[0].function_declarations[X].parameters.properties[Y].value'
    
  3. After this fix, the field is stripped and requests succeed.

Related

…ini API

Gemini API rejects function declarations containing the JSON Schema
`deprecated` keyword with INVALID_ARGUMENT. Claude Code and other
clients include this field in their tool definitions, causing 400
errors on Antigravity/Gemini routes.

Add `deprecated` to the unsupported keywords list in
removeUnsupportedKeywords() so it is stripped before forwarding.
@gemini-code-assist
Copy link

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 critical compatibility issue with the Gemini API, where tool declarations containing the deprecated JSON Schema keyword were being rejected. By proactively removing this unsupported keyword from the outgoing schemas, the change ensures that clients can successfully interact with the Gemini API without encountering INVALID_ARGUMENT errors, thereby improving the robustness and interoperability of the system.

Highlights

  • Gemini API Compatibility: Resolved an INVALID_ARGUMENT error (400) from the Gemini API when tool schemas containing the JSON Schema deprecated keyword were sent, which was affecting clients like Claude Code.
  • Schema Keyword Stripping: The deprecated keyword is now explicitly stripped from tool schemas before being forwarded to the Gemini API, preventing rejection.

🧠 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 "deprecated" to the list of unsupported JSON Schema keywords that are stripped before sending to the Gemini API.
Activity
  • No human activity (comments, reviews) has been recorded on this pull request yet.
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

@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 deprecated keyword. The fix is to add deprecated to the list of unsupported keywords that are stripped from the schema before sending it to Gemini. The change is simple and correct. I've suggested adding a test case to verify this behavior and prevent regressions.

"$schema", "$defs", "definitions", "const", "$ref", "$id", "additionalProperties",
"propertyNames", "patternProperties", // Gemini doesn't support these schema keywords
"enumTitles", "prefill", // Claude/OpenCode schema metadata fields unsupported by Gemini
"deprecated", // JSON Schema keyword not supported by Gemini API

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 deprecated to the list of unsupported keywords. To ensure this fix is robust and prevent future regressions, it would be great to add a test case that verifies the deprecated keyword is stripped.

You could add the following test to internal/util/gemini_schema_test.go:

func TestCleanJSONSchemaForGemini_RemovesDeprecatedField(t *testing.T) {
	input := `{
		"type": "object",
		"properties": {
			"old_field": {
				"type": "string",
				"deprecated": true
			}
		}
	}`

	expected := `{
		"type": "object",
		"properties": {
			"old_field": {
				"type": "string"
			}
		}
	}`

	result := CleanJSONSchemaForGemini(input)
	compareJSON(t, expected, result)
}

Verify that `deprecated` field is stripped from tool schemas while
preserving properties named "deprecated" as legitimate field names.
@luispater luispater closed this Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants