Skip to content

Hooks not loaded when session is resumed via --resume #1503

@zacharyzimmerman

Description

@zacharyzimmerman

Describe the bug

When a session is resumed using --resume, hooks configured in .github/hooks/*.json are never loaded.

In the source code (index.js v0.0.411-1), createSession() calls loadHooks() to discover and register hook files from .github/hooks/. However, getSession() — which handles the --resume code path — does not call loadHooks(). This means any tool or wrapper that uses --resume will never trigger any configured hooks (sessionEnd, agentStop, etc.).

Affected version

GitHub Copilot CLI 0.0.411-1 (Windows_NT)

Steps to reproduce the behavior

  1. Install a hook via a .github/hooks/*.json file (e.g. toasty --install copilot creates ~/.github/hooks/toasty.json with a sessionEnd hook).
  2. Start Copilot CLI with --resume <sessionId>.
  3. Complete a session or trigger the hook event.
  4. Observe that the hook command is never executed.

Without --resume (fresh createSession path), the same hook file works correctly.

Expected behavior

getSession() should call loadHooks() (or equivalent) so that hooks from .github/hooks/*.json are loaded for resumed sessions, just as they are for new sessions.

Additional context

  • Impact: Any wrapper that always passes --resume (e.g. Agency / Microsoft Agent Platform) will never fire hooks. This completely breaks the hooks feature for those users.
  • Root cause location: In the minified index.js, createSession contains a call to this.loadHooks(e) while getSession has zero references to loadHooks, hooks, or the hook-loading helpers (B3t, Tee).
  • Hook file format is correct: The .github/hooks/toasty.json file validates against the zod schema (version: 1, hooks.sessionEnd array with type: "command", powershell/bash fields, timeoutSec).
  • Hook file location is correct: Copilot CLI globs <gitRoot>/.github/hooks/**/*.json (or <cwd>/.github/hooks/ if not in a git repo). The file is at ~/.github/hooks/toasty.json.
  • Verified across 5 Agency sessions that --resume is always passed, confirming hooks never load.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions