Repository navigation
Description
Summary
When a model response is truncated by the generation token cap (finish: "length"), OpenCode ends the turn silently: no error, no assistant message, no auto-continue. The session goes idle with outcome: "succeeded" while the agent is mid-task. With always-reasoning models, the entire generation budget can be consumed by reasoning tokens alone (output: 0), so the turn ends before any tool call or text is produced — the agent appears to just "stop" partway through a task.
Environment
- opencode version: 2.0.18 (latest)
- OS: Windows_NT 10.0.26200 (win32 x64)
- Terminal: Unavailable: issue is server-side session behavior, not client-specific
- Shell: C:\WINDOWS\system32\cmd.exe
- Install/channel: desktop app CLI (
%APPDATA%\ai.opencode.desktop\cli\2.0.18\opencode-cli.exe) - Active plugins: none found
Reproduction
- Use an always-reasoning model whose endpoint applies a modest default
max_tokenswhen none is sent — observed withnebius/zai-org/GLM-5.3-Flash, varianthigh, no explicitmax_tokensoverride (default cap observed: 8192). - Start a multi-step agentic task requiring many tool calls (e.g. iterate on a design and implement it).
- Watch turns end: the assistant message contains only truncated
reasoning_content, finishes withlength, and the session silently goes idle. The agent does not continue and nothing indicates why.
Also reproducible with a raised cap: after adding providers.<provider>.models.<model>.body.max_tokens = 65536 (which worked and hot-reloaded without restart), the model consumed the entire 65536-token budget on reasoning (tokens: {input: 8275, output: 0, reasoning: 65536}) and the turn again ended silently with finish: "length".
Expected Behavior
- A truncated turn should be visible to the user — e.g. an assistant/system message stating the response was cut off at the max token limit — rather than a silent idle with
outcome: "succeeded". - Ideally, when a turn ends with
finish: "length"and no tool calls, OpenCode would auto-continue the step (or at least prompt to continue), since the agent is by definition incomplete.
Actual Behavior
Session message data for each stop shows an assistant message with content: [{type: "reasoning", ...}] (truncated mid-sentence), finish: "length", rawFinish: "length", tokens {output: 0, reasoning: <cap>}, followed immediately by an idle event with outcome: "succeeded". Server logs contain no ERROR/WARN for these turns, so there is no signal a turn was truncated.
Frequency: consistent — 5 occurrences across 2 sessions on 2026-10-08 (4 at the 8192 cap, 1 at the 65536 cap after the config override).
Additional Context
- Model context: GLM-5.3-Flash is "always-on reasoning" (reasoning cannot be disabled, only effort lowered), so at
higheffort the generation budget is exhausted byreasoning_contentbefore any tool call is emitted. - Workarounds that help but do not fix the UX: explicit
providers.<provider>.models.<model>.body.max_tokensoverride (verified: cap moved 8192 → 65536 with hot reload), lower reasoning-effort variant, or a stronger model. The silent stop itself remains whenever the budget is exhausted by reasoning. - The
outcome: "succeeded"idle event after a truncated turn is what makes this hard to diagnose: users see the agent stop with no error, and logs show nothing.
Activity
opencode-agent commentedon Oct 8, 2026
Thanks for the detailed report and the session data.
I think this is a duplicate of #50949. That issue covers a turn ending with
finish: "length"and no usable output being recorded as a success with no visible error, and a comment there reports the same reasoning-only case you hit (reasoning cut off at the cap, no text or tool call, session idle as succeeded).Possible duplicates and closely related issues, ordered from most to least likely:
lengthfinish with no usable output is treated as success. Its thread includes the reasoning-only variant on v2.max_tokenscase settling assucceeded. It was closed, but its fix PRs were never merged.lengthturns end assucceededon v2.0.18 in the TUI.finish_reason: "length".The open fix for #50949 (#51741) currently only handles steps with no text, no reasoning and no tool call at all, so your reasoning-only case is worth mentioning in #50949.
The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different.
opencode-agent commentedon Oct 9, 2026
Closing this as a duplicate of #50949, since there's been no reply in the last day saying how this problem is different. Thanks again for the detailed report and session data.
Please follow #50949 for updates. It would help to add a comment there with your reasoning-only case: GLM-5.3-Flash at
high, withtokens.output: 0and all reasoning tokens used at both the 8192 and 65536 caps. The open fix there (#51741) currently only handles turns with no text, no reasoning and no tool call, so your case would not be covered as written. Related: #46596, #51517 and #52015, plus #17471 for continuing automatically onlength.If this turns out to be a different problem, reply here and we can reopen it.