Skip to content

Fix account policy enforcement in the Agents window - #336968

Merged
Ross Wollman (rwoll) merged 3 commits into
mainfrom
rwoll-issue-reproduction
Sep 21, 2026
Merged

Ross Wollman (rwoll) merged 3 commits into
mainfrom
rwoll-issue-reproduction

Conversation

@rwoll

@rwoll Ross Wollman (rwoll) commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

Initialize configuration defaults before registering policies so the Agents window applies account restrictions correctly, and preserve policy updates received while configuration files load. Hide the Welcome invitation and reject direct launch commands when Agent mode is disabled.

Before the change, the "Try out the new Agents Window" showed up on the Editor Welcome even though Agents were disabled by token policy:
Screenshot 2026-09-20 at 9 55 30 PM

Now, the "Try…" no longer shows and even if the user circumvents it (e.g. using code --agents … to launch the Agents Window directly), policy is properly applied so it shows the disabled state:

Screenshot 2026-09-20 at 9 55 37 PM

Repro

  1. Sign into Copilot. Using scripts/mock-policy-server, mock /copilot_internal/v2/token with {"token":"agent_mode=0;editor_preview_features=0;mcp=0"} and route that endpoint through the proxy. Leave other endpoints on passthrough.
  2. Remove any manual chat.agent.enabled override and run Developer: Sync Account Policy.
  3. Confirm the editor's normal Agents button disappears, then open Welcome → Try out the new Agents window.

Before: the invitation remains and opens an unblocked Agents window, although both windows receive chat_agent_enabled: false.

After: the invitation is hidden, and an Agents window opened directly with --agents shows Agents Disabled. Verified with mocked account policy; successful model execution was not tested with the synthetic token.

Validation

Client build and lint pass; 191 focused tests pass, including startup policy changes and existing draft handoff coverage.

Fixes https://github.com/microsoft/vscode-internalbacklog/issues/9102.

Copilot AI balanced review requested due to automatic review settings September 21, 2026 04:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The implementation consistently enforces policy state and includes focused regression coverage for startup races, UI visibility, and direct commands.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes account-policy enforcement across the Agents window and related launch surfaces.

Changes:

  • Corrects configuration and policy initialization ordering.
  • Reactively hides Agents banners when agent mode is unavailable.
  • Blocks direct Agents window launch commands and adds regression coverage.
File Description
src/​vs/​workbench/​contrib/​welcomeGettingStarted/​browser/​gettingStarted.ts Makes the Welcome banner policy-aware.
src/​vs/​workbench/​contrib/​welcomeAgentSessions/​browser/​agentSessionsWelcome.ts Makes the sessions invitation policy-aware.
src/​vs/​workbench/​contrib/​chat/​test/​electron-browser/​agentSessionsActions.test.ts Tests launch-command enforcement.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​agentSessions/​agentSessionsBanner.test.ts Tests reactive banner visibility.
src/​vs/​workbench/​contrib/​chat/​electron-browser/​agentSessions/​agentSessionsActions.ts Rejects launches when agent mode is disabled.
src/​vs/​workbench/​contrib/​chat/​browser/​agentSessions/​agentSessionsBanner.ts Reactively applies entitlement and configuration visibility.
src/​vs/​sessions/​services/​configuration/​test/​browser/​configurationService.test.ts Covers policy initialization and update races.
src/​vs/​sessions/​services/​configuration/​browser/​configurationService.ts Initializes defaults first and preserves current policy state.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Co-authored-by: Copilot App <[email protected]>
@rwoll
Ross Wollman (rwoll) marked this pull request as ready for review September 21, 2026 05:03
@github-actions

Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: c0f6c8cd Current: 5a81461f

Changed (1)

sessions/connectionDiagnostics/connectionDiagnostics/MobileDismissedDiscovery/Light
Before After
before after

2 insignificant change(s) omitted (≤20 px, Δ≤2). See CI logs for details.

const result = startAccountPolicyInitialization(policyData);
await result.initialization;
return result;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
}
}

await result.initialization;
return result;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change

*--------------------------------------------------------------------------------------------*/

import { $, addDisposableListener } from '../../../../../base/browser/dom.js';
import { $, addDisposableListener, setVisibility } from '../../../../../base/browser/dom.js';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
import { $, addDisposableListener, setVisibility } from '../../../../../base/browser/dom.js';
import { $, addDisposableListener, setVisibility } from '../../../../../base/browser/dom.js';

@ahmedrabia203030-web

Copy link
Copy Markdown

**gjvvnbv120pyufy]yiohjk'ujbj gygpugj]ijjik\jhbjb623123650
hcgdm]yufkjh\iuiljk21523
pl30197971-remark
**

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants