microsoft / microsoft/vscode

agentHost: add regression tests that the auto-approve policy does not clamp the Autopilot mode axis

Open
#333,077 0 comments 0 reactions 1 assignee Claimed by @digitarald View on GitHub
Dominant language
TypeScript
Stars
193k
Forks
42.4k
PR merge metrics
PR metrics pending

Description

### Background

#321865 moved Agent Host Autopilot off the `autoApprove` approvals axis onto the independent `mode` axis (`mode='autopilot'`; the `autoApprove` enum is now `default | assisted | autoApprove`).

The enterprise managed setting `permissions.disableBypassPermissionsMode` forces the `ChatToolsAutoApprove` policy, which surfaces as `configurationService.inspect('chat.tools.global.autoApprove').policyValue === false`. This is the **policy value**, not the setting value—the setting's own default is already `false` and carries no restriction.

Invariant: that policy restricts only elevated **approval** values. Agent Host `mode='autopilot'` must remain selectable and seedable; it runs within the permitted approval level, so tool calls still route through the session's approval level. Auto-approving in Autopilot to make it work would defeat the policy and is not an acceptable fix.

### Problem

The invariant holds in the current source, but is unpinned in the two paths most likely to regress—the new-session config seeds, where the approvals clamp and mode resolution sit side by side:

- `baseAgentHostSessionsProvider._initialNewSessionConfig` (Agents window): approvals are clamped while mode is resolved independently.
- `AgentHostUntitledProvisionalSessionService._getInitialConfig` (editor window): no direct coverage today.

Already covered elsewhere and out of scope: `copilotAgent.getAutonomousSessionConfig` and `isPolicyBlockedCompletionAction`.

### Acceptance criteria

1. In `localAgentHostSessionsProvider.test.ts`, with an auto-approve policy value of `false` and `chat.defaultConfiguration = { mode: 'autopilot', approvals: 'allowAll' }`, creating a session forwards `mode: 'autopilot'` and `autoApprove: 'default'`.
2. Extend the remembered Agent Host config migration coverage with a policy-restricted variant: remembered `autoApprove: 'autopilot'` still forwards `mode: 'autopilot'` and `autoApprove: 'default'`. This pins migration-before-clamp ordering.
3. Add coverage for `AgentHostUntitledProvisionalSessionService._getInitialConfig`: mode passes through and approvals clamp under policy. Its seeded object also contains `isolation: 'folder'`.

### Non-goals

- No production behavior change unless a test reveals a violation; any fix must keep the clamp scoped to `SessionConfigKey.AutoApprove`, never the mode axis.
- The local/legacy chat Autopilot **permission level** remains bundled with auto-approval and intentionally policy-disabled. Do not change `permissionPickerActionItem`, `permissionPicker`, or `copilotChatSessionsProvider._defaultPermissionLevel`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.