anomalyco / anomalyco/opencode
Session silently stops on empty LLM response (finish: unknown, 0 tokens)
@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.tsbreaks on any finish that isn'ttool-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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.