Skip to content

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

Closed

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.

Activity

  1. nhickster commented on Mar 3, 2026

    @nhickster

    This is a technically a duplicate of #1084 , but you have a lot of good context here and maybe having two of these bugs open will get them to fix it.

  2. stephentoub commented on Apr 6, 2026

    @stephentoub

    I believe this issue has been fixed. I'm going to close it out, but if using the latest version you're still having issues, please feel free to re-open. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions