Skip to content

fix(gemini): sanitize schema keywords in function responses to prevent 400 - #3411

Open
AhooraZen wants to merge 1 commit into
decolua:masterfrom
AhooraZen:fix-gemini-tool-response-schema-refs
Open

fix(gemini): sanitize schema keywords in function responses to prevent 400#3411
AhooraZen wants to merge 1 commit into
decolua:masterfrom
AhooraZen:fix-gemini-tool-response-schema-refs

Conversation

@AhooraZen

Copy link
Copy Markdown

Problem

When tool output (e.g. from webfetch or JSON schema files) contains keys like $ref, $defs, #, or /, tryParseJSON parses them into the functionResponse.response object.

Google Gemini / Antigravity protobuf parser treats these keys as schema references rather than payload data, failing with:

{"error":{"code":400,"message":"The referenced name `#/$defs/Config` in function_response.response does not match to a display_name in the function_response.parts.","status":"INVALID_ARGUMENT"}}

Solution

  • Added sanitizeFunctionResponseResult in open-sse/translator/formats/gemini.js to recursively sanitize forbidden schema characters ($, #, /, definitions) in tool result objects before constructing functionResponse.
  • Added unit test in scripts/test-gemini-tool-response-sanitization.mjs.

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