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).
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:packages/opencode/src/session/prompt.tsbreaks on any finish that isn'ttool-calls)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: unknownwith 0 tokens.Repro
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).