Skip to content

fix(gemini): remove redundant schema injection into system prompt#1071

Open
seheepeak wants to merge 1 commit intovectorize-io:mainfrom
seheepeak:fix/gemini-duplicate-schema-injection
Open

fix(gemini): remove redundant schema injection into system prompt#1071
seheepeak wants to merge 1 commit intovectorize-io:mainfrom
seheepeak:fix/gemini-duplicate-schema-injection

Conversation

@seheepeak
Copy link
Copy Markdown

Summary

Removes the JSON schema text injection from system_instruction in GeminiLLM.call(). The schema is already passed via the native response_schema parameter (with response_mime_type="application/json"), so the prompt-side injection was duplicating it on every structured-output call and wasting input tokens.

Fixes #1070

Test plan

  • Verified retain still works correctly with the Gemini provider after removing the lines
  • ruff check, ruff format --check, ty check pass on the modified file

GeminiLLM.call() was sending the structured output schema twice: once
injected as text into system_instruction, and once via the native
response_schema parameter. The native parameter (with response_mime_type
set to application/json) already enforces structured output, so the
prompt-side injection only wasted input tokens.

Fixes vectorize-io#1070
@seheepeak
Copy link
Copy Markdown
Author

CI failures look unrelated to this PR — fixture setup fails with HINDSIGHT_API_LLM_VERTEXAI_PROJECT_ID is required for Vertex AI provider. Probably needs a maintainer's eyes.

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.

GeminiLLM provider sends structured output schema twice (prompt + native response_schema)

2 participants