Skip to content

Terminal auto-approval parity for agent host + make CLI/SDK the source of truth #326766

Open

Description

Follow up to #323570 and #322112. Rules from chat.tools.terminal.autoApprove are forwarded to agent host and respected (#322774), but the approval experience did not come along. When a command isn't auto-approved, agent host sessions only get "Allow" (once) and "Skip".

From local harness we used to have:

  • Always Allow <command>
  • Allow <command> in this Session / in this Workspace
  • Allow Exact Command Line
  • Allow All Commands in this Session
  • Configure Auto Approve...

None of these show up in agent host copilot today, so users have to re-approve the same command over and over. Awkward part is the agent host side already offers an "Allow in this Session" option over the protocol, but our terminal confirmation UI hardcodes its two buttons and drops it on the floor.

Work needed:

  • Bring the rule-creating options back for agent host terminal confirmations (user/workspace scope can just write to the existing setting, which is already forwarded)
  • Forward session-scoped rules to the agent host process so "allow in this session" actually auto-approves later commands silently
  • Some telemetry on how often people add rules from the confirmation UI, per scope. Would be useful signal for the item below.

Bigger picture: right now VS Code owns the rules and we forward + re-parse commands ourselves. I think this should be the other way around, where Copilot CLI/SDK is the source of truth so approval behavior is consistent whether you're in VS Code, CLI in terminal, etc. The SDK already has most of the pieces (session/location scoped approvals, permissions.configure / modifyRules, persisted grants in ~/.copilot/permissions-config.json). Open questions before we can converge:

  • Rule shape mismatch: our setting is regex/matchCommandLine based, SDK grants are command-identifier based
  • SDK has no user-global allow list today, only per repo/dir
  • AHP has no standard message for standing allow/deny rules (scoped approvals are opaque option ids, approve-all is a vendor RPC)

#323570 and #322791 fall under this umbrella.

Activity

  1. added
    terminal
    agent-host
    on Jul 21, 2026
  2. modified the milestones: 1.131.0, on Jul 29, 2026
  3. anthonykim1 commented on Jul 29, 2026

    @anthonykim1
    ContributorAuthor

    Adding findings from the Agent Host PowerShell-grammar work (#328052) that are convergence items rather than standalone bugs.

    While reviewing that change I built a consistency matrix across the two engines. The standalone defects are filed separately (#328107, #328108, #328109, #328110); what is left below is the structural drift that belongs on this umbrella.

    Where the two engines differ today

    behaviour workbench Agent Host
    npm-script auto-approve (NpmScriptAutoApprover) yes no
    session-scoped rules yes no (deliberately suppressed via skipSessionScoped)
    grammar signal terminal shell (isPowerShell(shell, os)) tool name (getShellLanguage)
    dynamic redirect destinations (>$HOME/x) blocked was approved — fixed in the #328052 PR
    errored parse blocks approval no (#328108) yes
    assignments / invocations fail closed no (#328107) yes, after #328052

    The grammar-signal row is not a defect — the Agent Host has no persistent terminal, so the tool name is the only correct signal available. Same intent, different input.

    Root cause: duplicated logic, shared data

    The two engines already share the rule data — getAgentHostTerminalAutoApproveRulesConfig forwards the effective chat.tools.terminal.autoApprove over AHP, so the Agent Host's bundled default table is only a legacy-client fallback. What is duplicated is the logic, and every divergence above is a symptom: the errored-parse gate exists in one copy, the assignment hole existed in both, and a dead leading-( matching branch was copied from the workbench into the Agent Host (it is unreachable in both, since the PowerShell grammar already strips the parens).

    Suggested convergence work

    1. Extract a shared core. Put parsing + rule matching in an environment-agnostic common/ module both sides consume, with tree-sitter access injected (Agent Host reads wasm via fs; workbench uses ITreeSitterLibraryService). Layering permits this — workbench may import from platform. This removes drift by construction.

    2. Invert the safety invariant. Replace "enumerate (command) nodes and check each" with "verify the captured spans account for the whole command line, and fail closed on anything unaccounted for." This is grammar-agnostic and fails closed on node types nobody enumerated. It subsumes both the errored-parse gate (Terminal auto-approve: a partially-failed tree-sitter parse can still auto-approve #328108) and the assignment/invocation hole (Terminal auto-approve: assignments and method invocations bypass sub-command checks #328107), which is a strong signal it is the shape the code wants.

    3. One language vocabulary. Today: _meta.language uses 'shellscript' | 'powershell', IAgentToolPendingConfirmationSignal.shellLanguage uses 'bash' | 'powershell', IShouldAutoApproveOptions.language uses 'bash' | 'powershell', TreeSitterCommandParserLanguage is a fourth, and the renderer converts back to 'shellscript'. One enum plus one converter.

    4. Close the feature gap so the same command gets the same answer on both surfaces — npm-script auto-approval and session-scoped rules. The skipSessionScoped: true stopgap in terminalChatService.ts is the honest interim answer and its comment already explains why.

    5. A shared conformance corpus. One table of (commandLine, shell, expectedResult) run against both implementations. This is the artifact that would have caught the regression in Agent Host terminal auto-approve should use PowerShell grammar for PowerShell commands #328052 — that PR's own tests all passed, because they asserted the new behaviour rather than comparing it to the old.

  4. modified the milestones: , On Deck on Sep 8, 2026
  5. dagwinstox commented on Oct 5, 2026

    @dagwinstox

    I'm seeing what looks like a regression with chat.tools.terminal.autoApprove in the Local harness.

    VS Code: 1.140.0
    Commit: 07f806f
    OS: Windows NT x64 10.0.26200

    chat.tools.terminal.enableAutoApprove is enabled and chat.tools.terminal.autoApprove contains the standard/default allow rules.

    With the Local harness, commands that match auto-approve rules, for example:
    git status

    still show the "Run bash command?" confirmation.
    This is not specific to the Git regex. Other commands present in the auto-approve list behave the same way.

    If I switch the exact same session/workspace to the Copilot harness, the auto-approve configuration works as expected and matching commands execute without requesting confirmation.

    So on my installation:

    • Local harness -> autoApprove rules not honored
    • Copilot harness -> autoApprove rules honored
  6. leonardos-cerebras commented on Oct 19, 2026

    @leonardos-cerebras
    Version: 1.142.0 (user setup)
    Commit: 6d62b1d5dace93a33b3a6d3eca1317bd5e15bcb1
    Date: 2026-10-15T03:02:17Z
    Electron: 43.7.7
    ElectronBuildId: 15553055
    Chromium: 150.0.7871.250
    Node.js: 24.21.0
    V8: 15.0.245.31-electron.0
    @github/copilot: 1.0.95-0.unstable.r38345923974.g3754b70
    @github/copilot-sdk: 1.0.19.38345923974.g3754b70
    OS: Windows_NT x64 10.0.26200
    

    With the Copilot harness, "Allow All Commands in this Session" is missing:
    Image

    With the local harness:
    Image

    Problems:

    1. With the Copilot harness, "Allow All Commands in this Session" is missing
    2. The options are different across the harnesses.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

agent-hostterminal

Type

No type

Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions