Skip to content

fix(mod): no prompt.context or classic.SessionStart hook, so a guard has nothing to skip (#2243) - #2413

Merged
backnotprop merged 4 commits into
mainfrom
fix/2243-guard-skip-notices
Oct 31, 2026
Merged

backnotprop merged 4 commits into
mainfrom
fix/2243-guard-skip-notices

Conversation

@backnotprop

@backnotprop backnotprop commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner

Part of #2243.

What it fixes

On Team/Enterprise accounts Claude Code's built-in cc-plugin-sec-default sits in the prepend tier and sends prompt.context, every classic.* event and session.compact (and a few events the mod does not hook) past user plugins. For each hook of ours the engine passes by that way, Claude Code prints, once per session id:

plannotator: its <event> hook was skipped. "cc-plugin-sec-default" runs first and sent the event on past it.

Two findings from Claude Code 2.1.314 (its claude plugin test kit under a temp HOME, and its host code):

  • A matcher does not stop the notice. The host trims only the plugins above the first one whose matcher matches. The guard is outermost and matches every event, so a hook of ours whose matcher does not match is still in the chain and still reported. That is why classic.SessionStart {source:'resume'} printed at every startup (oronbz's report).
  • Registration cannot depend on $.store. on() works only inside register(), and register() runs before $ exists: an engine.create step runs after it, $.store is refused there, and on() after register() returned throws. So "don't register when the store says false" can't be built.

So the mod no longer registers either hook:

  • The Inbox reminder goes as the first prompt's prompt.submit context for everyone (that event is not skipped). This was already the guarded path from Inbox reminder reaches Team/Enterprise sessions and survives compaction (#2159) #2167. The prompt.context block and the inboxReminderContextWorks learning code are gone. After a compaction, the existing SessionStart compact command hook still prints PLANNOTATOR_INBOX_REMINDER, and that is now the one copy. Before, standard users also got the re-made prompt.context block, so they had two.
  • Resume: no classic.SessionStart hook. A resumed conversation ($.session.messages() already holds an assistant row when this process first sees it) gets the session's open Inbox threads as its first prompt's context, and the Inbox is asked once per conversation. Guarded users now get the list too; before, the guard skipped it. The conversation is classed at first sight, even when session.start has not decided yet, so a first prompt that outwaits the 2.5 s gate does not make the next one look resumed.
  • Which resumed conversations need the reminder: the old prompt.context block was never in the transcript, so a conversation started under the old mod and resumed would have none. The mod now records in $.store (inboxReminderSessions, newest 500) each session id whose first prompt entered with the reminder. On resume, a session id with the record gets only its threads; one without it (an older mod's conversation, or one from before the Inbox ran) gets the reminder once plus its threads, and is recorded. A fork has a new id, so it may get a duplicate line. An in-process /resume back to a session this process already saw gets its thread list again.

What it does not silence

Under the guard, Claude Code still prints:

  • its classic.PermissionRequest hook was skipped at the first permission prompt of a session. The hook is matched on ExitPlanMode, which does not help (see above). Removing it would rely on the Claude Code mod: one plan approval when the plugin guard skips the mod's hook (#2007) #2043 approval record, and CLIs older than that would get a second plan review.
  • its session.compact hook was skipped at the first compaction. Guarded users also get the plain reminder after a compaction, without the thread list.

claude-code-mod.md said the opposite of both; that is corrected.

Not covered, by choice: subagents no longer get the reminder (they report to their parent, per the plannotator skill).

Behaviour changes

  • Standard machines: the reminder moves from a context block to a prompt attachment. It is still in the first user message and is the same text, so the cached prefix is unchanged.
  • Subagents: the old prompt.context block also reached subagents' first messages. prompt.submit runs only for the main conversation, so subagents no longer get the reminder (guarded machines never gave it to them).
  • A resumed first prompt sent while the mod is still starting can wait up to about 4 s (the 2.5 s gate, then the 1.5 s thread read).

Tests

Engine harness (scripts/test-claude-code-mod.sh, Claude Code 2.1.314, temp HOME): 64 pass. The guard stand-in now mirrors 2.1.314's guard and reports each link of ours the engine bypassed (the trace the notice comes from). 8 of the tests fail on main, among them:

  • under the guard, no prompt.context or classic.SessionStart link to skip (on main the kit reports both notices);
  • the reminder arrives once on a standard and on a guarded machine, with no context block and no second copy after a compaction;
  • a resumed conversation gets its thread list once and no second reminder (also under the guard, for an in-process /resume, and with no open thread).

5 fail on this PR's first head (0b7241b), for the review fixes:

  • a conversation with assistant rows and no record gets the reminder once on resume (with its threads, and alone when there is none); one with the record gets none;
  • the first prompt records the session;
  • a session.start slower than the 2.5 s gate: the first prompt goes on bare and the next carries the reminder (it got none before);
  • an in-process /resume back to a session this process already saw gets its threads again.

Bun: apps/hook/hooks/mod/, packages/shared/inbox, tests/agents-md-size.test.ts. tsc for the mod and packages/shared. claude plugin validate apps/hook passes and lists no prompt.context or classic.SessionStart hook.

Version skew

Mod-only change, so none between the mod and the CLI. On engines without hooks modules, the classic command hooks are unchanged. A stored inboxReminderContextWorks is left in place and ignored; an older mod that reads it still works. The new inboxReminderSessions record is the mod's own $.store key; an older mod never reads it.

Thanks @sshevlyagin for the report and the suggested direction, and @oronbz for the classic.SessionStart sighting.

…has nothing to skip (#2243)

Under Claude Code's cc-plugin-sec-default every registered hook the guard
sends past prints "its <event> hook was skipped" once per session, matched or
not (the host trims only plugins above the first match). Registration cannot
depend on $.store: on() runs only inside register(), before $ exists.

- The Inbox reminder goes as the first prompt's prompt.submit context for
  everyone; the prompt.context block and the inboxReminderContextWorks
  learning code are removed. After a compaction the SessionStart compact
  command hook's line is now the one copy.
- A resumed conversation (an assistant row already in $.session.messages())
  gets the session's open Inbox threads as its first prompt's context, once,
  and no second reminder; guarded users get it too.
- Docs: 2.1.314's guard also skips session.compact, and the ExitPlanMode
  matcher does not stop the classic.PermissionRequest notice; both remain.

Part of #2243.
)

Review fixes for #2413:
- Record in $.store (inboxReminderSessions, newest 500) each session id
  whose first prompt entered with the reminder; a resumed conversation
  without the record (an older mod's, or one from before the Inbox ran)
  gets the reminder once plus its threads, with it only its threads.
- Class a conversation at first sight whatever session.start has decided,
  so a first prompt that outwaits the gate does not make the next look
  resumed.
- An in-process /resume back to a session this process saw gets its
  threads again.
- Docs: the marketing Inbox page and the agent guides say what ships,
  the ~4 s bound on a resumed first prompt, and the two notices left.
@backnotprop backnotprop added the ci:full Run the heavy CI tier on this PR (added by the merge script) label Oct 31, 2026
@backnotprop
backnotprop merged commit 7795e6f into main Oct 31, 2026
71 of 72 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:full Run the heavy CI tier on this PR (added by the merge script)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant