anomalyco / anomalyco/opencode

Session silently stops on empty LLM response (finish: unknown, 0 tokens)

Open
#41,469 16 comments 1 reaction 1 assignee View on GitHub

@kitlangton is already working on this.

Since Aug 10, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

When the model provider returns an empty completion (0 tokens, no text/reasoning/tool output, finish reason maps to unknown), opencode treats it as a normal completed turn:

  • the session loop exits silently (packages/opencode/src/session/prompt.ts breaks on any finish that isn't tool-calls)
  • no error is surfaced to the user, no retry happens
  • the conversation appears to "suddenly stop" mid-task

Observed with the opencode-go gateway (deepseek-v4-flash) returning an empty response: the session went idle with the last assistant message recorded as finish: unknown with 0 tokens.

Repro

  • Provider returns an SSE stream with no content/tool deltas and an unknown finish reason.
  • After processing, the loop exits and the session goes idle with no error.

Expected

An empty response should be retried (or surfaced as an error), not silently treated as a completed turn.

Related: #40531 (upstream PR with the same fix, currently conflicting with dev).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.