anomalyco / anomalyco/opencode
v1.18.21 repeatedly continues complete responses with finish=unknown
@jlongster is already working on this.
Since Aug 21, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
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
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." - 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
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)
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.