Skip to content

Allow Policy Helper registration through VS Code settings - #345712

Merged
Ross Wollman (rwoll) merged 5 commits into
microsoft:mainfrom
monil-patel:user/mopatel/policy-helper-restart-alternative
Nov 4, 2026
Merged

Ross Wollman (rwoll) merged 5 commits into
microsoft:mainfrom
monil-patel:user/mopatel/policy-helper-restart-alternative

Conversation

@monil-patel

Copy link
Copy Markdown
Contributor

Summary

Let extensions register a Policy Helper for local Copilot Agent Host sessions without a VS Code restart or window reload.

The Agency extension can write chat.agentHost.copilot.policyHelper through the configuration API. VS Code forwards the registration to the local Agent Host. The Copilot runtime executes the helper and resolves policy.

Related issue: github/copilot-agent-runtime#28101.

Extension contract

await vscode.workspace.getConfiguration('chat.agentHost.copilot').update(
    'policyHelper',
    { path: absoluteHelperPath, args: helperArguments },
    vscode.ConfigurationTarget.Global,
);

The setting accepts an executable path and optional string args. It uses application scope and excludes Settings Sync. The advanced tag limits default visibility in the Settings editor. doNotSuggest: true omits the key from settings JSON suggestions. The configuration API remains available, and users can inspect the value in raw settings JSON.

An unset, malformed, or whitespace-only path means no helper. Omitted arguments normalize to []. A cleared setting crosses the protocol as an empty-path object, so removal clears the host's previous registration.

Runtime lifecycle

The normalized registration belongs to the existing client startup snapshot. Addition, removal, path changes, and argument changes trigger the existing safe restart flow. Equivalent registrations do not trigger another restart.

Shared clients wait until active turns, subagents, and credential updates finish. Scoped clients refresh stale configuration at the next idle use. Each runtime launch receives the captured startup value. Change logs report policyHelper without its path or arguments.

The next fresh chat receives the helper configuration. Existing chats can retain their previous skill inventory after resume. Helper script content changes do not trigger a restart.

Policy boundary

A valid registration sets COPILOT_CLI_POLICY_HELPER and adds POLICY_HELPER to COPILOT_CLI_ENABLED_FEATURE_FLAGS. Other feature flags remain intact. An absent registration clears the helper environment variable and adds no helper flag.

Device and server policy remain authoritative. VS Code provides registration, not policy enforcement. This change covers the local Agent Host path only. It does not change the Copilot extension's separate copilotcli session path.

Validation

Command Result
npx --yes --package=pnpm@12.16.0 pnpm run build-fast Passed, including client and built-in extensions
npm run typecheck-client Passed
Targeted ESLint command below Passed
git diff --check Passed
Focused unit command below 241 passed
npm run eslint -- src\vs\platform\agentHost\common\copilotCliConfig.ts src\vs\platform\agentHost\node\copilot\copilotAgent.ts src\vs\platform\agentHost\node\copilot\copilotAgentStartupConfig.ts src\vs\platform\agentHost\test\common\copilotCliConfig.test.ts src\vs\platform\agentHost\test\node\copilotAgent.test.ts src\vs\platform\agentHost\test\node\copilotAgentStartupConfig.test.ts src\vs\workbench\contrib\chat\browser\chat.shared.contribution.ts src\vs\workbench\contrib\chat\test\browser\chatConfiguration.test.ts

.\scripts\test.bat --reporter dot --run src\vs\platform\agentHost\test\common\copilotCliConfig.test.ts --run src\vs\platform\agentHost\test\node\copilotAgentStartupConfig.test.ts --run src\vs\platform\agentHost\test\node\copilotAgent.test.ts --run src\vs\workbench\contrib\chat\test\browser\chatConfiguration.test.ts --grep "copilotCliConfig|CopilotAgentStartupConfig|Chat configuration|CopilotAgent (restart on startup config change|scoped credentials)"

The tests cover normalization, registration metadata, removal transport, environment injection, redacted comparisons, captured startup values, scoped clients, and deferred restarts.

Live verification

An isolated regular Code OSS workbench used a cloned profile and a Windows ARM64 runtime override. The source profile remained untouched.

Scenario Observed result
Register through an extension with ConfigurationTarget.Global Client restarted automatically without an application relaunch
Invoke the generated skill in the next fresh chat Actual skill invocation returned policy helper skill for repo devprod.commitlinks
Clear the registration Client restarted automatically, and a fresh chat reported the skill unavailable
Change arguments during an active turn The skill call completed successfully before the deferred restart
Write an identical registration again No additional restart
Resume a chat that started without the helper The previous skill inventory remained

The live run used runtime artifact 70ffdab, not the bundled runtime. It does not establish published runtime availability. Full integration and smoke suites, remote hosts, and the Agency rollout gate were not exercised.

Manual test

  1. Configure a compatible runtime and a helper that supplies a repository-specific skill.
  2. Start a local Agent Host chat.
  3. Write the helper registration through the extension configuration API.
  4. Open a fresh chat without a window reload.
  5. Invoke the generated skill.
  6. During an active turn, change the helper arguments.
  7. Confirm that the turn finishes before the client restart.
  8. Clear the registration and open a fresh chat.
  9. Confirm that the helper skill is absent.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 5af45bc5-bd78-4717-a21d-b847191b3cb6
Copilot AI balanced review requested due to automatic review settings November 3, 2026 03:07
@monil-patel monil-patel changed the title Support local Policy Helper registration without a VS Code restart Allow Policy Helper registration through VS Code settings Nov 3, 2026

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.

🔵 Needs a closer look

Live verification used an override artifact and the external runtime contract was unavailable, leaving bundled-runtime compatibility, policy precedence, and the Agency rollout gate dependent on maintainer confirmation.

No open issues 🎉

What changed in this PR

Enables extensions to register or clear a Policy Helper for local Copilot Agent Host sessions without restarting VS Code or reloading the window, using the existing safe runtime-restart lifecycle.

Changes:

  • Adds an application-scoped helper setting, normalization, and local-host synchronization with explicit removal handling.
  • Captures helper configuration at runtime startup, preserves other feature flags, and redacts helper values from change logs.
  • Adds lifecycle and configuration tests and documents the registration contract.
File Description
src/​vs/​workbench/​contrib/​chat/​test/​browser/​chatConfiguration.test.ts Tests setting metadata and serializable removal handling.
src/​vs/​workbench/​contrib/​chat/​browser/​chat.shared.contribution.ts Registers the local-only setting and synchronization transform.
src/​vs/​platform/​agentHost/​test/​node/​copilotAgentStartupConfig.test.ts Tests helper comparisons and redacted change descriptions.
src/​vs/​platform/​agentHost/​test/​node/​copilotAgent.test.ts Tests environment injection, captured values, and safe restart behavior.
src/​vs/​platform/​agentHost/​test/​common/​copilotCliConfig.test.ts Tests helper normalization and schema validation.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotAgentStartupConfig.ts Includes helper configuration in startup comparisons without logging values.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotAgent.ts Passes captured helper configuration and its feature flag to runtime launches.
src/​vs/​platform/​agentHost/​common/​copilotCliConfig.ts Defines the helper setting, type, schema, and normalizer.
src/​vs/​platform/​agentHost/​AGENTS.md Documents registration, restart behavior, and policy precedence.

Review effort: Balanced

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 5af45bc5-bd78-4717-a21d-b847191b3cb6
@monil-patel
monil-patel marked this pull request as ready for review November 3, 2026 03:20
Preserve Policy Helper registration and upstream progress prompt configuration.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 13a6c083-7976-461a-8eb2-6ed734379b30
Extract the shared setting schema to avoid duplicate command registration during full unit test discovery.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 13a6c083-7976-461a-8eb2-6ed734379b30
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 13a6c083-7976-461a-8eb2-6ed734379b30
@rwoll
Ross Wollman (rwoll) merged commit 6586e4e into microsoft:main Nov 4, 2026
59 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.146.0 milestone Nov 4, 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.

5 participants