Skip to content

opencode-go: "502 Cannot connect to API: The session has been destroyed" never recovers until the session is restarted #233

Description

@dgokcin

What happens

On an OpenCode Go model (clodex:opencode-go:deepseek-v4.1-flash, proxy mode), a turn
sometimes starts failing with:

502 Cannot connect to API: The session ha…  ·  Retrying in 26s  ·  attempt 9/10

(message is truncated in the TUI; it looks like The session has been destroyed)

It looks like the usual Anthropic "API temporarily overloaded" banner, but it behaves
differently: it never recovers. Claude Code burns through all 10 retries, and every
subsequent prompt in that session fails the same way. The only fix is to kill Claude Code
and start a new session — after the restart the exact same prompt works immediately.

So this is not the upstream being down: the connection state clodex is reusing appears to
be permanently poisoned for the lifetime of the process.

Expected

Either the connection is re-established transparently on the next attempt (like the
Anthropic path does), or the failure is at minimum recoverable without killing the session.

Notes

  • Happens intermittently, after the session has already been running a while.
  • Retries by Claude Code do not help — all 10 attempts produce the identical 502.
  • ~/.clodex/logs/inference-requests.jsonl has no 502 entries at all (only 200/400/401/403/404/429),
    so the error seems to be produced locally in clodex rather than being an upstream response
    being passed through.

Environment

  • clodex 2.11.6
  • Claude Code 2.1.269
  • provider: opencode-go, model deepseek-v4.1-flash
  • macOS (darwin 24.6.0)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions