You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
v1.18.21 repeatedly continues complete responses with finish=unknown #43939
OpenCode 1.18.21 can repeatedly continue a complete assistant response when the provider labels it finish=unknown.
With opencode/x-preview-f-free, the provider sometimes returns complete, usable text while reporting unknown and zero token usage. Since #43892 makes the prompt loop continue after every unknown finish, OpenCode submits another turn. If subsequent completed responses also end with unknown, the loop continues without a bound.
Sanitized event sequence from one run:
step_finish reason=unknown output_tokens=0 # five empty attempts
text bytes=44879 # complete, syntactically valid requested JSON
step_finish reason=unknown output_tokens=0
text bytes=50319 # redundant continuation
step_finish reason=unknown output_tokens=0
step_start # another continuation begins
The process remained active after the first complete response and had to be terminated. This can duplicate or corrupt output, hang unattended runs, and consume unbounded provider requests.
The empty-response case in #41469 and #43856 should be retried. This report concerns the distinct output-bearing case. The test added in #43895 covers unknown -> continuation -> stop; it does not cover a provider that returns complete text and continues to label the finish unknown.
Expected behavior: recovery from unknown must be bounded. An empty unknown may be retried, but a substantive output-bearing unknown must not cause unlimited automatic continuations.
Plugins
None.
OpenCode version
1.18.21
Steps to reproduce
Run a long, non-interactive request against a provider that can return usable output with an unknown finish, for example: opencode run --format json --model opencode/x-preview-f-free --variant high "Return one moderately long, self-contained JSON object as your entire response."
Inspect the JSON event stream.
When a complete text event is followed by step_finish reason=unknown, observe that OpenCode starts another model turn instead of completing the command.
If the provider labels the next response unknown as well, observe another continuation.
The provider behavior is intermittent. The event sequence above is from a captured occurrence.
Screenshot and/or share link
The sanitized event sequence is included above. The original response content is unrelated to the transport failure and cannot be shared.
Operating System
Windows 11 with Ubuntu 22.04.5 under WSL2 (kernel 6.6.87.2-microsoft-standard-WSL2)
Terminal
Non-interactive WSL2 shell invoking the OpenCode Windows CLI (opencode.exe)
dev continues every unknown finish after #43892, which recovers empty streams but also starts another model turn after a complete text response.
Plan: treat unknown as settled when the assistant already produced text and has no pending tool calls. Empty unknown still continues so dropped streams can recover. Reasoning-only stays open.
I'll open a PR with prompt + CLI regression tests.
Arguably, "cover a provider that returns complete text and continues to label the finish unknown" shouldn't be necessary because the provider is faulty.
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.
Activity
razectp commentedon Aug 22, 2026
I'll take this.
devcontinues everyunknownfinish after #43892, which recovers empty streams but also starts another model turn after a complete text response.Plan: treat
unknownas settled when the assistant already produced text and has no pending tool calls. Emptyunknownstill continues so dropped streams can recover. Reasoning-only stays open.I'll open a PR with prompt + CLI regression tests.
neuhaus commentedon Aug 22, 2026
Arguably, "cover a provider that returns complete text and continues to label the finish unknown" shouldn't be necessary because the provider is faulty.
thdxr commentedon Oct 11, 2026
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 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊