copilot-cli icon indicating copy to clipboard operation
copilot-cli copied to clipboard

preToolUse: silent command rewrite via updatedInput — confirmation dialog appears even with permissionDecision: allow

Open jeziellopes opened this issue 7 months ago • 13 comments

Summary

When a preToolUse hook rewrites a command using updatedInput with permissionDecision: allow, Copilot CLI v1.0.24 still shows an interactive confirmation dialog to the user on every rewritten command. There is currently no way for a hook to silently rewrite a command.

Environment

  • Copilot CLI version: 1.0.24
  • OS: Linux

Context

Consider a tool that automatically prepends a proxy prefix to dev commands (e.g. git status → proxy git status) to reduce LLM token consumption. Users install a preToolUse hook so the agent's commands are transparently rewritten without friction.

Before v1.0.24, updatedInput was not supported in Copilot CLI (#2013), so the hook used deny-with-suggestion as a workaround. When v1.0.24 shipped updatedInput support, the hook was upgraded to use updatedInput + permissionDecision: allow.

What I expected

A hook returning:

{
  "hookSpecificOutput": {
    "hookEventName": "PreToolUse",
    "permissionDecision": "allow",
    "permissionDecisionReason": "proxy auto-rewrite",
    "updatedInput": {
      "command": "proxy git status",
      "description": "check repo status"
    }
  }
}

should silently rewrite the command and run it — no confirmation needed, since:

  1. The user explicitly installed the hook (opt-in)
  2. permissionDecision is allow
  3. The rewrite is mechanical (just prepending a proxy prefix)

What happened instead

Copilot CLI shows a confirmation dialog on every rewritten command:

╭─────────────────────────────────────────────────────╮
│ Hook permission request                             │
│ ⚠ proxy auto-rewrite                               │
│                                                     │
│  Tool: bash                                         │
│  Args: {"command": "proxy git status", ...}         │
│                                                     │
│ Do you want to allow this tool call?                │
╰─────────────────────────────────────────────────────╯

This dialog appears for every single command the agent runs that gets rewritten — making the hook more disruptive than the old deny-with-suggestion workaround.

Proposed solution

Add a way for hooks to indicate a rewrite should be applied silently. Options:

Option A — permissionDecision: allow should suppress the dialog (most intuitive):

If the hook already decided allow, no confirmation should be needed.

Option B — New field showConfirmation: false:

{
  "hookSpecificOutput": {
    "permissionDecision": "allow",
    "updatedInput": { ... },
    "showConfirmation": false
  }
}

Option C — New permissionDecision value "silent-allow" or "allow-silent"

Option A seems most consistent with the existing semantics — allow already means the hook approved it.

Impact

Without silent rewrite, updatedInput is not practical for high-frequency mechanical rewrites (like token optimization proxies). The old deny-with-suggestion workaround was less disruptive because denials are handled gracefully by the agent without surfacing a modal to the user.

cc @MRayermannMSFT (from #2013)

jeziellopes avatar Apr 11 '26 14:04 jeziellopes

This was fixed across two releases. In v1.0.18, permissionDecision: "allow" was updated to suppress the tool approval prompt. In v1.0.24, updatedInput support was added so hooks can rewrite tool arguments before execution. These features compose, so returning allow together with updatedInput on v1.0.24 should rewrite the command without showing a dialog. If you are still seeing the prompt on v1.0.24, please comment with a minimal repro or sanitized hook output and we will take another look.

examon avatar Apr 12 '26 21:04 examon

Confirmed still happening on v1.0.24. Here's a minimal repro.

Hook config (.github/hooks/rtk-rewrite.json)

{
  "hooks": {
    "PreToolUse": [
      {
        "type": "command",
        "command": "proxy-hook",
        "cwd": ".",
        "timeout": 5
      }
    ]
  }
}

Hook input (from Copilot CLI)

{"toolName":"bash","toolArgs":"{\"command\":\"git log --oneline -3\",\"description\":\"check repo\"}"}

Hook output (what the hook returns)

{
  "hookSpecificOutput": {
    "hookEventName": "PreToolUse",
    "permissionDecision": "allow",
    "permissionDecisionReason": "proxy auto-rewrite",
    "updatedInput": {
      "command": "proxy git log --oneline -3",
      "description": "check repo"
    }
  }
}

What happened

Despite permissionDecision: allow, Copilot CLI v1.0.24 shows this dialog:

╭──────────────────────────────────────────────────────────────────╮
│ Hook permission request                                          │
│ ⚠ proxy auto-rewrite                                            │
│                                                                  │
│  Tool: bash                                                      │
│  Args: {"command": "git log --oneline -3", "description": "..."}│
│                                                                  │
│ Do you want to allow this tool call?                             │
│ ❯ 1. Yes                                                         │
│   2. No (Esc to stop)                                            │
╰──────────────────────────────────────────────────────────────────╯

Note: the dialog shows the original args, not the rewritten updatedInput. The permissionDecisionReason ("proxy auto-rewrite") is shown as the dialog title, which confirms the hook output was received — but the dialog still appears.

This happens on every rewritten command. A mechanical rewrite hook where the user explicitly opted in by installing the hook becomes unusable because it interrupts every single agent command.

jeziellopes avatar Apr 13 '26 13:04 jeziellopes

Experiencing the same thing as @jeziellopes, and the problem is still present on 1.0.25, @examon.

ChristofferKarlsson avatar Apr 14 '26 09:04 ChristofferKarlsson

@examon this was not fixed.

specter119 avatar Apr 15 '26 05:04 specter119

@jeziellopes Thanks for the concrete repro. I retested this with an isolated Copilot CLI v1.0.39 and a fresh config containing only the posted PreToolUse hook. In that run, permissionDecision: "allow" plus updatedInput rewrote the bash command to the proxy command, executed the proxy command, and did not show a Hook permission request dialog.

To find the delta with the failing setup, could you please share three details from a single failing run?

  1. Can you reproduce in a fresh empty config with only the posted PreToolUse hook? If yes, could you please share the exact launch command/config path?
  2. For one failing tool call, please share the raw hook stdin, stdout, stderr, and exit status exactly as Copilot CLI saw them (before any jq or formatting, etc.)
  3. From that same run, please share the exact dialog text and what executes after approving: the original command or the rewritten proxy command.

Thanks a lot

examon avatar Apr 29 '26 13:04 examon

Image Image

我使用copilot --yolo,运行过程中遇到rtk时总是弹出这个询问的页面。请问如何解决?

bigfoot88 avatar May 05 '26 03:05 bigfoot88

Same here with 1.0.44, every tool call gets a "Hook permission request" when using RTK even with /yolo enabled. 😮‍💨

vinciest avatar May 09 '26 11:05 vinciest

same here with rtk https://github.com/rtk-ai/rtk/issues/1155#issuecomment-4447138925

asule90 avatar May 15 '26 11:05 asule90

I'm running into this problem also, and I'd love to see this prioritized and fixed.

rohitpagariya avatar May 25 '26 19:05 rohitpagariya

So do we have solution for this?

jaderocks avatar Jun 17 '26 10:06 jaderocks

I still have this issue in v1.0.64-3 ... @CopilotTeam can we get an updated timeline on this?

Jonas-Tieto avatar Jun 24 '26 11:06 Jonas-Tieto

Reporting back, I've got this work with a custom extention and been using RTK fine with Copilot CLI for a while, you can run rtk gain --history to verify if it's really working. https://gist.github.com/vinciest/900d2712aad394e5c8f359e27be8ca89

vinciest avatar Jun 25 '26 09:06 vinciest

Thanks for the report. We've shipped fixes in this area since this was filed, and we believe this may now be resolved. Could you retest on the latest release (Copilot CLI v1.0.103) and let us know whether you still see it? If we don't hear back in a couple of weeks, we may close this issue — you can always reopen it.

Triaged as part of a Copilot SDK backlog review, with help from GitHub Copilot.

patniko avatar Oct 26 '26 21:10 patniko