altimate-code icon indicating copy to clipboard operation
altimate-code copied to clipboard

Compaction writes two summaries per overflow, and its ledger misses files written by shell commands

Open RaghwendraSingh opened this issue 1 month ago • 0 comments

Problem

Two compaction defects in long sessions:

  • One context overflow produces two summaries. After a compaction that keeps a recent tail, the next loop iteration compacts again before sending any agent request. The second summary is built from only the kept tail (system + one tool step + instruction), so it replaces a full summary with a summary of the last few messages, and it costs an extra model call.
  • The compaction ledger misses files written by shell commands. The "Session state ledger" injected after compaction lists only files written by the write/edit/apply_patch tools. Files created or changed through bash (redirects, scripts, sed -i) appear only as "Shell commands also ran this session; any file changes they made are possible but unverified", so the continuing agent re-reads or re-creates files it already wrote.

Evidence

  • Real session (local opencode.db): compaction #1 at 08:20:48 kept a tail starting mid-turn; the continue message was written at 08:22:32.565 and compaction #2 was created at 08:22:32.570, 5 ms later, with no agent request in between. Summary #2 had 9,364 input tokens (tail only).
  • Local mock gateway, main at bdb7dcc7b9, an agent that runs echo step N >> notes.md for 10 steps with the context reported over the limit at steps 4 and 8: the request sequence is agent×4, summary, summary, agent×4, summary, summary, agent×3, so 4 summary calls for 2 overflows. The ledger never lists notes.md.

Expected

  • One overflow produces one summary.
  • The ledger lists files changed by shell commands, since the session already records per-step snapshot diffs (patch parts) that name them.

RaghwendraSingh avatar Nov 03 '26 10:11 RaghwendraSingh