anthropics / anthropics/claude-code

[FEATURE] Background compaction: keep the session running while the summary is produced

Offen
#93,732 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area:core enhancement performance
Vorherrschende Sprache
Python
Sterne
145k
Forks
23.1k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

### Preflight Checklist

- [x] I have searched [existing requests](https://github.com/anthropics/claude-code/issues?q=is%3Aissue%20label%3Aenhancement) and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)

### Problem Statement

Auto-compaction stops the session. Context fills, the conversation pauses, a summarization request goes out, and nothing else happens until it comes back. The wait scales with how much conversation there is to summarize and with how fast the provider answers, so the sessions that stall longest are the long ones I have the most invested in. On a slower model or a third party endpoint it is long enough to lose the thread of what I was doing, and it arrives unannounced in the middle of a task.

The cost is not the tokens. It is that a session I am actively working in goes silent at the least convenient moment.

### Proposed Solution

Compact on a snapshot, off to the side, while the session keeps running.

1. Arm early, at a configurable fraction of the context window rather than at the edge of it.
2. Take a boundary at the current end of the conversation and summarize everything before it in the background.
3. Keep answering against the full context while that runs. Nothing blocks.
4. When the summary lands, swap it in at the boundary and carry forward the turns that happened in the meantime.
5. If the window fills before the summary returns, fall back to blocking exactly as today.

A setting to control the arming point would cover people on slow providers who need a wider margin. `precomputeCompactionEnabled` already appears in `/config` on some installs as `Precompute compaction` and it shortens the wait, but it is absent from the settings documentation and it still leaves the session paused at the boundary. Documenting it and defaulting it on would help on its own, and it is the natural place to build the rest of this.

### Alternative Solutions

Running `/compact` by hand at a natural break moves the pause somewhere less disruptive, but it does not shorten it and it means watching the context meter instead of working. Setting `autoCompactEnabled` to false trades a pause for a hard stop. Splitting work across shorter sessions loses the context that made the long session worth having.

### Priority

High - Significant impact on productivity

### Feature Category

Performance and speed

### Use Case Example

I am four hours into a refactor across a large repository. Claude is partway through updating call sites when auto-compact fires. The session goes quiet, I switch to something else, and by the time it resumes I have to reread the transcript to work out where it was. With background compaction the summary is prepared while the edits continue, and the swap happens between turns without me noticing.

### Additional Context

Related requests, all now closed and locked, which is why this is a new issue rather than a comment: #23336, #11894, #26026, #43510, #46431, #51033, #52972.

The ordering constraint looks like the hard part. Turns that complete during compaction have to be reconciled against a summary produced from a conversation that no longer matches, and a naive swap would drop them. Falling back to a blocking compaction when the reconciliation is not safe seems better than getting it subtly wrong, since losing recent work silently is worse than waiting.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Start at the /config output and settings documentation, where precomputeCompactionEnabled is mentioned but undocumented; compare it with autoCompactEnabled and /compact behavior. Trace the existing auto-compaction boundary before designing snapshot/background work. Done means the session stays responsive during summarization, preserves turns completed meanwhile, and blocks as a fallback if the window fills first.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Bereich
cli, performance
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Aktiv
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.