Skip to content

Add auto-approve session config for agent host#309513

Merged
roblourens merged 3 commits intomainfrom
roblou/agent-host-auto-approve
Apr 13, 2026
Merged

Add auto-approve session config for agent host#309513
roblourens merged 3 commits intomainfrom
roblou/agent-host-auto-approve

Conversation

@roblourens
Copy link
Copy Markdown
Member

Add an autoApprove session config property to the Copilot agent host with three options matching the extension host permission picker: Default Approvals, Bypass Approvals, and Autopilot (Preview).

Changes

Session config schema (copilotAgent.ts)

  • Add autoApprove property to resolveSessionConfig() with sessionMutable: true
  • Three enum values: default, autoApprove, autopilot

Auto-approval behavior (agentSideEffects.ts)

  • Early check in _tryAutoApproveToolReady(): when autoApprove is autoApprove or autopilot, auto-approve all tool calls unconditionally (bypasses per-file and per-command rules)

UI — New session picker (agentHostSessionConfigPicker.ts)

  • Filter autopilot option based on chat.autopilot.enabled setting
  • Disable bypass/autopilot when enterprise policy restricts chat.tools.global.autoApprove
  • Confirmation dialogs on first selection of bypass/autopilot (matching extension host pattern)
  • Warning/info CSS styling on trigger for elevated levels
  • Icons hardcoded in getConfigIcon() (shield/warning/rocket)

UI — Running session picker (agentHostSessionConfigPicker.ts)

  • New action registered on MenuId.ChatInputSecondary (same location as normal agent permission picker)
  • Gated by ChatContextKeyExprs.isAgentHostSession context key
  • Reuses shared helpers for filtering, confirmation dialogs, and styling

Mid-session config changes (both providers)

  • setSessionConfigValue() dispatches SessionConfigChanged action for running sessions
  • _preserveSessionMutableConfig() transfers mutable config when session transitions from new to committed
  • _handleConfigChanged() updates running config cache (creates minimal entry for restored sessions)
  • Proper cleanup: _runningSessionConfigs entries deleted on session removal/deletion/disconnect

Tests (agentSideEffects.test.ts)

  • 4 new tests: bypass auto-approves blocked writes, autopilot auto-approves blocked shell commands, default does NOT auto-approve, mid-session config change works

Notes

  • Autopilot = bypass approvals for agent host (the extension host autopilot continuation loop, task_complete tool, etc. are implemented in the Copilot extension's tool calling loop, not the SDK)

(Written by Copilot)

Add an autoApprove session config property to the Copilot agent host with
three options: Default Approvals, Bypass Approvals, and Autopilot (Preview).

- Add autoApprove property to resolveSessionConfig() in copilotAgent.ts
  with sessionMutable: true so it can be changed during running sessions
- Auto-approve all tool calls in agentSideEffects when bypass/autopilot
  is active, overriding per-file and per-command approval rules
- Add client-side filtering (autopilot gated by chat.autopilot.enabled,
  enterprise policy disables bypass/autopilot options)
- Show confirmation dialogs matching the extension host permission picker
- Render the picker in MenuId.ChatInputSecondary for running sessions
  (same location as the normal agent permission picker)
- Wire SessionConfigChanged dispatch for mid-session config changes in
  both local and remote agent host session providers
- Add running session config cache with proper lifecycle cleanup
- Handle restored sessions by creating minimal config entries
- Add 4 unit tests for session-level auto-approve behavior

(Written by Copilot)
Copilot AI review requested due to automatic review settings April 13, 2026 16:21
Render the autoApprove picker in the same location as the normal EH
permission picker (Menus.NewSessionControl, left side) instead of
alongside target/branch on the right side.

- Skip autoApprove property in main session config picker
- Add AgentHostNewSessionApprovePicker registered on NewSessionControl
- Existing running session picker on ChatInputSecondary unchanged

(Written by Copilot)
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a session-scoped “auto-approve” configuration to Agent Host sessions in the Sessions app, so approval level can be set per session (and changed mid-session) rather than behaving like a global toggle.

Changes:

  • Introduces an autoApprove session config property (default/autoApprove/autopilot) and uses it to bypass tool confirmations at the agent-host side.
  • Adds UI pickers + styling for choosing elevated approval levels (with policy gating and confirmation prompts).
  • Enables mid-session config updates by caching session-mutable config in local/remote session providers and dispatching session/configChanged.
Show a summary per file
File Description
src/vs/sessions/contrib/remoteAgentHost/browser/remoteAgentHostSessionsProvider.ts Cache + dispatch of session-mutable config for running remote sessions
src/vs/sessions/contrib/localAgentHost/browser/localAgentHostSessionsProvider.ts Cache + dispatch of session-mutable config for running local sessions
src/vs/sessions/contrib/chat/browser/media/agentHostSessionConfigPicker.css Visual styling for elevated approval levels on the picker trigger
src/vs/sessions/contrib/chat/browser/agentHostSessionConfigPicker.ts Session approvals picker UI, policy gating, and confirmation dialogs
src/vs/platform/agentHost/test/node/agentSideEffects.test.ts Adds unit coverage for session-level auto-approve behaviors
src/vs/platform/agentHost/node/copilot/copilotAgent.ts Extends session config schema/values with autoApprove
src/vs/platform/agentHost/node/agentSideEffects.ts Implements unconditional auto-approval when session config is elevated

Copilot's findings

  • Files reviewed: 7/7 changed files
  • Comments generated: 4

Comment thread src/vs/platform/agentHost/node/copilot/copilotAgent.ts
Comment thread src/vs/sessions/contrib/localAgentHost/browser/localAgentHostSessionsProvider.ts Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 13, 2026

Screenshot Changes

Base: 689454c4 Current: de8a632a

Changed (1)

agentSessionsViewer/ApprovalRowLongLabel/Dark
Before After
before after

Address Copilot review: use IResolveSessionConfigResult indexed type
instead of typeof expression for clearer type annotation.

(Written by Copilot)
@roblourens roblourens marked this pull request as ready for review April 13, 2026 16:51
@roblourens roblourens enabled auto-merge (squash) April 13, 2026 16:51
@roblourens roblourens merged commit 39b97f8 into main Apr 13, 2026
26 checks passed
@roblourens roblourens deleted the roblou/agent-host-auto-approve branch April 13, 2026 16:58
@vs-code-engineering vs-code-engineering bot added this to the 1.117.0 milestone Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants