Skip to content

compaction: hold the next pass when the last one bought no room - #1687

Merged
justrach merged 1 commit into
mainfrom
fix/compact-no-progress
Oct 20, 2026
Merged

justrach merged 1 commit into
mainfrom
fix/compact-no-progress

Conversation

@justrach

Copy link
Copy Markdown
Owner

Fixes #1686.

Root cause

An automatic compaction that left the context over the compaction point fired again on the next step. That happens when the provider's compacted state, or a summary that must keep a long live turn verbatim, can't get under the line. Every step then paid a compaction, and the model reread what it had just lost. The existing stall guard (#706) only catches repeated cuts at the same history boundary. A compaction that "succeeds" but leaves the context over the line rewrites history, so the guard reset on every pass.

Fix

  • New compact_backoff.zig. If the pre-send gate is still over the line within one step of a history rewrite, the next compaction is held until the context grows by a twentieth of the window.
  • The 95% wall always compacts, so recovery may trim as before. Real relief (the context drops under the line) ends the hold.
  • The in-stream server compaction directive uses the same raised threshold while holding, so the server doesn't compact on every request either.
  • A held pass is noted in the trace, and outside JSON mode it prints one line.

Tests

  • compact_backoff: hold after a no-room compaction, release on growth, the 95% wall and real relief end a hold, and a compaction that bought several steps is not treated as a stall.
  • Compaction, directive and turn unit tests: 250 pass.
  • Tier-1 pre-push gate is green.

An automatic compaction that left the context over the compaction point
fired again on the next step. When the provider's compacted state, or a
summary that must keep a long live turn verbatim, could not get under the
line, every step paid a compaction and the model reread what it had just
lost.

A compaction that leaves the context over the line within one step now
holds the next one until the context grows by a twentieth of the window,
or reaches the 95% wall where recovery may trim. The in-stream server
directive uses the same raised threshold while holding, so the server
does not compact on every request either.

Fixes #1686
@justrach
justrach merged commit b46ff0e into main Oct 20, 2026
8 of 9 checks passed
@justrach
justrach deleted the fix/compact-no-progress branch October 20, 2026 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ACP turn repeatedly compacts and rereads unchanged files for 47 minutes

1 participant