Skip to content

opencode-go / deepseek-v4.1-flash: repeated AI_APICallError: Bad Request mid-session (opaque 400) #51477

Closed as not planned

Description

@antacheikh21-ship-it

Description

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)

Evidence (from ~/.local/share/opencode/log/opencode.log)

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

  1. Start a session using model deepseek-v4.1-flash via provider opencode-go.
  2. Send messages until the session grows (context/tool output accumulates).
  3. 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.

Activity

  1. github-actions commented on Sep 26, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    • #51201: Same opencode-go/deepseek-v4.1-flash opaque 400 body in long sessions, with identical request bytes sometimes succeeding on replay.
    • #51434: Same model and {"model":"deepseek-v4.1-flash"} rejection, occurring intermittently after tool-use turns.
    • #48093: Similar opaque 400 in a continuing long session on the earlier deepseek-v4-flash model.
  2. SamSpiri commented on Sep 29, 2026

    @SamSpiri

    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, 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.

  3. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    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 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions