compaction-background changedbuild-with-claude/compaction-background
Nearest release: v2.1.286, published an hour after 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+7added
Lines−1removed
From line
50
where the diff opens
First seen
21 Sep 2026
this site's first read of the page
Recorded edits6to this page, all time
The whole hunk
from line 50, old and new numbered
/
from line 50
5050
5151The compaction request counts against your rate limits like any other request, and while it runs your application has two requests open at once. The conversation keeps growing on its full history until the swap, so start the compaction request while the context window still has room for the turns that arrive meanwhile.
5252
53The following program is the loop from [Compact in a loop](https://platform.claude.com/docs/en/build-with-claude/compaction-on-demand#compact-in-a-loop) with the compaction request taken off the conversation's path. It has no PHP version, because the example depends on running two requests at once. The highlighted lines show where it differs from the loop, and the following list takes them in the order the program runs them.
53The following program is the loop from [Compact in a loop](https://platform.claude.com/docs/en/build-with-claude/compaction-on-demand#compact-in-a-loop) with the compaction request taken off the conversation's path. The highlighted lines show where it differs from the loop, and the following list takes them in the order the program runs them.
5454
5555<CodeGroup exclude="shell, php">
5656 ```python Python
from line 467
467467 client.close();
468468 }
469469 ```
470
471 <CodeGroupItem language="PHP">
472 <Note>
473 The PHP SDK sends requests synchronously, so it can't run the compaction request in the background while the conversation goes on.
474 </Note>
475 </CodeGroupItem>
470476
471477 ```ruby Ruby
472478 client = Anthropic::Client.new
No line in this hunk matches that.