Repository navigation
Compaction from the classic PreCompact hook; resumed subagents; Claude tested to 2.1.300 - #31
Merged
Merged
Conversation
Since Claude 2.1.299, the built-in sec-default mod sends session.compact straight to the append tier for every Team/Enterprise organization (and machine with managed settings), so no user mod, the tower's included, sees it. Automatic compactions then read as nothing until SessionStart source=compact. The classic PreCompact hook still fires before every compaction, manual or automatic, including one that gives up with no SessionStart (checked on 2.1.300). The mod declares PreCompact, and the fold takes it or session.compact as the start: outside an organization Claude raises both, and the second changes nothing. Only a manual compaction moves the status (working, then idle at its SessionStart). An automatic one already runs inside a working turn. Idle and precomputed compactions raise PreCompact with trigger auto (per the 2.1.300 binary), and a waiting worker must keep its wait rather than turn working. compact-auto and compact-manual are recorded again on 2.1.300 through PreCompact. The older recordings stay as *-outside-org, a Claude that raises session.compact.
Claude 2.1.299 raises agent.spawn again when SendMessage resumes a subagent whose turn ended, with resume.agentId and the same result.agentId. The fold appended a second run with that id, and runOf then added every resumed step's tokens to both. A spawn naming a run the log already holds now reopens it. A spawn naming one it never saw (resumed from an earlier session) starts a run as before.
The fixture set replays clean on 2.1.299 (LUCY-71's run) and the compaction fixtures are recorded on 2.1.300, with the fold now reading PreCompact and resumed subagents.
Claude Code 2.1.299 can compact a 200K+ token conversation after about 54 minutes idle. The worker keeps its wait, and its next turn starts from the summary. The tower leaves idleCompaction as Claude sets it.
…nd the 2.1.300 range Each suspect's claims were read against the branch: none names session.compact, a resumed subagent, or the tested release.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
PreCompacthook (3d469e1). The mod declaresPreCompactinhooks.json, andstatus.tstakesPreCompactorsession.compactas the start of a compaction. A Claude outside an organization raises both, and the second changes nothing. Only amanualtrigger moves the status (working, then idle at itsSessionStart). Any other trigger leaves the status as it is. That covers mid-turn auto compaction, where the session is already working, and idle compaction, which also callsPreCompactwithtrigger: "auto"and must not turn a waiting worker intoworking.agent.spawnwithresume.agentIdreopens the run with that id instead of adding a second one that shares its id and double-counts its tokens.Why
Since Claude Code 2.1.299 the built-in
sec-defaultmod sendssession.compactpast the user tier for every Team/Enterprise organization and every machine with managed settings (anthropics/claude-codemods/sec-default, and anthropics/claude-code#102134). Inside an organization the tower's mod no longer sees a compaction start, and a worker in the middle of an automatic compaction readsidle. The classicPreCompacthook still fires with itstrigger, for both manual and automatic compaction (checked on 2.1.300).Checks
npm run typecheck,npm test(375/375),npm run tower3dandkb verify --since origin/main(0 suspects). The tree is clean.Fixtures
compact-autoandcompact-manualwere re-recorded on 2.1.300 inside an organization, and the earlier recordings are kept ascompact-*-outside-org, so both paths stay covered.subagent-resumeis new. All are redacted.No host change: the mod is read when each Claude starts. No UI change.
Known gap, not addressed here: on 2.1.300 a "rapid-refill" turn end ("Autocompact is thrashing") raises no
PreCompactand noStop.