Group of 3 You'll notice
SessionStart hook transcript messages can now be held back and inserted into the transcript only when explicitly released
What
- The main session controller gained
deferHookMessages/releasePendingHookMessagesmethods, wired into the REPL asdeferHookMessages/releaseDeferredHookMessagesprops, letting a pending hook set's transcript messages be held back instead of inserted immediately, until explicitly released. - Before running a new turn (when starting fresh rather than resuming a concurrent query), the agent now awaits any pending/deferred hook set via
awaitPendingHooks(), so the turn doesn't start until hooks have resolved (the wait is skipped only if the abort signal actually fires). - On session resume, the mechanism for landing
SessionStart-type hook messages into the transcript was reworked: instead of a single pending-promise plus a "landed" flag, there is now a_pendingHookSetobject withdeferHookMessages,awaitStartupHooks,releasePendingHookMessages, and abort support, tied to session id checks so stale hook results for a since-replaced session get discarded.
Why This makes hook-driven transcript messages around session start and resume more reliable: turns wait for pending hooks instead of racing them, hook messages can be staged and released at the right moment, and results from a stale, already-replaced session no longer leak into the current one.