From a536eb9227f2935d7628aea824c525dda2ca96a2 Mon Sep 17 00:00:00 2001 From: omartelo Date: Thu, 15 Oct 2026 11:42:31 -0300 Subject: [PATCH] docs(hooks): close compacting with the turn's state, not the trigger's Claude Code 2.1.300 compacts an idle conversation before its prompt cache expires and hands the mod that compaction as `auto`, the trigger a mid-turn one carries. Closing every `auto` with `busy` left the card on the spinner with no Stop to follow. The closing report is now the turn's state: `busy` while a turn is open, `done` when none is. --- docs/hooks/session-state.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/hooks/session-state.md b/docs/hooks/session-state.md index 8e102ff0..c41cbb6d 100644 --- a/docs/hooks/session-state.md +++ b/docs/hooks/session-state.md @@ -195,13 +195,22 @@ is: the client reports it when the compaction starts, and when it settles (finished or failed) reports the state the session is back in. That closing report is what clears it, like any later state would. -Only Claude Code sends it, from the plugin's mod, on `session.compact`. Measured -on Claude Code 2.1.295 at a real PTY against a stub listener: +Only Claude Code sends it, from the plugin's mod, on `session.compact`. The +closing report is the turn's state, not the trigger's: `busy` while a turn is +open, `done` when none is. The first two rows were measured on Claude Code +2.1.295 at a real PTY against a stub listener; the third was seen on 2.1.300: | `e.trigger` | When it runs | Took | Report that closes it | |-------------|------------------------------------------------|------|-----------------------| | `manual` | `/compact`, at an idle prompt | ~6s | `done` | | `auto` | mid-turn, after `UserPromptSubmit`, before the model call | ~14s | `busy` | +| `auto` | at an idle prompt, before the prompt cache expires ("Compacted while idle") | — | `done` | + +The idle compaction is why the trigger cannot decide the closing report: its +summary is prepared under a `precompute` trigger and applied through the same +path as a mid-turn one, so it reaches the mod as `auto` with no turn open and no +`Stop` to follow. Closing it with `busy` left the card on the spinner until the +next prompt. Without it the card says the wrong thing in both cases: a `/compact` raises no prompt event, so the card sits on the finished turn's check the whole time, and