fix(cli): prevent compaction request replay loops - #13374
Merged
Conversation
This comment has been minimized.
This comment has been minimized.
…action-message-reinjection # Conflicts: # packages/opencode/src/session/prompt.ts
marius-kilocode
enabled auto-merge
August 27, 2026 10:23
Contributor
|
the only real concern I have is that slice().some(() => some()) in a for loop over the same list ... I am not sure that's the best we can do there to avoid choking on that part of the logic but if the list is always small enough maybe we don't care, in such case it would be nice to have a comment that states |
WebReflection
approved these changes
Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
Automatic compaction can turn an already-handled user request into a new request. The completed-response path passes
overflow: false, which the replay code treats as a pending preflight turn. This can repeat completed work and tool calls. The prior-usage preflight path has the opposite problem: it does not request replay, so a pending request can disappear behind the summary.Fixes #13323 and #13317.
Why This Change Was Made
Keep the fix at the existing compaction boundaries rather than add a new recovery system:
lengthfinish, preserving the correction from fix(cli): handle tool progress during compaction #13424.The final diff is four files: two runtime files, focused regressions in an existing Kilo-owned test file, and one patch changeset. It introduces no persisted schema fields, SDK changes, queue scheduler, UI changes, or import/fork machinery.
User Impact
Pending requests continue after automatic compaction without becoming a second visible user prompt. Completed answers and tool actions are not restarted merely because the context crossed its threshold. Preflight recovery preserves attachments; provider-overflow recovery retains the original attachment in storage while using the existing media placeholder on retry. The existing three-compaction safety cap remains in place.
Evidence
The focused regressions failed on the baseline: a pending request was absent from the outgoing context, a terminal response caused three model calls instead of one, and saved tool progress was excluded from the summary.
Validation of the simplified implementation:
integrity_checkreturnedok.ContextOverflowError.The live self-test used a deterministic local provider, not an external paid model. Internal synthetic replay rows remain stored by the existing replay mechanism; they are not additional visible user text. Broader crash-recovery and transcript redesign work is intentionally outside this PR.