Skip to content

fix(google): use responseJsonSchema for Gemini#15333

Closed
Kage18 wants to merge 1 commit into
vercel:mainfrom
Kage18:kage-fix-google-response-json-schema
Closed

fix(google): use responseJsonSchema for Gemini#15333
Kage18 wants to merge 1 commit into
vercel:mainfrom
Kage18:kage-fix-google-response-json-schema

Conversation

@Kage18

@Kage18 Kage18 commented May 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • send Gemini structured-output schemas as generationConfig.responseJsonSchema for the Google API
  • keep Vertex requests on generationConfig.responseSchema
  • cover generate and stream request bodies, plus a Vertex regression

Fixes #7689.

Kage usage

  • Used Kage scoped to packages/google to locate the shared GoogleLanguageModel path and relevant structured-output tests.
  • Captured a repo-local memory packet explaining why non-Vertex Google uses responseJsonSchema while Vertex keeps responseSchema.
  • Local Kage metrics after refresh: 78 files, 2,158 symbols, 1,369 calls, 564 tests, 100% indexed coverage, 3 memory packets, 82 memory graph entities, 83 evidence-backed edges, 0 stale packets.

Tests

  • pnpm --dir packages/google exec vitest --config vitest.node.config.js --run src/google-language-model.test.ts
  • pnpm --filter @ai-sdk/google type-check

Note: local verification emitted the repository Node engine warning because this shell runs Node v25.9.0 while the repo declares support for ^18/^20/^22/^24.

@Kage18

Kage18 commented May 15, 2026

Copy link
Copy Markdown
Contributor Author

Kage usage for this PR:

This PR fixed #7689 by sending Gemini structured-output schemas as generationConfig.responseJsonSchema for the Google API while preserving generationConfig.responseSchema for Vertex.

How Kage helped:

  • Scoped recall to packages/google and the shared GoogleLanguageModel request-building path.
  • Kept the relevant implementation, snapshots, and tests together: google-language-model.ts, google-language-model.test.ts, and the structured-output snapshots.
  • Helped preserve the important provider split: non-Vertex Google requests use responseJsonSchema; Vertex requests continue using responseSchema.
  • Captured the durable rule and regression evidence for both generate and stream request bodies, plus the Vertex regression case.
  • Captured the verification commands and the local Node engine-warning context.

Why this matters for future sessions:
A future agent changing Google structured-output request generation can recall the API/Vertex distinction and avoid “simplifying” both providers onto the same schema field.

Full contribution summary and Kage metrics: kage-core/Kage#8

? convertJSONSchemaToOpenAPISchema(responseFormat.schema)
: undefined,
(googleOptions?.structuredOutputs ?? true) &&
(isVertexProvider

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Without any necessary filtering, they have the same "responseJsonSchema" parameter.
Please refer to Vertex AI(linked to gemini-enterprise-agent-platform) for details.

In addition, please modify the convertJSONSchemaToOpenAPISchema function based on ai.google.dev to support more JSON schemas, so as to make this PR more necessary.

Sorry for that I am not a relevant contributor and thus cannot assist you in passing this PR.

@lgrammel

Copy link
Copy Markdown
Collaborator

Thank you for the pull request. Issue #7689 was closed as not planned. Closing this pull request.

@lgrammel lgrammel closed this Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect property name: responseSchema should be response_json_schema for Google providers

3 participants