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
bug: recover context-limited length completions before durable output #44609
A provider can return reason: "length" before durable assistant output when the prompt plus the configured output budget exceeds the model context window. The session runner currently persists that length finish and stops instead of compacting the context and retrying.
Reproduction
With a model limit of context = 20_000 and output = 1_000, return a step-finish event with reason: "length", inputTokens: 19_900, and outputTokens: 40, without text, reasoning, or tool events. The runner makes one request; the expected sequence is original attempt, compaction summary, then retry.
A deterministic regression test on the unmodified source fails with:
Expected length: 3
Received length: 1
Proposed Fix
Treat that narrow event shape as recoverable only before an assistant message has started, then reuse the existing one-time overflow-compaction path. Do not retry when the response actually reached the configured output limit.
Verification
The failing-first regression and an output-limit guard test are included in the accompanying PR. The current Windows worktree cannot complete the green run because Bun reports EPERM while resolving existing .bun dependency links, before the test module reaches its assertions; the PR describes this limitation explicitly.
If your case is specifically the narrow pre-durable-output context-window overflow path (not general output-limit truncation), it may be worth referencing those issues in a PR to avoid re-solving overlapping mechanics.
Activity
github-actions commentedon Aug 24, 2026
This issue might be a duplicate of existing issues. Please check:
reason: "length"and zero output before any assistant content) — closed but the recovery path described there maps closely to the fix proposed herefinishReason: "length"treated as normal completion, session exits silently) with a broader scope covering tool-call truncation and doom loopsfinish_reason: "length"), which targets the same gap from the user-facing sideIf your case is specifically the narrow pre-durable-output context-window overflow path (not general output-limit truncation), it may be worth referencing those issues in a PR to avoid re-solving overlapping mechanics.
github-actions commentedon Oct 24, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.