Follow Discord
Sweep 27 Oct 2026 · 19:04Z Build v2.1.312 531 read Stable v2.1.308 Latest v2.1.312 Next v2.1.312 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One change · api

compaction-keep-recent-turns changedbuild-with-claude/compaction-keep-recent-turns

Nearest release: v2.1.312, published under an hour before this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.

Recorded here
Lines+2added
Lines−2removed
From line 491 where the diff opens
First seen 21 Sep 2026 this site's first read of the page
Recorded edits9to this page, all time

The whole hunk

from line 491, old and new numbered
/
lines
from line 491
491491* **Picking the cut:** The program keeps the last two turns, where a turn is one `user` message and the reply to it. It splits the history four messages from the end, so the kept turns start with a `user` message.
492492* **Deciding when to compact:** The size check also requires that the conversation has more turns than the program keeps, so the older part is never empty.
493493* **The compaction request:** Where the loop sends the whole history, this version sends only the older messages.
494* **The swap:** Where the loop replaces the whole history with the returned message, this version's new history is the returned message followed by the kept turns.
494* **The swap:** Where the loop replaces the whole history with the returned message, this version’s new history is the returned message followed by the kept turns.
495495 
496496The `stop_reason` check and every request after the swap are unchanged from the loop.
497497 
from line 499
499499 
500500If you send thinking blocks back on a model with [preserved thinking](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking), the thinking in the kept turns stays valid only while the [conditions for kept thinking](https://platform.claude.com/docs/en/build-with-claude/compaction-thinking-blocks#conditions-for-kept-thinking-to-stay-valid) hold, and one of them limits where the cut can fall.
501501 
502The program's cut, between a reply and the next `user` message, meets that condition. So does a cut at the end of a request you already made: compact exactly that request's `messages`, and keep everything your history has gained since.
502The program’s cut, between a reply and the next `user` message, meets that condition. So does a cut at the end of a request you already made: compact exactly that request’s `messages`, and keep everything your history has gained since.
503503 
Feedback