Description
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)
Description
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 reportingunknownand zero token usage. Since #43892 makes the prompt loop continue after everyunknownfinish, OpenCode submits another turn. If subsequent completed responses also end withunknown, the loop continues without a bound.Sanitized event sequence from one run:
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 finishunknown.Expected behavior: recovery from
unknownmust be bounded. An emptyunknownmay be retried, but a substantive output-bearingunknownmust not cause unlimited automatic continuations.Plugins
None.
OpenCode version
1.18.21
Steps to reproduce
unknownfinish, 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."step_finish reason=unknown, observe that OpenCode starts another model turn instead of completing the command.unknownas 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)