Skip to content

Map managed permission policies into Agent Host sessions - #328082

Draft
Josh Spicer (joshspicer) wants to merge 3 commits into
mainfrom
joshspicer-managed-permissions-agent-host
Draft

Map managed permission policies into Agent Host sessions#328082
Josh Spicer (joshspicer) wants to merge 3 commits into
mainfrom
joshspicer-managed-permissions-agent-host

Conversation

@joshspicer

@joshspicer Josh Spicer (joshspicer) commented Jul 29, 2026

Copy link
Copy Markdown
Member

Why

VS Code has legacy enterprise policy values that arrive through its configuration policy system rather than the runtime's newer managed-settings delivery mechanisms. This maps the restrictive subset that has exact equivalents in the runtime's managed-permission grammar into the SDK startup contract.

Exact policy mapping

Only IConfigurationService.inspect(...).policyValue is read. User, workspace, profile, and default values are never promoted to enterprise policy.

  • chat.tools.global.autoApprove policy value false
    disableBypassPermissionsMode: "disable"
  • chat.tools.terminal.enableAutoApprove policy value false
    ask: ["Shell(*)"]

chat.tools.eligibleForAutoApproval is intentionally not mapped because the runtime rejects generic Tool(...) selectors. Network and sandbox policies are also out of scope because their semantics are not equivalent to generic permission rules.

How it works

  1. The renderer derives the permissions object from managed policy values only.
  2. It forwards that object through the typed Agent Host root config.
  3. Removing policy sends an empty-object wire sentinel because root config patches merge and JSON drops undefined; Agent Host normalizes the sentinel back to no policy.
  4. The session launcher supplies managedSettings: { permissions } on both create and resume, alongside enableManagedSettings: true so runtime self-fetch/device policy still composes.
  5. No restrictive policy means managedSettings is omitted from the SDK configuration.
  6. Managed permissions are part of the active-client snapshot. A change disposes and resumes both default and peer-chat SDK sessions before the next turn, ensuring startup-only policy changes take effect before more work runs.

Rollout blocker

The currently published @github/copilot-sdk (1.0.9-preview.1) types and runtime do not transport/enforce managedSettings; the narrow local type only keeps this integration compileable. Keep this PR draft until:

  1. github/copilot-agent-runtime#14000 is released;
  2. github/copilot-sdk#2139 publishes a version bundling that runtime;
  3. this PR bumps @github/copilot-sdk in both package trees and removes the temporary type shim.

Until that dependency bump, this PR must not merge because the published SDK would drop the field before RPC.

Testing

  • Focused schema/mapping tests
  • Renderer transport tests, including policy removal
  • Launcher create/resume forwarding and omission tests
  • Default and peer-chat restart tests
  • Pre-commit hygiene

Full typecheck-client currently also reports unrelated errors from current main in native auth/component-fixture files; the Agent Host files changed here compile through the focused suites.

Copilot AI review requested due to automatic review settings July 29, 2026 19:38

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.

Pull request overview

Maps enterprise permission policies into Copilot Agent Host session startup settings and restart detection.

Changes:

  • Derives managed runtime permissions exclusively from policy values.
  • Forwards permissions during session creation/resumption.
  • Restarts sessions when managed permissions change and adds coverage.
Show a summary per file
File Description
agentHostSchema.ts Defines managed permission schema and derivation.
remoteAgentHostProtocolClient.ts Forwards policy-derived permissions.
copilotAgent.ts Adds permissions to restart snapshots.
copilotSessionLauncher.ts Passes permissions to the Copilot SDK.
agentHostSchema.test.ts Tests derivation and validation.
remoteAgentHostProtocolClient.test.ts Tests policy forwarding.
copilotAgent.test.ts Tests restart detection.
copilotSessionLauncher.test.ts Tests SDK configuration forwarding.

Review details

  • Files reviewed: 8/8 changed files
  • Comments generated: 1
  • Review effort level: Medium

});
this.dispatchAction(ROOT_STATE_URI, {
type: ActionType.RootConfigChanged,
config: { [AgentHostManagedPermissionsConfigKey]: permissions },
@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Base: 3e63ea8f Current: 06bcda3d

No screenshot changes.

@joshspicer
Josh Spicer (joshspicer) force-pushed the joshspicer-managed-permissions-agent-host branch 2 times, most recently from c4c405b to b8af535 Compare August 4, 2026 16:24
Synthesize a client-agnostic managedSettings.permissions object from VS Code's
legacy enterprise Copilot/agent policies and forward it through the Agent Host
root config to the Copilot SDK at session create/resume.

Derive exclusively from IConfigurationService.inspect(...).policyValue, using
only rule boundaries the runtime supports:
- managed chat.tools.global.autoApprove === false -> disableBypassPermissionsMode: 'disable'
- managed chat.tools.terminal.enableAutoApprove === false -> ask: ['Shell(*)']

Per-tool eligibility (chat.tools.eligibleForAutoApproval) is intentionally not
mapped: the runtime rejects generic Tool(...) rules, so there is no supported
boundary to express it, and malformed/unknown rules reject session startup.
Network/sandbox policies are out of scope. The derived snapshot participates in
restart detection so a policy change refreshes the session before the next turn.

The published @github/copilot-sdk (^1.0.8) does not yet expose managedSettings,
so a precise additive local type mirrors the existing local-type precedent
(ICopilotRuntimeManagedSettingsSdk) until the SDK publishes the field.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: c111c62a-eff3-4ff6-bb8a-8436a1b4babe
The `managedPermissions` root config key follows omit semantics: it is absent
when no restrictive enterprise policy applies. Its schema property carried a
`default: {}`, which is seeded into stored root config values by
`registerProviderConfiguration` and would let the launcher forward an empty
(and misleading) `managedSettings` even with no policy. Remove the default so
the key stays `undefined` and `managedSettings` is omitted entirely.

Also remove the stale `chat.tools.eligibleForAutoApproval` reference from the
`AgentHostManagedPermissionsConfigKey` doc comment (eligibility is no longer
synthesized after the runtime-contract correction).

Add a launcher test asserting neither create nor resume config carries
`managedSettings` when the root value is unset.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: c111c62a-eff3-4ff6-bb8a-8436a1b4babe
Clear removed policy through the merge-based root config, restart peer chats on policy changes, and update rebased launcher tests.

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

Copilot-Session: d5d4d699-33e2-4a55-9d48-57d2e483dd3d
@joshspicer
Josh Spicer (joshspicer) force-pushed the joshspicer-managed-permissions-agent-host branch from b8af535 to 71e9d23 Compare August 4, 2026 16:29
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.

2 participants