Skip to content

[Bug] rtk hook copilot does not trigger for VS Code Copilot Chat — "run_in_terminal" not recognized in detect_format() #1425

Closed

Description

@devmasa

Summary

rtk hook copilot produces no output (PassThrough) when invoked from VS Code
Copilot Chat, because detect_format() does not recognize "run_in_terminal"
as a valid tool name. As a result, the hook never fires and all commands pass
through without rewriting.


Environment

  • RTK version: 0.37.2 (Homebrew)
  • AI tool: VS Code Copilot Chat extension (not Copilot CLI)
  • OS: Ubuntu (WSL2)
  • No copilot-instructions.md was active during hook verification (isolated hook behavior only)

Root Cause

VS Code Copilot Chat sends tool_name: "run_in_terminal" in the PreToolUse
hook payload, but detect_format() only matches "runTerminalCommand",
"Bash", and "bash":

// src/hooks/hook_cmd.rs
if matches!(tool_name, "runTerminalCommand" | "Bash" | "bash") {

This causes all commands from VS Code Copilot Chat to fall through to
HookFormat::PassThrough, and the hook returns no output.


Evidence

Actual JSON received by the hook (captured via debug wrapper script):

{
  "tool_name": "run_in_terminal",
  "tool_input": {
    "command": "git status",
    "explanation": "Check current git status",
    "mode": "sync",
    "timeout": 60000
  }
}

VS Code Output panel (GitHub Copilot Chat Hooks channel):

[PreToolUse] Input: {"tool_name":"run_in_terminal","tool_input":"..."}
[PreToolUse] Completed (Success) in 26ms, no output

Fix

Add "run_in_terminal" to the match arm in detect_format():

if matches!(tool_name, "runTerminalCommand" | "Bash" | "bash" | "run_in_terminal") {

Verified locally with a source build — the hook correctly rewrites commands
after this change.


Additional Context: Allow loop after fix (updatedInput not honored)

After applying the fix above, a secondary issue appears in VS Code Copilot Chat:

When the hook returns permissionDecision: "ask" with updatedInput, VS Code
Copilot Chat enters an infinite Allow-dialog loop:

  1. Hook fires → returns "ask" + updatedInput: {"command": "rtk git status"}
  2. Copilot Chat shows an Allow dialog
  3. User clicks Allow
  4. updatedInput is ignored — the original command (git status) is retried
  5. Hook fires again → loop repeats

This is consistent with the updatedInput problems reported in Copilot CLI:

The same class of problem appears to affect VS Code Copilot Chat. Resolution is
expected on the Copilot side.

Workaround (verified working in VS Code Copilot Chat, 2026-04-21):

Use permissionDecision: "deny" with a suggestion message — the same approach
that the Copilot CLI community has recognized as the practical workaround:

{
  "hookSpecificOutput": {
    "hookEventName": "PreToolUse",
    "permissionDecision": "deny",
    "permissionDecisionReason": "Token savings: use `rtk git status` instead (rtk saves 60-90% tokens)"
  }
}

With this approach, Copilot Chat reads the reason message and automatically
retries with rtk git status without surfacing a dialog to the user.

Activity

  1. added
    bug
    effort-small
    good first issue
    on Apr 22, 2026
  2. pszymkowiak commented on Apr 22, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟡 Priority medium
    🎯 Confidence 96%

    Summary

    Add 'run_in_terminal' to detect_format() tool name matching in hook_cmd.rs; fix is trivial and a PR (#1800) is already in progress.

    This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.

    📁 Relevant files
    • src/hooks/hook_cmd.rs

    Triaged automatically by wshm · This is an automated analysis, not a human review.

  3. added
    P1-critical
    on Apr 28, 2026
  4. added 3 commits that reference this issue on May 8, 2026
    5f6f3ae
    c2959e4
    ba8e583
  5. devmasa commented on May 14, 2026

    @devmasa
    Author

    Thanks for the mention! I've updated the PR to address this as well —
    the fix is included in #1800, which now also closes #1839.

  6. added a commit that references this issue on May 28, 2026
    6f0e926
  7. added a commit that references this issue on Jun 8, 2026
    9120a16
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

    P1-criticalarea:clibugeffort-smallgood first issuepriority:medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions