Repository navigation
Description
Description
Using Google Gemini 3.8 Flash via the Gemini API (https://aiplatform.googleapis.com/v1beta1/.../models/gemini-3.8-flash:streamGenerateContent?alt=sse), the request fails with 400 INVALID_ARGUMENT:
Requests ending with a model turn are not supported.
isRetryable: false, so the session hard-fails (a session.error event is emitted, session ses_f99077bd3ffekifM3UhsAgnIpk, project 2acd036c175137252d8b8a07a3ea82d0fe0658a3) and the only way to continue is to type a new prompt.
The cause is the projected conversation history being sent with the last contents entry as a model (assistant) turn. Gemini rejects any request whose contents ends with a model role. This surfaces after the model finishes answering / thinking, and the history is reloaded with an assistant-only tail — e.g. on the next prompt, after an interrupted stream, or via a continue/auto-continue path.
Same root cause as the already-open #45359 (reproduced on gemini-3.7-flash); it also reproduces on gemini-3.8-flash.
Plugins
Unknown / not provided in the error payload.
OpenCode version
Unknown from the error payload (please confirm).
Steps to reproduce
- Configure the Google/Gemini provider and select
gemini-3.8-flash. - Run a normal session and let the model finish its answer (complete a model turn).
- On the next prompt, the stream returns 400
Requests ending with a model turn are not supported. - Only typing a fresh prompt lets the conversation continue.
Screenshot and/or share link
No response — see the error payload below.
Operating System
Unknown from the error payload.
Terminal
Unknown from the error payload.
Error payload
{
"directory": "/workspace/xxx",
"project": "2acd036c175137252d8b8a07a3ea82d0fe0658a3",
"payload": {
"id": "evt_067152aee001TL0iqoRHGvPa9n",
"type": "session.error",
"properties": {
"sessionID": "ses_f99077bd3ffekifM3UhsAgnIpk",
"error": {
"name": "APIError",
"data": {
"message": "Requests ending with a model turn are not supported.",
"statusCode": 400,
"isRetryable": false,
"responseHeaders": {
"alt-svc": "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000",
"content-length": "142",
"content-type": "text/event-stream",
"date": "Thu, 03 Sep 2026 11:43:55 GMT",
"server": "scaffolding on HTTPServer2",
"vary": "Origin, X-Origin, Referer",
"x-content-type-options": "nosniff",
"x-frame-options": "SAMEORIGIN",
"x-xss-protection": "0"
},
"responseBody": "{\n \"error\": {\n \"code\": 400,\n \"message\": \"Requests ending with a model turn are not supported.\",\n \"status\": \"INVALID_ARGUMENT\"\n }\n}\n",
"metadata": {
"url": "https://aiplatform.googleapis.com/v1beta1/projects/XXXX/locations/global/publishers/google/models/gemini-3.8-flash:streamGenerateContent?alt=sse"
}
}
}
}
}
}
Activity
github-actions commentedon Sep 3, 2026
This issue might be a duplicate of existing issues. Please check:
Since you've already identified #45359 as the same root cause, this issue may be tracked there. A maintainer will review whether this should be merged into that issue or tracked separately (e.g., to cover gemini-3.8-flash specifically).
rekram1-node commentedon Sep 3, 2026
can u export session?
opencode export > session.jsongabriel-macherini commentedon Sep 3, 2026
same problem. looks like the model try to think and fails on that. Or maybe is related with high demand right now.
esafak commentedon Sep 4, 2026
is the session file safe to share here or should I pm you in DIscord?
gabriel-macherini commentedon Sep 9, 2026
I got a free tier from from my bank. This account is named Google AI Plus (400 GB). This gives you the right to generate an API key, but this key is restrict request for 5 per minute. So the thing works until you ask for something that need several request tools and breaks. This is not true when you are using the antigravity app. there you can make as many calls you want, but the quota still very low. So i just want to give some head ups about this because I did some digging. Maybe worth let some others opencode users know about this. Anyway, I love opencode, keep updating it!
rekram1-node commentedon Sep 29, 2026
fixed on opencode v2: https://opencode.ai/v2/docs
shuqingzai commentedon Sep 29, 2026
Hi @rekram1-node
Will v1 be updated simultaneously, or is it just v2? The v2 ecosystem isn't mature yet, and many users haven't switched over to it.