Skip to content

CL-9007: ship shared summary-plus-small-tail pipeline for automatic and manual compaction - #1177

Merged
TheGreatAxios merged 3 commits into
mainfrom
cl-9007-ship-shared-summary-plus-small-tail-pipeline-for-automatic
Sep 27, 2026
Merged

TheGreatAxios merged 3 commits into
mainfrom
cl-9007-ship-shared-summary-plus-small-tail-pipeline-for-automatic

Conversation

@TheGreatAxios

@TheGreatAxios TheGreatAxios commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Shared budgeted-tail pipeline for automatic and manual compaction: both funnel through capabilities.compact(pruning-compactor), so one pipeline change covers both.

What changes:

  • Folds keep a structured handoff summary plus a small live tail (~7500-token default budget, ~5-10k tokens) instead of the last-N-verbatim keep window. keepRecentTurns stays as the legacy floor only.
  • Tail tool outputs ride head/tail excerpted with a visible sentinel, original/kept lengths; full bytes stay stored (archive blob / adopted handoff file) and are never rewritten by excerpting. Excerpting is idempotent across repeat folds.
  • When the keep-set covers everything foldable, apply still emits those excerpted live copies rather than the unexcerpted turns, so a short-but-bulky first compact does not keep the occupancy that armed it. No empty summary is invented.
  • Re-excerpt skip matches the structured [tail-shortened N→ marker, not a raw prefix substring.
  • Cuts never split a tool pair (whole-or-nothing partner drag); newest user messages with attachments stay whole up to the budget.
  • Repeat folds pass the prior spine as priorSummary (update, don't restack) and carry the live tail forward; prior spines fold into the next handoff. Spine goal falls back to the fold narrative (minus the verify-repair appendix) when no user text was folded.
  • record carries parameters.compactionShape plus decisions tailBudgetTokens/tailTokenEstimate/shortenedToolOutputs for the CL-9006 governor.
  • Result-carrying turns no longer fuse into neighboring text turns, so excerpts stay independently budgetable; the budget-swallow early return keeps eager image aging (turns + spill blobs).
  • SessionPruningCompactorArgs gains an optional compactionShape override (production default unchanged); integration harness forwards a test override.

Not in scope (per brief): governor thresholds/arming untouched, no per-family tuning, no archive storage migration, no second compactor.

Verification:

  • bun run typecheck exit 0
  • Compaction suites: 253 pass, 0 fail
  • bun test ./src ./tests ./evals ./scripts --randomize --seed 424242 -> 8037 pass, 0 fail
  • bun run lint -> 0 warnings, 0 errors
  • Governor seam suite (src/agent/compaction.test.ts) shows no behavior change

Fixes CL-9007

Red state for the shared summary-plus-small-tail pipeline: tail budget with shortened tool outputs, pair-safe cuts, whole newest user messages, repeat folds updating the prior summary, and archive retrievability. These fail against the last-N-verbatim keep window.
Route every pruning-compactor fold through one budgeted tail selector: the tail holds at least the last keepRecentTurns turns and extends older while the next whole pick fits tailBudgetTokens. Tail tool outputs ride head/tail excerpted with a sentinel; cuts never split a tool pair; newest user messages stay whole; prior spines fold into the next handoff while the summary updates them via priorSummary.
@linear-code

linear-code Bot commented Sep 25, 2026

Copy link
Copy Markdown

CL-9007

A keep-set that covers every foldable turn still has to ship the
excerpted live copies the tail selector already paid for. Returning
the unexcerpted turns keeps the occupancy that armed the compact.

Skip re-excerpting only on the structured marker so a body that
merely mentions the prefix is still shortened.
@TheGreatAxios
TheGreatAxios merged commit 8ca97f1 into main Sep 27, 2026
13 checks passed
@TheGreatAxios
TheGreatAxios deleted the cl-9007-ship-shared-summary-plus-small-tail-pipeline-for-automatic branch September 27, 2026 22:27
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.

1 participant