{"version":"2.1.265","anchor":"turn-dispatch-now-waits-for-pending-hooks-before-starting","canonical_anchor":"turn-dispatch-now-waits-for-pending-hooks-before-starting","heading":"Hook messages during session start\/resume can now be deferred and released later","tier":"notice","area":"Hooks","scope":null,"heads_up":null,"url":"https:\/\/changelogs.core-directive.com\/v\/2.1.265\/e\/turn-dispatch-now-waits-for-pending-hooks-before-starting","release_url":"https:\/\/changelogs.core-directive.com\/v\/2.1.265","markdown":"### Hook messages during session start\/resume can now be deferred and released later\n\nSessionStart hook transcript messages can now be held back and inserted into the transcript only when explicitly released\n\n**What**\n\n- The main session controller gained `deferHookMessages`\/`releasePendingHookMessages` methods, wired into the REPL as `deferHookMessages`\/`releaseDeferredHookMessages` props, letting a pending hook set's transcript messages be held back instead of inserted immediately, until explicitly released.\n\n- 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).\n\n- 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 `_pendingHookSet` object with `deferHookMessages`, `awaitStartupHooks`, `releasePendingHookMessages`, and abort support, tied to session id checks so stale hook results for a since-replaced session get discarded.\n\n**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.\n\n- Area: Hooks\n- Tier: You'll notice\n- Useful: 3\/5\n- Signal: 2\/5"}