Skip to content

preToolUse agent hook denial does not work #3874

Closed

Description

@springcomp

Describe the bug

Running chat session from Copilot CLI, I have installed a hook that denies all commands.

Affected version

  • GitHub Copilot Chat Extension v1.0.65

Steps to reproduce the behavior

.github/hooks/hooks.json

{
  "version": 1,
  "hooks": {
    "preToolUse": [
      {
        "cwd": "src",
        "bash": "bin/Debug/net10.0/hook",
        "powershell": "bin/Debug/net10.0/hook",
        "timeoutSec": 15
      }
    ]
  }
}

A simple C# hook.exe program:

Program.cs

Console.WriteLine("{\"permissionDecision\":\"deny\"}");
Environment.Exit(2);

Here is a simple session prompt:

Give me the latest powershell Get-Date

I tried everything:

  • Exit code 2
  • {"permissionDecision": "deny"} response to preToolUse hook events.
  • {"behavior":"deny"} response to permissionRequest hook events.

Still, the tool is called and never denied.

Expected behavior

The tool call SHOULD be denied.

Additional context

No response

Activity

  1. added theissue type on Jun 20, 2026
  2. added
    area:pluginsPlugin system, marketplace, hooks, skills, extensions, and custom agents
    area:permissionsTool approval, security boundaries, sandbox mode, and directory restrictions
    on Jun 20, 2026
  3. Necmttn commented on Jun 21, 2026

    @Necmttn

    The regression contract here can be very small.

    For a PreToolUse event with a concrete tool_use_id, if the hook response resolves to permissionDecision: "deny", then:

    • run_in_terminal must not execute
    • no successful PostToolUse event should be emitted for that tool_use_id
    • the transcript should record a denied tool result with the hook reason

    I would also pin precedence in the test: top-level permissionDecision vs hookSpecificOutput.permissionDecision vs exit code 2. If multiple shapes are accepted, they should converge to the same internal verdict before tool dispatch, rather than each host path interpreting them separately.


    Generated with ax.

  4. changed the title [-]VS Code agent `preToolUse` agent hook denial does not work[/-] [+]`preToolUse` agent hook denial does not work[/+] on Jun 30, 2026
  5. springcomp commented on Jun 30, 2026

    @springcomp
    Author

    I updated the issue to make it easier to reproduce

  6. BGMLAI commented on Jul 14, 2026

    @BGMLAI

    This looks like a dispatch invariant rather than only a hook-format problem: once any pre-tool hook returns deny, the matching tool_use_id must become non-dispatchable. It would help to normalize all accepted hook output shapes into one internal verdict before execution, then test the full path (hook -> denial event -> no process spawn), not just JSON parsing. Logging the normalized verdict and tool_use_id would also make failures much easier to diagnose.

  7. copilot-cli-bot commented on Sep 20, 2026

    @copilot-cli-bot

    This appears to be resolved as of GitHub Copilot CLI v1.0.86. Please update to that release or a newer stable version. We're closing this as completed. If it still happens, please comment with your version and reproduction steps.

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

    area:permissionsTool approval, security boundaries, sandbox mode, and directory restrictionsarea:pluginsPlugin system, marketplace, hooks, skills, extensions, and custom agents

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions