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
opencode run exits as if complete when a step finishes reason "length" with zero output #42900
When a step finishes with reason: "length", output: 0, no tool call and no assistant text, opencode run treats the run as complete: the process exits and the transcript simply stops. In-flight work is lost, and to a process-liveness supervisor it is indistinguishable from a normal finish (ours logged "FINISHED clean" for two such deaths).
This happens when a thinking-capable model spends its entire limit.output budget on reasoning tokens. The turn is exhausted, not finished — there is no answer, no tool call, no stop reason from the model.
Cost in practice: one death lost 59 uncommitted edits across 22 files, ~50 minutes in, four tests from green. Frequency here is roughly 1 in 10 long headless runs.
Raising limit.output does not fix it. After raising the cap 8192 → 16384 → 32768, runs died at 8,191 / 16,383 / 31,999 reasoning tokens respectively, each with zero output — a runaway turn consumes essentially the whole budget whatever it is, so raising the cap only buys more wasted generation per death. Healthy steps in the same runs use 30–730 reasoning tokens, two orders of magnitude below the ceiling, so there is no gradual signal to alert on.
The recovery path already exists and works. After one such death, opencode run --session <id> "<continue instruction>" resumed with the full prior context and completed the task with no re-verification. run just never takes that path itself.
Suggested fix
On a step finishing reason == "length" with zero output tokens and no tool call, continue the session (optionally a bounded retry with a log line) instead of exiting as complete. Failing that, a distinct non-zero exit status would at least let supervising scripts react — today they cannot tell it from success.
Steps to reproduce
Point opencode at a thinking-capable model via LM Studio (OpenAI-compatible provider) with limit.output set.
Run headless: opencode run --format json --dir <workdir> "<task that asks for a long composed document>".
Intermittently a step finishes reason: "length" with output: 0 and no tool call; the process exits and the run is over.
Asking for a large document in a single turn makes it substantially more likely — that is when the model is most apt to think past the ceiling.
Duplicate of #17471 (same root cause and fix) and #18108 (same code path, prompt.ts:698-699). I've moved the distinct evidence — the zero-output reasoning-burn variant, the headless silent-exit behaviour, and the measurement showing cap-raising does not help — into a comment on #17471 rather than leaving a third issue open. Apologies for the noise.
Activity
github-actions commentedon Aug 16, 2026
This issue might be a duplicate of existing issues. Please check:
finish_reason: "length"is hit — same root behavior and the same suggested fix (inject a synthetic "continue" and re-enter the loop).finishReason: "length"being treated as normal completion causing silent session exit (see failure point 4 and P1 in that issue), with overlapping root-cause analysis and proposed fixes.njhillson commentedon Aug 16, 2026
Duplicate of #17471 (same root cause and fix) and #18108 (same code path, prompt.ts:698-699). I've moved the distinct evidence — the zero-output reasoning-burn variant, the headless silent-exit behaviour, and the measurement showing cap-raising does not help — into a comment on #17471 rather than leaving a third issue open. Apologies for the noise.