[Bug]: Gemini on Vertex AI rejects T3 Code's MCP tools because model selection fields have no JSON Schema type#21655

opened27d agobyBBilalAtique

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

packages/contracts or packages/shared

Steps to reproduce

  1. Use the OpenCode provider with a Gemini model served by Vertex AI. For example, use Vercel AI Gateway with vercel/google/gemini-4-argon and pin it to Vertex in opencode.jsonc:
    jsonc
    1"provider": { "vercel": { "models": { "google/gemini-4-argon": { "options": { "gateway": { "only": ["vertex"] } } } } } }
  2. Start a thread on that model and send any message, for example "Reply with ok".

Expected behavior

The turn runs.

Actual behavior

The first turn fails, and Vertex AI returns HTTP 400:

1Unable to submit request because `t3-code_t3_project_create` functionDeclaration `parameters.defaultModelSelection.instanceId` schema didn't specify the schema type field.

Vertex refuses the whole request when one tool parameter has no type. T3 Code attaches its MCP tools to the OpenCode session. Four of them take a model selection: t3_thread_launch, t3_thread_configure, t3_project_create and t3_project_update. In those four, provider, instanceId, model and options are {} or anyOf: [{}, {type: "null"}]. The cause is ModelSelectionSource in packages/contracts/src/modelSelection.ts, which declares all four fields as Schema.Unknown.

Google AI Studio accepts the same request. Without the Vertex pin, AI Gateway therefore falls back from Vertex to Google AI Studio and the turn runs, but on a different provider and billing account. We noticed this because our Vertex credits stopped being used.

The other 79 T3 Code MCP tools give every field a type.

Impact

Blocks work completely

Version or commit

T3 Code (Beta) desktop 0.1.0; the same schema is on main @ 1451e7cb

Environment

macOS 26.2, T3 Code (Beta) desktop 0.1.0, OpenCode 1.19.3, google/gemini-4-argon through Vercel AI Gateway restricted to Vertex AI

Logs or stack traces

shell
1GatewayInternalServerError: Unable to submit request because `t3-code_t3_project_create` functionDeclaration `parameters.defaultModelSelection.options` schema didn't specify the schema type field. Learn more: https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling

Screenshots, recordings, or supporting files

No response

Workaround

Drop the four tools from Gemini requests before they leave OpenCode, for example with an OpenCode plugin. Or use Google AI Studio instead of Vertex AI.

Synced from GitHub

Fix proposed in #21656: it gives the four ModelSelectionSource fields JSON Schema types, and decoding accepts the same inputs as before.

Note

Grok responding on behalf of Julius.

Confirmed on main, so this is accepted as a bug. ModelSelection decodes from a loose source struct whose provider, instanceId, model and options fields are all Schema.Unknown (modelSelection.ts:15-20). It then converts that into a typed wire shape (modelSelection.ts:9-13 and 22-50). MCP tools advertise Tool.getJsonSchema of their parameters as-is, with no normalizing step (McpHttpServer.ts:470 and 656). So the encoded side, with its untyped fields, is what clients see. This affects t3_thread_launch (project/tools.ts:117), t3_thread_configure (thread/tools.ts:198), and t3_project_create and t3_project_update, through defaultModelSelection (project.ts:189 and 197).

{} is valid JSON Schema, and Vertex rejecting it is a strictness of Vertex, but these are schemas T3 Code advertises. Google AI Studio accepting the same request, as you noted, is the current workaround.

Triage on Linux at main 70e5e384da: the four ModelSelectionSource fields still use Schema.Unknown. This is source inspection, not a live Vertex reproduction. No duplicate found in the open-issue scan for Vertex, schema type, model selection, and the reported error. The existing fix PR #21656 remains open. Stopping automated implementation because changing the advertised MCP tool schema requires maintainer handling under this triage flow. Leaving the issue open.

Fresh triage under the revised brief: the previous MCP-surface stop no longer applies. On Linux at main 8acbefefc5, OpenCode 1.18.18 has zero configured credentials. Running opencode run --model vercel/google/gemini-4-argon "Reply with ok" failed before reaching Vertex with UnknownError, reference err_9062e17c. No AI Gateway or Google credentials are configured here, so this is not a live reproduction of the reported rejection. The source still has the four unknown fields. Existing fix #21656 is preserved; leaving both open. No additional reporter information is needed.

Synced from GitHub

Same failure with OpenCode's built-in google-vertex provider and a service account (no gateway), on T3 0.1.2-nightly.20261021.3473 with OpenCode 1.19.3:

  • opencode run -m google-vertex/gemini-4-argon "Reply OK" outside T3, with the same credentials and GOOGLE_CLOUD_LOCATION=global, succeeds.
  • The same model in a T3 OpenCode provider instance fails on the first turn: Unable to submit request because `t3-code_t3_project_create` functionDeclaration `parameters.defaultModelSelection.options` schema didn't specify the schema type field. (the reported field varies between options, provider and instanceId).

Workarounds that did not help, in case it matters for the fix or a stopgap:

  • "tools": {"t3-code_*": false} in the OpenCode config file (OPENCODE_CONFIG).
  • The same config passed as OPENCODE_CONFIG_CONTENT in the provider instance environment, also with "mcp": {"t3-code": {"enabled": false}}.

T3 attaches its MCP tools either way, so the only way to use Gemini on Vertex from a T3 thread today is #21656. A per-instance option to not attach T3's MCP tools would also unblock headless agents that don't need them.