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
The opencode-go provider session repeatedly fails with AI_APICallError: Bad Request when using the model deepseek-v4.1-flash. The error happens mid-session (not on first message) and recurs every session.
Error
AI_APICallError: Bad Request
{"model":"deepseek-v4.1-flash"}
Stack trace from log:
AI_APICallError: Bad Request
at <anonymous> (/$bunfs/root/chunk-cxy6gyp0.js:6:14455)
at async <anonymous> (/$bunfs/root/chunk-cxy6gyp0.js:6:12790)
at processTicksAndRejections (native:7:39)
level=ERROR message="stream error" providerID=opencode-go modelID=deepseek-v4.1-flash agent=build mode=primary error.error="AI_APICallError: Bad Request"
Occurred repeatedly at 09:51:58, 10:03:25, 10:31:54 on the same session (ses_f2410c936ffenWMq7qKa5Auwfx), including after prior successful messages in the same session.
Environment
opencode version: 1.18.32
Provider: opencode-go
Model: deepseek-v4.1-flash
Runtime selected: llm.runtime=ai-sdk
OS: Linux
Install path: ~/.opencode/bin/opencode
Steps to reproduce
Start a session using model deepseek-v4.1-flash via provider opencode-go.
Send messages until the session grows (context/tool output accumulates).
Observe intermittent Bad Request stream errors, eventually the session becomes unusable.
Expected behavior
Requests succeed, or if the payload is invalid, a descriptive error is returned (which field/param caused the 400) instead of an opaque Bad Request.
Additional context
The error appears tied to conversation state/size rather than the initial request.
No plugin involved; config is minimal.
The raw 400 body only echoes {"model":"deepseek-v4.1-flash"} and no server-side reason.
Request
Please surface the upstream 400 response body/reason so users can tell whether it's an unsupported parameter, context length, or malformed tool-call payload sent by the ai-sdk runtime.
Reacted by Y-m, taoria, Yangguang Li, euwbah and Simon Spiridonov
Matches only: provider opencode-go, model deepseek-v4-flash / deepseek-v4.1-flash (any variant), status 400, type provider.invalid-request, and a message carrying no upstream reason — the Provider request failed with HTTP 400 fallback, a bare Bad Request, or the raw {"model":"..."} body. Two extra attempts, 3 s then 9 s. Anything with a real reason is left terminal.
Caveat on my own testing: it has not fired yet, and it cannot be made to. The rate is a few percent of turns, so I would rather have a signal from someone who hits this often. What you would see on a recovery is a retry countdown on the turn instead of the session stopping.
The related gap this works around, not fixes, is that the 31-byte body is dropped when the error is persisted, so nothing after the fact can recover the cause.
Activity
github-actions commentedon Sep 26, 2026
This issue might be a duplicate of existing issues. Please check:
opencode-go/deepseek-v4.1-flashopaque 400 body in long sessions, with identical request bytes sometimes succeeding on replay.{"model":"deepseek-v4.1-flash"}rejection, occurring intermittently after tool-use turns.deepseek-v4-flashmodel.SamSpiri commentedon Sep 29, 2026
Same opaque mid-session 400 as the others in this cluster. Client-side retry for it, looking for testers:
https://github.com/SamSpiri/opencode-go-stub-400-retry
Matches only: provider
opencode-go, modeldeepseek-v4-flash/deepseek-v4.1-flash(any variant), status 400, typeprovider.invalid-request, and a message carrying no upstream reason — theProvider request failed with HTTP 400fallback, a bareBad Request, or the raw{"model":"..."}body. Two extra attempts, 3 s then 9 s. Anything with a real reason is left terminal.Caveat on my own testing: it has not fired yet, and it cannot be made to. The rate is a few percent of turns, so I would rather have a signal from someone who hits this often. What you would see on a recovery is a retry countdown on the turn instead of the session stopping.
The related gap this works around, not fixes, is that the 31-byte body is dropped when the error is persisted, so nothing after the fact can recover the cause.
thdxr commentedon Oct 11, 2026
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (
opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊