Skip to content

fix(compaction): drop thinking blocks from the live tail - #1316

Closed
TheGreatAxios wants to merge 1 commit into
cl-9902-keep-compaction-growth-latch-after-under-threshold-foldsfrom
cl-9899-compact-occupancy-from-60-down-to-under-10
Closed

TheGreatAxios wants to merge 1 commit into
cl-9902-keep-compaction-growth-latch-after-under-threshold-foldsfrom
cl-9899-compact-occupancy-from-60-down-to-under-10

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Collaborator

Summary

  • The live tail drops thinking and redacted_thinking blocks so uncapped newest-pair thinking cannot pin post-fold occupancy near 45%. Full thinking stays in the archived transcript.
  • Thinking-only live turns become the existing [thinking-only turn omitted] marker so adapters do not 400 on empty content. Newest tool-call/result pairs still stay for resume.
  • Compact records and telemetry now include live_tokens (post-fold live-turn estimate). Tail budget stays 2500.

On a 40k-token thinking fixture: origin/main and the latch-only branch keep 40,144 live tokens with thinking; this branch folds to 2,375 live tokens (under 10% of 128k).

Verification

  • bun test src/context-compactor.test.ts src/session/compactor-pairing.test.ts — 45 pass
  • Compaction baseline: bun test ./evals/compaction/metrics.test.ts ./e2e/compaction-baseline.test.ts pass
  • Occupancy eval vs origin/main and CL-9902 on the same 40k-token thinking fixture (main/9902: 40144 live tokens + thinking; this branch: 2375, no thinking)

Fixes CL-9899

Uncapped thinking on the newest pair was pinning post-fold occupancy
near 45%. The live copy drops thinking and redacted_thinking; the
archive keeps the full bodies. Thinking-only turns become the existing
omitted marker so adapters do not 400 on empty content.
@linear-code

linear-code Bot commented Oct 4, 2026

Copy link
Copy Markdown

CL-9899

@TheGreatAxios TheGreatAxios left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review · Comment

Live tail drops thinking/redacted_thinking so a 40k-token thinking fixture folds from 40,144 live tokens (main / #1315) to 2,375. Newest tool pair stays; thinking-only turns become THINKING_ONLY_OMITTED. Warden: approve. Planner: hold-with-follow-up.

Findings

  • src/session/compactor.ts:731 — excerptTailTurn also strips thinking from the newest assistant that still has tool_call. Anthropic requires that thinking beside tool_use on the post-compact continuation. This is a known follow-up (do not reverse the occupancy drop; do not excerpt thinking). Follow-up: https://linear.app/abklabs/issue/CL-9904

bun test src/context-compactor.test.ts src/session/compactor-pairing.test.ts — 45 pass. Compaction baseline e2e/metrics pass. Occupancy eval vs origin/main: 40144 with thinking vs 2375 without.

@TheGreatAxios
TheGreatAxios deleted the branch cl-9902-keep-compaction-growth-latch-after-under-threshold-folds October 5, 2026 01:44
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