You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(provider): Copilot Gemini models fail to produce structured tool calls #15315
Copilot Gemini Flash models (e.g. gemini-3-flash-preview) cannot make structured tool calls. The model outputs plain-text descriptions like [tool_call: mirror-url ...] instead of structured tool_calls in the response.
Root cause
sanitizeGemini in ProviderTransform.schema() matches Copilot Gemini models via api.id.includes("gemini"). This transform is designed for Google's native Gemini API, but Copilot models use an OpenAI-compatible endpoint — the Copilot API handles Gemini schema conversion internally.
Two post-v1.1.49 commits added aggressive schema transforms that produce double-transformed schemas the Copilot translation layer can't handle:
I checked preserved local session history in ~/.local/share/opencode/opencode.db and found a concrete Copilot Gemini Flash example that matches this issue.
Representative stored example:
session: ses_2c99226d4ffeg3prz743ArLhvE
title: Fix cutoff UI & replace drilldown modal with dark Google Map
assistant message: msg_d3679e4d1001sB1zVNAbQmgVDM
The assistant text part contains pseudo-tool / planner text like:
<TodoWrite ... />
@explorer
but the stored message parts are only:
step-start
text
step-finish with reason = "stop"
There is no structured tool part for that message. So in this case Gemini/Copilot appears to emit tool intent as plain text instead of structured tool calls.
This looks distinct from #14972:
#14972: real tool part exists, but the loop stops anyway
this issue: no real tool part exists because Copilot Gemini emitted pseudo-tool text instead
I observed this in preserved local sessions on OpenCode 1.3.3/1.3.4. So this does not seem limited to custom providers; it also affects normal github-copilot / gemini-3-flash-preview usage.
i was testing about this as well on both gemini-3.1-pro and gemini-3-flash, and after some digging with gemini pro itself, it asserted:
The root cause is a known limitation of the Copilot session.send API pipeline: It completely ignores system instructions that
enforce schema.
When Vercel AI SDK calls generateObject in mode: 'json', it injects a system prompt asking the model to strictly follow your
provided JSON schema (which in our script was {"recipe": {"name": "...", "ingredients": [...]}}).
But look at what Gemini actually returns:
{
"title": "Toast",
"ingredients": [
"1 slice of bread"
],
"instructions": [
"Place the bread in a toaster and heat until golden brown."
]
}
It outputs valid JSON, but it invents its own schema (title, ingredients as an array of strings, instructions) completely
ignoring the schema the AI SDK requested. Because the fields don't match the Zod schema exactly, the SDK throws a
AI_NoObjectGeneratedError: response did not match schema.
As confirmed by my Exa search across the github/copilot-sdk issues, the GitHub Copilot API currently lacks a response_format:
{ type: "json_schema" } field on the backend (Issue #41 / #857). Until GitHub adds native structured_outputs: true support to
their proxy, any model routed through Copilot (including gemini-3.1-pro-preview) will be "deaf" to strict schema enforcement.
I am not sure it's at all related. And it could be github copilot gemini model degradation too. But basically lately GitHub Copilot gemini-3-flash-preview tasks often stop mid-way without any error or a reason. No questions asked, no explanation, just stops working on the task after some of it done but before finishing it up.
Copilot's gemini-3-flash-preview was working fine in opencode for a long time until recently.
As you can imagine it's hard to reproduce. But switching to copilot's sonnet works fine. So, it's gemini flash specific.
I can't say which opencode version was working fine. I thought it may be recent and reverted to 1.2.25 but that also has this issue.
I am not sure it's at all related. And it could be github copilot gemini model degradation too. But basically lately GitHub Copilot gemini-3-flash-preview tasks often stop mid-way without any error or a reason. No questions asked, no explanation, just stops working on the task after some of it done but before finishing it up. Copilot's gemini-3-flash-preview was working fine in opencode for a long time until recently. As you can imagine it's hard to reproduce. But switching to copilot's sonnet works fine. So, it's gemini flash specific. I can't say which opencode version was working fine. I thought it may be recent and reverted to 1.2.25 but that also has this issue.
I am pretty confident it's something Opencode, because if I use Gemini 3 Flash in VSCode this doesn't happen
You're seeing plain-text tool call outputs instead of structured tool_calls when using Copilot Gemini models like gemini-3-flash-preview. PathCourse Health handles OpenAI-compatible structured outputs natively so you don't have to build or maintain custom parsing and response transforms.
Activity
ll01 commentedon Mar 5, 2026
I'm facing a similar issue
thatdaveguy1 commentedon Mar 29, 2026
I checked preserved local session history in
~/.local/share/opencode/opencode.dband found a concrete Copilot Gemini Flash example that matches this issue.Representative stored example:
ses_2c99226d4ffeg3prz743ArLhvEFix cutoff UI & replace drilldown modal with dark Google Mapmsg_d3679e4d1001sB1zVNAbQmgVDMThe assistant text part contains pseudo-tool / planner text like:
<TodoWrite ... />@explorerbut the stored message parts are only:
step-starttextstep-finishwithreason = "stop"There is no structured
toolpart for that message. So in this case Gemini/Copilot appears to emit tool intent as plain text instead of structured tool calls.This looks distinct from
#14972:#14972: realtoolpart exists, but the loop stops anywaytoolpart exists because Copilot Gemini emitted pseudo-tool text insteadI observed this in preserved local sessions on OpenCode
1.3.3/1.3.4. So this does not seem limited to custom providers; it also affects normalgithub-copilot / gemini-3-flash-previewusage.sparticle9 commentedon Apr 1, 2026
i was testing about this as well on both gemini-3.1-pro and gemini-3-flash, and after some digging with gemini pro itself, it asserted:
The root cause is a known limitation of the Copilot session.send API pipeline: It completely ignores system instructions that
enforce schema.
When Vercel AI SDK calls generateObject in mode: 'json', it injects a system prompt asking the model to strictly follow your
provided JSON schema (which in our script was {"recipe": {"name": "...", "ingredients": [...]}}).
But look at what Gemini actually returns:
{ "title": "Toast", "ingredients": [ "1 slice of bread" ], "instructions": [ "Place the bread in a toaster and heat until golden brown." ] }It outputs valid JSON, but it invents its own schema (title, ingredients as an array of strings, instructions) completely
ignoring the schema the AI SDK requested. Because the fields don't match the Zod schema exactly, the SDK throws a
AI_NoObjectGeneratedError: response did not match schema.
As confirmed by my Exa search across the github/copilot-sdk issues, the GitHub Copilot API currently lacks a response_format:
{ type: "json_schema" } field on the backend (Issue #41 / #857). Until GitHub adds native structured_outputs: true support to
their proxy, any model routed through Copilot (including gemini-3.1-pro-preview) will be "deaf" to strict schema enforcement.
hrez commentedon Apr 4, 2026
I am not sure it's at all related. And it could be github copilot gemini model degradation too. But basically lately GitHub Copilot gemini-3-flash-preview tasks often stop mid-way without any error or a reason. No questions asked, no explanation, just stops working on the task after some of it done but before finishing it up.
Copilot's gemini-3-flash-preview was working fine in opencode for a long time until recently.
As you can imagine it's hard to reproduce. But switching to copilot's sonnet works fine. So, it's gemini flash specific.
I can't say which opencode version was working fine. I thought it may be recent and reverted to 1.2.25 but that also has this issue.
thatdaveguy1 commentedon Apr 4, 2026
I am pretty confident it's something Opencode, because if I use Gemini 3 Flash in VSCode this doesn't happen
alex-pathcourse commentedon May 11, 2026
You're seeing plain-text tool call outputs instead of structured
tool_callswhen using Copilot Gemini models likegemini-3-flash-preview. PathCourse Health handles OpenAI-compatible structured outputs natively so you don't have to build or maintain custom parsing and response transforms.Working example: https://github.com/pathcourse-health/pch-integration-examples#framework-adapters
MusabaN commentedon Jul 7, 2026
This is also happening with gemini flash 3.5
github-actions commentedon Sep 6, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.