Claude Code Pauseless Context Compaction: Asynchronous Background Compaction, Automatic Handoffs and Working With the Lid Closed
Claude Code does not ship a native pauseless compaction mode. Claude Burst, an open source local gateway, adds one. When a session passes a threshold, defaulting to 400k tokens, it summarises older history in a background request, then swaps the summary in on your next prompt, so you never wait.
Claude Code has no native pauseless compaction mode: its own /compact, and the automatic compaction it runs as a conversation approaches the end of the context window, both stop the session while the summary is written. Pauseless context compaction is an open source feature of Claude Burst, a local gateway that sits between Claude Code and Anthropic on your Mac, which makes compaction asynchronous: the summary is written in a separate background request while you carry on working, instead of synchronously with your session waiting on it. This post covers how it works, what it cannot do, what it saved in its first day of real use, and two supporting features that make long unattended sessions practical: automatic session handoffs and keeping Claude Code running with the laptop lid closed.
1. Why long sessions are worth compacting early
Every turn in a Claude Code session resends the whole conversation to the model. Prompt caching turns most of that resend into cache reads, which are billed at a fraction of the normal input rate, but the cache read component still scales with the size of the context: at the same rate, 400k cached tokens cost four times what 100k cached tokens cost. Output tokens, uncached input and cache writes also contribute to each request, so this does not mean a whole request at 400k costs four times one at 100k, and on a Pro or Max subscription the effect on how long your usage allowance lasts has not been measured directly. What is clear is that a large context makes every turn process far more tokens than a small one, for as long as the session stays large.
Claude Code’s built in compaction tends to run late, near the end of the window, which means a long session spends many turns carrying a very large context before anything reduces it, and when compaction does run, you wait for it. The pattern that would help is to compact earlier, while the context is still a manageable size, and to do it somewhere you never have to wait.
2. What pauseless context compaction does: asynchronous summaries
Because every request Claude Code sends to Anthropic passes through the Burst gateway, the gateway can see how large each session’s context has become and can change what is sent upstream without Claude Code knowing.
When a session’s context passes a threshold, 400k tokens by default, Burst sends one asynchronous background request on your subscription, using that session’s own login, asking the same model to summarise everything before your latest prompt. That request takes about forty seconds, and because it runs asynchronously, alongside your session rather than in front of it, nothing in your session is blocked while it runs. From your next prompt onwards, Burst sends the summary upstream in place of the older messages it covers. Claude Code keeps its complete local transcript and behaves exactly as before; the model sees a much shorter history.
You can see this happen in Claude Code’s own window. A UserPromptSubmit hook shows a line under the prompt you send when a summary starts, when it is ready, when it has cut the context, and when it fails or no longer fits, for example Claude Burst, pauseless compaction: done. Context down 88%, 666k → 78k. The line is shown to you and is not added to the model’s context, so it costs nothing.

3. What it cannot do
There are two limits worth understanding before you rely on it, and the first matters most for unattended work.
A finished summary is first applied only on a request that ends in a plain prompt from you, never partway through a round of tool calls, because swapping history mid round risks separating a tool call from its result. The consequence is that during a long autonomous tool loop, where the agent keeps working without you typing anything, the summary can be ready but unused until you next speak. The asynchronous summarisation never blocks you, but it does not by itself stop Claude Code’s native compaction from running during a long stretch of uninterrupted agent work.
The second limit follows from Claude Code never learning that Burst shortened the history, so its own copy of the conversation keeps growing. If Burst’s summary later stops fitting, for instance after a rewind, and Claude Code’s full copy has by then passed the context window, the full history is too big to send: Anthropic refuses it and Claude Code falls back to its own compaction, with the usual pause. The gateway log records which message changed, so the cause can be traced.
4. How it works under the hood
The design follows Anthropic’s documented keep tail pattern, in which an early portion of the conversation is replaced by a summary and the recent portion is kept as it was. The summary always ends at a plain user prompt, never at a tool result, so no tool call is summarised away from its own result, and the swap is only ever introduced at a prompt boundary, as described above.
The summary request resends the history exactly as Claude Code last sent it. That makes a cache hit possible rather than guaranteed: it depends on the cached prefix still being live, since Anthropic’s prompt cache has a limited lifetime, and on nothing earlier in the prompt having changed. In practice it made a large difference, because the first two summaries did not read the session from cache and the third, after the fix, did.
Two kinds of content are handled separately. The system reminder blocks at the start of the conversation, which carry your CLAUDE.md, skills and environment details, are carried across word for word, because a summary might paraphrase or drop an instruction that matters. Thinking blocks from turns before the swap are dropped. That is an implementation choice in Burst: those blocks were produced against a history that no longer exists, and because Anthropic’s handling of earlier thinking blocks varies by model, removing them is the conservative option. Turns produced after the swap keep their thinking as normal.
The gateway also knows when to step aside. If you run /clear or /compact, or rewind, the summary no longer matches the history Claude Code is sending, so Burst drops it and passes requests through untouched, and a dropped summary reopens the compaction window straight away. Otherwise a session is compacted at most once per window, sixty minutes by default, a failed summary is retried after five minutes, a warning is logged at a lower threshold of 300k tokens, and the state survives a restart of the gateway.
5. What it saved in its first day
The first real test was one long Opus 5.5 session that ran from 29 to 30 September 2026, over 306 requests. Burst produced three summaries, the largest taking the context from 611k tokens to 49k, and the model’s recall of earlier work held up in the rest of the session.
| Item | API equivalent |
|---|---|
| Context not resent | $30.57 |
| Less: three summaries | $5.27 |
| Less: extra cache writes | $0.19 |
| Net estimated saving | $25.11 |
The components are rounded; the dashboard, which calculates from unrounded values, shows $25.12. The summaries themselves cost $2.10, $2.96 and $0.21, the drop in the third being the cache fix described in section 4.
This is one session on one day, so it shows the mechanism and the order of magnitude rather than serving as a benchmark. Every figure is an API equivalent estimate: on a subscription nobody is billed these amounts, and the practical benefit is reduced context processing, whose effect on how long your allowance lasts would need to be measured separately.
The saving is an estimate under stated assumptions, not a guaranteed lower bound. A compacted request does not record what it would have sent without Burst, so the dashboard replays each session alongside a “without Burst” twin whose context grows exactly as the real session’s does, except that it never takes Burst’s reductions. The twin is compacted when it reaches 950k tokens, standing in for Claude Code’s own compaction near the end of its 1M window, since Claude Code does not publish its exact threshold, and requests just after that point count against Burst. The saving per request is the difference between twin and real context at the model’s cache read rate, and the net figure subtracts every summary and every extra cache write. Two assumptions pull in opposite directions. Not crediting back the cost of the twin’s own compactions makes that part of the estimate conservative. Assuming the twin grows all the way to 950k could overstate the saving, however, if Claude Code’s native context management, which Anthropic documents as clearing older tool outputs before it summarises, keeps a real session smaller than the twin assumes; the twin does not currently model that.
6. Automatic handoffs: HANDOFF.md written at close, read at start
Pauseless context compaction keeps a single session lean, but sessions still end. Session handover carries the working state from one session into the next without you writing a note to yourself. It is built from two Claude Code hooks that Burst installs from its dashboard, and it is opt in per repository: the hooks only act where the git root contains a HANDOFF.md file, so creating that file, even empty, switches a repository on.
When a session ends through /exit, Ctrl D, /clear or closing the Ghostty window, the SessionEnd hook launches a detached job in its own process session, so the window closing cannot kill it, and returns straight away rather than doing the slow work inside the hook’s limited execution time. That job resumes a fork of the finished session with a writer model you choose, has it prepend a dated section to HANDOFF.md covering the current state, what was done, what is open and what will bite the next person, and commits that one file locally. It never pushes. Sessions with fewer typed prompts than a configurable minimum are skipped, and a macOS notification says when the handoff is written.
When a new session starts, or after /clear, the SessionStart hook briefs Claude with the newest handoff section, the commits since HANDOFF.md last changed, git status and the repository layout, and tells it to skim the code the handoff names before answering.
Two timing details matter. First, the start hook does not wait for a writer that is still running, and writing takes around a minute, so after /clear the new session is briefed from the previous handoff rather than the one being written for the session you just cleared; that handoff lands in HANDOFF.md shortly afterwards, and concurrent writers in the same repository queue behind a lock rather than overwriting each other. Second, the handoff depends on the hook running: a normal exit or a closed window triggers it, but a crash or a forced kill of Claude Code may end the session without the hook ever launching the writer, in which case no handoff is written for that session.
The cost is roughly one extra turn of the session, because the writer rereads it once, and a cheaper writer model reduces that. Because handoffs are ordinary markdown committed to git, they also form a reviewable history of how the work progressed.
7. Working with the lid closed, and keeping Remote Control
Closing a MacBook’s lid normally puts it to sleep, which suspends a running Claude Code session. Burst’s lid closed mode keeps a session in Ghostty running after the lid is shut. It is off by default and has two power modes: ac, the default, stays awake with the lid shut only while plugged in, and always also stays awake on battery, which the dashboard asks you to confirm because a closed laptop in a bag that never sleeps runs hot and drains its battery. Either mode can be limited to a set time after the Mac was last used, so a session you walked away from does not keep a closed laptop awake all night.
Most of the obvious approaches do not work. caffeinate and pmset sleep 0 stop idle sleep but not clamshell sleep; the switch that does is pmset -a disablesleep 1, which needs root, and because it is one global value, the ac mode installs a small root LaunchDaemon that turns it on when you plug in and off when you unplug. Burst also disables App Nap for Ghostty, since with the lid shut every window is hidden, which is exactly when macOS throttles an app. The previous setting is restored on removal or uninstall, and claude-burst status reports any drift between what is configured and what the machine is doing.
Steering that session from your phone uses Claude Code’s Remote Control, and here the installation mode matters. Claude Code disables Remote Control whenever ANTHROPIC_BASE_URL names a host other than api.anthropic.com, and Burst’s default base-url mode sets exactly that variable, so in the default mode Remote Control does not work. To keep it, you need Burst’s transparent intercept mode, which leaves ANTHROPIC_BASE_URL unset and instead points api.anthropic.com at the gateway through /etc/hosts, terminating TLS with a locally generated certificate authority. Claude Code believes it is talking to Anthropic directly, so Remote Control keeps working. The trade is real: transparent mode needs root once, adds a local certificate authority, and affects every process on the Mac that talks to that hostname, so if the gateway is down, Anthropic is unreachable machine wide until it recovers or the mode is removed. The project recommends transparent mode for this reason, and ships watchdogs to repair the gateway and the redirect.
A closed laptop that leaves the house also loses home WiFi, and macOS will not join a phone’s hotspot on its own while nobody is at the Mac. Burst can detect that the Mac is offline and join a hotspot you choose, with configurable timing, the password held in the login Keychain, and a test on the dashboard that reports each step of the join.
8. How the pieces fit together
With transparent mode, lid closed mode and pauseless context compaction all on, you can start a long piece of work, close the lid and leave, and follow and steer the session from your phone through Remote Control. When you leave home WiFi, the Mac joins your hotspot. Each time you send a prompt from your phone, any finished summary is swapped in, so the session stays lean without stopping to compact. When the session ends, a handoff is written and committed for the next one.
Around all of this sits Burst’s original job, which is overflow: when Anthropic’s own rate limit headers say a model’s subscription allowance is exhausted, it routes that model’s requests to a paid secondary such as Together AI or Amazon Bedrock, and returns to the subscription when the limit resets.
9. Getting started
Claude Burst is MIT licensed and runs on macOS, on Apple Silicon or Intel. You need Go 1.23 or later to build it, and Claude Code logged in to a Pro or Max subscription; a metered Anthropic API key can be used as the primary route instead.
git clone https://github.com/andrewbakercloudscale/claude-burst.git
cd claude-burst
./install.sh
open http://127.0.0.1:7788The installer builds the binary locally and starts the gateway in the default base-url mode, which needs no root and is the simplest to try, but which disables Remote Control. If you want to steer sessions from your phone, switch to transparent mode:
claude-burst configure --intercept-mode transparent
claude-burst enable # generates and trusts the local CA
sudo scripts/transparent-root.sh install # the one root stepPauseless context compaction and session handover are switched on from their sections of the dashboard. Lid closed mode can be switched on there or from the command line:
claude-burst configure --keep-awake-lid-closed true # plugged in only (mode ac)
claude-burst status # confirm what is liveEvery change has an undo, including sudo scripts/transparent-root.sh remove and ./install.sh uninstall, which restores the previous sleep setting. The project describes itself as an experimental MVP, so try it on a non critical development account first. If you are considering it for a team, note that transparent mode and lid closed mode both change machine wide settings, and that a consumer subscription is not contractually equivalent to Claude for Work, the Claude API or Bedrock.
10. Frequently asked questions
10.1 Does Claude Code have pauseless context compaction built in?
No. Claude Code’s own compaction is synchronous: it pauses the session while the summary is written. Claude Burst adds asynchronous, pauseless context compaction as a local gateway feature, summarising in the background and swapping the summary in on your next prompt.
10.2 Does asynchronous compaction help during a long autonomous tool loop?
Only partly. The summary is written without blocking, but it is first applied when you next send a prompt, so a long stretch of agent work with no input from you can still reach Claude Code’s native compaction.
10.3 Does it change my local Claude Code transcript?
No. Claude Code keeps its full local history; only the request sent to Anthropic carries the summary. If you run /compact, /clear or rewind, Burst drops its summary and steps aside.
10.4 How do automatic Claude Code handoffs work?
Add a HANDOFF.md file to a repository’s git root. When a session ends normally, a hook has a model prepend a dated handoff section and commits it locally without pushing, and the next session is briefed from it. A crash or forced kill can skip the handoff.
10.5 Can I use Remote Control with Claude Code while the lid is closed?
Yes, with two settings: lid closed mode, which keeps the Mac awake with the lid shut, by default only while plugged in, and Burst’s transparent intercept mode, because Claude Code disables Remote Control whenever ANTHROPIC_BASE_URL points anywhere other than Anthropic, which the default mode does.