Skip to content

automations: capture client customizations for offline runs - #338990

Merged
Connor Peet (connor4312) merged 10 commits into
mainfrom
connor4312/automation-customizations-v2
Oct 1, 2026
Merged

Connor Peet (connor4312) merged 10 commits into
mainfrom
connor4312/automation-customizations-v2

Conversation

@connor4312

@connor4312 Connor Peet (connor4312) commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Lets scheduled and manual automation runs use the client's plugins without the client being connected. This is a simpler replacement for #338777 and depends on microsoft/agent-host-protocol#474.

How it works

  • Protocol: syncs Add client plugin customizations to automations agent-host-protocol#474, which adds AutomationSessionTemplate.customizations, AutomationEntry.customizations, and the automations.customizations capability.
  • Client: when the host advertises the capability, the automation store sends the target scope's enabled plugins with the definition on create and when the target changes. It holds the scope until the host responds so the host can read client-served bundles. Ordinary edits resubmit the saved entries unchanged. A selected custom agent that lives in the synced bundle is sent as its bundled URI.
  • Host: a new self-contained AgentHostAutomationCustomizations module copies new or changed entries into immutable directories under agentPlugins/.host/automations/ and reuses copies whose id/uri/nonce are unchanged. Any capture failure rejects the mutation.
  • Runs: each run session is created with a static, host-owned vscode.automation active client whose plugins point at the copies. Every provider (Copilot, Claude, Codex) already loads active-client plugins before the first turn, so there are no provider, enablement-gate, or session-config changes. The plugin manager uses .host directories in place.
  • Cleanup: after each create, update, and removal, the host deletes copies that no automation references. Copies used by a run session in the current host process are kept until the next startup, because that session keeps using them for follow-up turns.

Compared with #338777, this drops plugin-cache holders and leases, per-run snapshots, session-deletion hooks, reattaching plugins on restore, provider-specific captured-plugin branches, and client bundle snapshots. Production code is about +320/−54 instead of +1,511/−266.

MCP authentication in runs

Until the host can own MCP authentication, run sessions borrow existing sign-ins from connected windows. When an MCP server in a run session requires authentication, the host sends a VS Code-specific vscode/requestMcpAuthentication request to connected clients one at a time. A client never prompts: it reuses a sign-in the user already allowed for that server, pushes the token through the regular authenticate command, and reports success. The existing token fan-out then unblocks the run, so there are no provider changes. Each challenge is requested once per session and server; if no client can supply a token, the run continues without that server.

Known limitations

  • A run session restored after a host restart does not get the captured plugins back. Runs in flight during a restart are already failed as interrupted.
  • If a customization is edited while the host is copying it, the copy could be inconsistent.
  • MCP sign-in needs a VS Code window to be connected when the challenge happens; there is no retry when one connects later.

Validation

  • npm run typecheck-client: passed
  • ./scripts/test.sh --grep 'AgentHostAutomationCustomizations|AgentHostAutomationService|AgentPluginManager|AgentHostAutomationStore|SyncedCustomizationBundler': 160 passing
  • ./scripts/test.sh --runGlob '**/agentHost/test/node/**/*.test.js': 7,862 passing, 72 pending
  • ./scripts/test-integration.sh --run src/vs/platform/agentHost/test/node/e2e/conformance/agentHostConformance.integrationTest.ts: automation capability test passes; one changeset-discard test times out locally and fails identically on main
  • ESLint on changed files and git diff --check: clean
  • Manual, in Code OSS: created and edited automations and ran them 3 times with Copilot. All runs completed. The run sessions registered MCP servers from the captured plugins before any window client joined. Unchanged entries were reused on a second automation and on an ordinary edit, and the synced bundle was re-captured when its nonce changed.
  • Manual MCP sign-in: a run with no prompts connected 7 MCP servers from existing sign-ins (and an 8th that shares a Slack resource) before its first model request, and the model successfully called workiq-me-GetMyDetails. Servers without a prior sign-in stayed unauthenticated as intended.
  • Not run: real-provider integration tests.

Syncs microsoft/agent-host-protocol#474 (rebased onto c02ad7ef) which adds
AutomationSessionTemplate.customizations, AutomationEntry.customizations and
the automations.customizations capability.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Captures client plugins from an automation's session template into
immutable host-owned directories on create/retarget, and seeds run
sessions with them through a static active client, so every provider
loads them through its existing client-plugin path. Unreferenced copies
are collected at startup.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When the host advertises automations.customizations, send the target
scope's enabled plugins on create and retarget, and remap a selected
bundled custom agent to its synced URI.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings September 30, 2026 21:04
@connor4312
Connor Peet (connor4312) force-pushed the connor4312/automation-customizations-v2 branch from 9713828 to 6820753 Compare September 30, 2026 21:04

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

🟡 Changes recommended

Captured plugins are mutable through resource APIs, can collide across clients, and leak staging data after failures.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Enables automations to capture client plugins so scheduled and manual runs can use them without a connected client.

Changes:

  • Adds the AHP customization capability and automation fields.
  • Captures enabled plugins during creation or retargeting.
  • Runs automations with host-owned plugin copies and adds coverage.
File Description
src/​vs/​workbench/​contrib/​chat/​test/​browser/​agentSessions/​syncedCustomizationBundler.test.ts Tests bundled URI lookup.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​agentSessions/​agentHostUntitledProvisionalSessionService.test.ts Updates scope mock.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​agentSessions/​agentHostChatContribution.test.ts Updates scope mock.
src/​vs/​workbench/​contrib/​chat/​browser/​agentSessions/​agentHost/​syncedCustomizationBundler.ts Maps source URIs to bundled URIs.
src/​vs/​workbench/​contrib/​chat/​browser/​agentSessions/​agentHost/​agentHostActiveClientService.ts Exposes bundled URI lookup.
src/​vs/​sessions/​contrib/​providers/​remoteAgentHost/​test/​browser/​remoteAgentHostSessionsProvider.test.ts Updates remote scope mock.
src/​vs/​sessions/​contrib/​providers/​agentHost/​test/​browser/​localAgentHostSessionsProvider.test.ts Updates local scope mocks.
src/​vs/​sessions/​contrib/​providers/​agentHost/​test/​browser/​agentHostAutomationStore.test.ts Tests client capture behavior.
src/​vs/​sessions/​contrib/​providers/​agentHost/​browser/​agentHostAutomationStore.ts Captures plugins when saving automations.
src/​vs/​sessions/​AUTOMATIONS.md Documents captured customizations.
src/​vs/​platform/​agentHost/​test/​node/​copilotAgent.test.ts Updates plugin-manager fake.
src/​vs/​platform/​agentHost/​test/​node/​codex/​codexPrewarmEviction.test.ts Updates plugin-manager stub.
src/​vs/​platform/​agentHost/​test/​node/​codex/​codexCreateChat.test.ts Updates plugin-manager stub.
src/​vs/​platform/​agentHost/​test/​node/​claudeAgent.test.ts Updates plugin-manager fake.
src/​vs/​platform/​agentHost/​test/​node/​claudeAgent.integrationTest.ts Updates integration stubs.
src/​vs/​platform/​agentHost/​test/​node/​agentServiceTestUtils.ts Registers required host services.
src/​vs/​platform/​agentHost/​test/​node/​agentPluginManager.test.ts Tests host-owned plugin loading.
src/​vs/​platform/​agentHost/​test/​node/​agentHostAutomationService.test.ts Tests capture, execution, and cleanup.
src/​vs/​platform/​agentHost/​test/​node/​agentHostAutomationCustomizations.test.ts Tests the capture module.
src/​vs/​platform/​agentHost/​node/​agentService.ts Passes client identity and captured plugins.
src/​vs/​platform/​agentHost/​node/​agentPluginManager.ts Loads host-owned directories in place.
src/​vs/​platform/​agentHost/​node/​agentHostAutomationService.ts Integrates captures into automation lifecycle.
src/​vs/​platform/​agentHost/​node/​agentHostAutomationCustomizations.ts Implements capture, mapping, and startup GC.
src/​vs/​platform/​agentHost/​common/​state/​protocol/​common/​commands.ts Adds the capability contract.
src/​vs/​platform/​agentHost/​common/​state/​protocol/​channels-automation/​state.ts Adds customization state fields.
src/​vs/​platform/​agentHost/​common/​state/​protocol/​channels-automation/​actions.ts Documents capture action semantics.
src/​vs/​platform/​agentHost/​common/​state/​protocol/​.ahp-version Updates the synced AHP revision.
src/​vs/​platform/​agentHost/​common/​agentPluginManager.ts Exposes the host plugin path.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/vs/platform/agentHost/node/agentHostAutomationCustomizations.ts
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: 0fe38943 Current: ade18d33

Changed (7)

sessions/accountMenu/WeeklyAndFiveHourLimits/Light
Before After
before after
sessions/accountMenu/WeeklyLimitOnly/Light
Before After
before after
sessions/accountMenu/FiveHourLimitOnly/Light
Before After
before after
sessions/accountMenu/UsageUnavailable/Light
Before After
before after
sessions/accountMenu/LimitsWithoutReset/Light
Before After
before after
sessions/accountMenu/FiveHourLimitHover/Light
Before After
before after
chat/aiCustomizations/aiCustomizationManagementEditor/DiscoverPluginsLoadingMore/Light
Before After
before after

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

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

🟡 Changes recommended

Target retargeting can retain stale bundled-agent URIs, and captured revisions can consume unbounded disk space.

Review effort: Balanced
Findings: 2 High severity

Open (2)
Resolved since last review (1)

Comment thread src/vs/platform/agentHost/node/agentHostAutomationCustomizations.ts
Comment thread src/vs/sessions/contrib/providers/agentHost/browser/agentHostAutomationStore.ts Outdated
Advertise the customizations capability in the automation conformance
snapshot, and back the test plugin manager with an in-memory provider so
startup cleanup doesn't warn when callers pass a bare file service.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Collect copies no automation references after each create, update, and
removal, keeping copies used by run sessions in this process. When
retargeting, map a selected agent saved from the previous target's bundle
into the new bundle.

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

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Ulugbek Abdullaev (@ulugbekna)

Matched files:

  • src/vs/platform/agentHost/common/state/protocol/channels-automation/actions.ts
  • src/vs/platform/agentHost/common/state/protocol/channels-automation/state.ts
  • src/vs/platform/agentHost/node/agentHostAutomationCustomizations.ts
  • src/vs/platform/agentHost/node/agentHostAutomationService.ts
  • src/vs/platform/agentHost/test/node/agentHostAutomationCustomizations.test.ts
  • src/vs/platform/agentHost/test/node/agentHostAutomationService.test.ts
  • src/vs/platform/agentHost/test/node/e2e/suites/automationsSuite.ts

Ben Villalobos (@benvillalobos)

Matched files:

  • src/vs/platform/agentHost/common/state/protocol/channels-automation/actions.ts
  • src/vs/platform/agentHost/common/state/protocol/channels-automation/state.ts
  • src/vs/platform/agentHost/node/agentHostAutomationCustomizations.ts
  • src/vs/platform/agentHost/node/agentHostAutomationService.ts
  • src/vs/platform/agentHost/test/node/agentHostAutomationCustomizations.test.ts
  • src/vs/platform/agentHost/test/node/agentHostAutomationService.test.ts
  • src/vs/platform/agentHost/test/node/e2e/suites/automationsSuite.ts

roblourens
roblourens previously approved these changes Oct 1, 2026
When an MCP server in an automation run session requires authentication,
the host asks connected VS Code clients via vscode/requestMcpAuthentication.
Clients reuse an existing allowed sign-in without prompting and push the
token through the regular authenticate command, which unblocks the run.

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

# Conflicts:
#	src/vs/platform/agentHost/common/state/protocol/.ahp-version
roblourens
roblourens previously approved these changes Oct 1, 2026
@benvillalobos

Copy link
Copy Markdown
Member

Only concern is that saving plugins could lead to slow feeling UX is a remote if network is slow

  1. Save automation A on remote host (assume it takes a few moments)
  2. Try to cancel running automation B on the same host

If the stop button does nothing and shows no UX (spinner or something) we may need to smooth that out. Otherwise lgtm

@connor4312

Copy link
Copy Markdown
Member Author

Thanks for the review! Runs with a concurrent stop should generally work barring the entire connection being bogged down. That is a thing that has come up a few times and I'm probably going to make a protocol-level change to help resolve that (adding SSH-like receive windows for backpressure per-channel). But I will do a followup UI PR to include a 'saving' state for automations.

…ests

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

# Conflicts:
#	src/vs/platform/agentHost/common/state/protocol/.ahp-version
@connor4312
Connor Peet (connor4312) merged commit c0c9725 into main Oct 1, 2026
35 checks passed
@connor4312
Connor Peet (connor4312) deleted the connor4312/automation-customizations-v2 branch October 1, 2026 17:50
@vs-code-engineering vs-code-engineering Bot added this to the 1.141.0 milestone Oct 1, 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.

4 participants