Summary
src/core/hooks-loader.ts wires up 6 hook events:
preToolUse, postToolUse, userPromptSubmitted,
sessionStart, sessionEnd, errorOccurred
The upstream @github/copilot SDK (QueryHooks interface) supports 13:
export declare interface QueryHooks {
preToolUse?: PreToolUseHook[];
postToolUse?: PostToolUseHook[];
postToolUseFailure?: PostToolUseFailureHook[]; // ← missing
userPromptSubmitted?: UserPromptSubmittedHook[];
sessionStart?: SessionStartHook[];
sessionEnd?: SessionEndHook[];
errorOccurred?: ErrorOccurredHook[];
agentStop?: AgentStopHook[]; // ← missing
subagentStop?: SubagentStopHook[]; // ← missing
subagentStart?: SubagentStartHook[]; // ← missing
preCompact?: PreCompactHook[]; // ← missing
permissionRequest?: PermissionRequestHook[]; // ← missing
notification?: NotificationHook[]; // ← missing
}
(Source: node_modules/@github/copilot/sdk/index.d.ts:11762)
The CLI hooks reference documents all 13 events: https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-hooks-reference
Why this matters
The 7 missing hooks unlock several high-value use cases that aren't possible today through the bridge:
| Hook |
Use case |
preCompact |
Persist context before compaction discards it — critical for memory-capture pipelines (e.g. auto-write Beads memories before tokens are dropped) |
agentStop |
End-of-turn checkpoints; can block and force another turn (e.g. "did you write memories?" gate) |
subagentStart / subagentStop |
Observe and control delegated agent task tool calls — important for fleet-mode/multi-agent observability |
permissionRequest |
Programmatic allow/deny for headless / -p mode and CI; complements preToolUse |
notification |
Inject additionalContext into session on shell completion, agent idle, etc. — async signal hooks |
postToolUseFailure |
Provide structured recovery guidance when a tool fails (vs. just suppressing) |
The most impactful is preCompact — it's the missing piece for an "auto-memory" hook similar to claude-mem's pipeline, where observed tool calls get summarised into persistent storage before the context window collapses.
Proposed change
Mostly mechanical:
- Extend the
LoadedHooks interface in src/core/hooks-loader.ts with the 7 missing on* callbacks.
- Extend the
EVENT_TO_SDK map with the 7 new event-name mappings.
- Forward them through to the SDK's
QueryHooks when constructing sessions in session-manager.ts.
- Update
docs/configuration.md (Hooks section) — currently only documents preToolUse and postToolUse; should reflect the full event list and link to the upstream CLI hooks reference.
Decision-control surface (allow/deny/block/additionalContext) for the new events is already defined by the SDK and CLI docs, so no new wire-format design is needed — the bridge just needs to forward stdin/stdout shape per event.
Scope check
- Bridge-only change. No upstream
@github/copilot SDK enhancement required — the SDK already exposes all 13 events.
- Docs in
docs/configuration.md (Hooks section) currently lists only preToolUse/postToolUse; the loader actually supports 6, so there's already a doc/code drift to close as part of this.
Happy to put up a PR if helpful.
Summary
src/core/hooks-loader.tswires up 6 hook events:The upstream
@github/copilotSDK (QueryHooksinterface) supports 13:(Source:
node_modules/@github/copilot/sdk/index.d.ts:11762)The CLI hooks reference documents all 13 events: https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-hooks-reference
Why this matters
The 7 missing hooks unlock several high-value use cases that aren't possible today through the bridge:
preCompactagentStopblockand force another turn (e.g. "did you write memories?" gate)subagentStart/subagentStoppermissionRequest-pmode and CI; complementspreToolUsenotificationadditionalContextinto session on shell completion, agent idle, etc. — async signal hookspostToolUseFailureThe most impactful is
preCompact— it's the missing piece for an "auto-memory" hook similar to claude-mem's pipeline, where observed tool calls get summarised into persistent storage before the context window collapses.Proposed change
Mostly mechanical:
LoadedHooksinterface insrc/core/hooks-loader.tswith the 7 missingon*callbacks.EVENT_TO_SDKmap with the 7 new event-name mappings.QueryHookswhen constructing sessions insession-manager.ts.docs/configuration.md(Hooks section) — currently only documentspreToolUseandpostToolUse; should reflect the full event list and link to the upstream CLI hooks reference.Decision-control surface (allow/deny/block/additionalContext) for the new events is already defined by the SDK and CLI docs, so no new wire-format design is needed — the bridge just needs to forward stdin/stdout shape per event.
Scope check
@github/copilotSDK enhancement required — the SDK already exposes all 13 events.docs/configuration.md(Hooks section) currently lists onlypreToolUse/postToolUse; the loader actually supports 6, so there's already a doc/code drift to close as part of this.Happy to put up a PR if helpful.