Skip to content

Migrate to AI SDK v7 (@ai-sdk/google ≥4.0.70) so Gemini receives the full JSON Schema (fixes #139) #141

Closed as not planned

Description

@byapparov

Context

#139 is reproduced on 0.4.7: @ai-sdk/google 2.0.54's convertJSONSchemaToOpenAPISchema strips additionalProperties (and pattern, min/max, $ref), so Gemini returns {} for map-typed fields. All 5 Gemini PR Explanation runs in aictrl prod on 2026-10-10 lost every diagram element.

The upstream fix is @ai-sdk/google 4.0.70 (vercel/ai#20757, merged 2026-09-14): it sends parametersJsonSchema for tools and responseJsonSchema for outputs, and removes the lossy converter. It ships only on the AI SDK v7 line (provider 4.x, provider-utils 5.x, google-vertex 5.x). The v6 line (google 3.0.131) still converts, and there is no v5/v6 backport. Upstream OpenCode dev is on ai 6.0.168 / google 3.0.73 and has the same bug.

Founder decision (2026-10-10): fix #139 by migrating the SDK, not with a local patch or a contract workaround.

Goal

Move the fork from ai 5.0.124 / @ai-sdk/google 2.0.54 / @ai-sdk/google-vertex 3.0.106 to AI SDK v7 (google ≥ 4.0.70, google-vertex 5.x) across every provider package we use, with no behaviour regressions.

Acceptance Criteria

Notes

Activity

  1. byapparov commented on Oct 10, 2026

    @byapparov
    ContributorAuthor

    Scoping result (2026-10-10). Recommendation: one PR jumping straight to v7, after #140. Estimate 4–5 days.

    • Ruled out: a Google-only bump (ai 5 rejects non-v2 provider specs, and google 4.x is v4-only) and a v6 stop (v6 still converts the schema). Use upstream refactor(opencode): migrate to ai sdk v7 anomalyco/opencode#52064 as a checklist, not a cherry-pick.
    • Size: after the full bump there are 21 typecheck errors and 77 of 1678 tests fail.
    • Biggest risks:
      • finish-reason handling ("unknown" is removed; it affects termination, retry and the processor);
      • GLM's missing finish reason now raises an error;
      • system messages in messages are rejected at runtime;
      • usage fields are renamed, which silently breaks cost tracking;
      • the Gemini sanitizer, the Vertex metadata key, re-porting the OpenRouter patch;
      • changed provider defaults (OpenAI strictJsonSchema, Azure/xAI Responses API).

    Probe on v7: #139 is only partly fixed. The full schema now reaches Gemini (parametersJsonSchema with additionalProperties), and elements comes back with 6 entries instead of {}. But Gemini rewrites the map keys in its function-call response: queued->running→queued__running, 1→_1 or first_step, TASKS.org_id→TASKS_org_id. Ajv accepts the result and the run exits 0, so it's silently corrupted. The array-shaped schema and GLM both came back intact. So map-keyed results aren't safe through Gemini function calling even with the full schema; #140's path form avoids the issue entirely for file-based results.

  2. byapparov commented on Oct 11, 2026

    @byapparov
    ContributorAuthor

    Closed for now (founder, 2026-10-11): no current driver. #142 (released in 0.4.8) made schema-mode StructuredOutput take only {path}, so the big result schema no longer goes through @ai-sdk/google's lossy converter, and the prod symptom (Gemini PR Explanations with empty diagram elements) is fixed and verified. Upstream anomalyco/opencode closed its own v7 migration PR (#52064) unmerged, so there's no upstream to follow yet either. The scoping notes above stand (4–5 days, risk list). Reopen when a concrete problem needs AI SDK v7, e.g. an MCP tool with a map-typed schema misbehaving on Gemini, or a provider feature only v7 has. A lighter alternative if only Gemini is affected: a native Gemini path that sends parametersJsonSchema (as NousResearch/hermes-agent does in agent/gemini_schema.py).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions