Skip to content

Compaction from the classic PreCompact hook; resumed subagents; Claude tested to 2.1.300 - #31

Merged
RegiByte merged 5 commits into
mainfrom
tower/ben-11
Oct 14, 2026
Merged

RegiByte merged 5 commits into
mainfrom
tower/ben-11

Conversation

@RegiByte

Copy link
Copy Markdown
Owner

What

  • Start a compaction from the classic PreCompact hook (3d469e1). The mod declares PreCompact in hooks.json, and status.ts takes PreCompact or session.compact as the start of a compaction. A Claude outside an organization raises both, and the second changes nothing. Only a manual trigger moves the status (working, then idle at its SessionStart). 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 calls PreCompact with trigger: "auto" and must not turn a waiting worker into working.
  • A resumed subagent reopens its run (727a38c). An agent.spawn with resume.agentId reopens the run with that id instead of adding a second one that shares its id and double-counts its tokens.
  • Claude Code tested up to 2.1.300 (7d8dcae), the usage note on idle compaction (6ffa7ae), and kb entities checked against the change (fb91269).

Why

Since Claude Code 2.1.299 the built-in sec-default mod sends session.compact past the user tier for every Team/Enterprise organization and every machine with managed settings (anthropics/claude-code mods/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 reads idle. The classic PreCompact hook still fires with its trigger, for both manual and automatic compaction (checked on 2.1.300).

Checks

npm run typecheck, npm test (375/375), npm run tower3d and kb verify --since origin/main (0 suspects). The tree is clean.

Fixtures compact-auto and compact-manual were re-recorded on 2.1.300 inside an organization, and the earlier recordings are kept as compact-*-outside-org, so both paths stay covered. subagent-resume is 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 PreCompact and no Stop.

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.
@RegiByte
RegiByte merged commit 3c8d2ac into main Oct 14, 2026
1 check passed
@RegiByte
RegiByte deleted the tower/ben-11 branch October 14, 2026 22:36
@RegiByte RegiByte mentioned this pull request Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant