Skip to content

v1.18.21 repeatedly continues complete responses with finish=unknown #43939

Description

@Hugo-Polloli

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

  1. 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."
  2. Inspect the JSON event stream.
  3. When a complete text event is followed by step_finish reason=unknown, observe that OpenCode starts another model turn instead of completing the command.
  4. 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)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions