Skip to content

feat: add double-buffer compaction for context window management#1203

Open
marklubin wants to merge 1 commit intoanthropics:mainfrom
marklubin:feat/double-buffer-compaction
Open

feat: add double-buffer compaction for context window management#1203
marklubin wants to merge 1 commit intoanthropics:mainfrom
marklubin:feat/double-buffer-compaction

Conversation

@marklubin
Copy link

Summary

Adds double-buffered context window compaction (sync + async). Background checkpoint at 70%, swap at 95%, stop-the-world fallback, configurable timeout, incremental summary accumulation with renewal policies.

Reference: https://marklubin.me/posts/hopping-context-windows/

Testing

44 unit tests pass.

AI Disclosure

Developed with Claude (Anthropic). All code reviewed, tested, and validated by the author.

Staging PR on fork — will open upstream PR from here when ready.

Proactive context compaction using double buffering: checkpoint at a
configurable threshold, continue working while summarization runs in
the background, then swap to the pre-built back buffer at the swap
threshold.

Includes checkpoint index tracking for correct concurrent-phase
mirroring, stop-the-world fallback with recent-tail preservation,
and optional renewal policies (recurse/dump).
@marklubin marklubin marked this pull request as ready for review February 25, 2026 08:04
@marklubin marklubin requested a review from a team as a code owner February 25, 2026 08:04
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