automations: feat: move automations to the agent host via AHP - #330463
Conversation
There was a problem hiding this comment.
Pull request overview
Moves Automations from renderer-owned scheduling to durable Agent Host Protocol state and execution.
Changes:
- Adds AHP automation/run channels, persistence, scheduling, cancellation, and provenance.
- Projects host automation state into the Agents window with legacy-ledger migration.
- Removes renderer scheduling, leader election, and provider-local stores.
Show a summary per file
| File | Description |
|---|---|
src/vs/workbench/services/agentHost/browser/editorRemoteAgentHostServiceClient.ts |
Proxies automation commands. |
src/vs/workbench/contrib/terminal/test/browser/agentHostPty.test.ts |
Updates connection mock. |
src/vs/workbench/contrib/chat/common/automations/automationTelemetry.ts |
Updates duration semantics. |
src/vs/workbench/contrib/chat/common/automations/automationService.ts |
Defines host-backed service API. |
src/vs/workbench/contrib/chat/common/automations/automationsEnabled.ts |
Removes renderer timeout setting. |
src/vs/workbench/contrib/chat/common/automations/automationRunner.ts |
Simplifies host-run interface. |
src/vs/workbench/contrib/chat/common/automations/automation.ts |
Adds host and run metadata. |
src/vs/sessions/sessions.desktop.main.ts |
Registers migration storage. |
src/vs/sessions/services/sessions/common/sessionsProvider.ts |
Removes provider automation stores. |
src/vs/sessions/contrib/sessions/test/browser/sessionsList.test.ts |
Updates run fixtures. |
src/vs/sessions/contrib/sessions/test/browser/automationsView.test.ts |
Tests host-backed UI behavior. |
src/vs/sessions/contrib/sessions/test/browser/automationsView.fixture.ts |
Updates run fixture. |
src/vs/sessions/contrib/sessions/browser/views/automationsAccessibility.ts |
Exposes host statuses accessibly. |
src/vs/sessions/contrib/providers/agentHost/browser/localAgentHostSessionsProvider.ts |
Removes local automation store. |
src/vs/sessions/contrib/chat/test/browser/sessionTypePicker.test.ts |
Tests provider filtering. |
src/vs/sessions/contrib/chat/browser/sessionTypePicker.ts |
Adds provider filtering. |
src/vs/sessions/contrib/automations/test/browser/automationTestUtils.ts |
Removes legacy test utilities. |
src/vs/sessions/contrib/automations/test/browser/automationLeaderElection.test.ts |
Removes leader-election tests. |
src/vs/sessions/contrib/automations/test/browser/automationDialog.test.ts |
Updates host/model tests. |
src/vs/sessions/contrib/automations/electron-browser/legacyAutomationMigrationStorage.ts |
Implements native migration storage. |
src/vs/sessions/contrib/automations/common/legacyAutomationMigrationStorage.ts |
Defines migration storage contract. |
src/vs/sessions/contrib/automations/common/automationStorageService.ts |
Removes writable ledger contract. |
src/vs/sessions/contrib/automations/browser/providerAutomationService.ts |
Removes provider-store orchestration. |
src/vs/sessions/contrib/automations/browser/legacyAutomationMigrationStorage.ts |
Implements browser migration storage. |
src/vs/sessions/contrib/automations/browser/legacyAutomationMigration.ts |
Adds guarded legacy migration. |
src/vs/sessions/contrib/automations/browser/automationTools.ts |
Routes manual runs to hosts. |
src/vs/sessions/contrib/automations/browser/automationScheduler.ts |
Removes renderer scheduler. |
src/vs/sessions/contrib/automations/browser/automations.contribution.ts |
Registers host-backed services. |
src/vs/sessions/contrib/automations/browser/automationRunner.ts |
Tracks host-owned runs. |
src/vs/sessions/contrib/automations/browser/automationLeaderElection.ts |
Removes renderer leader election. |
src/vs/sessions/contrib/automations/browser/automationDialog.ts |
Restricts providers and normalizes models. |
src/vs/sessions/AI_CUSTOMIZATIONS.md |
Documents host-owned automation behavior. |
src/vs/platform/agentHost/test/node/sessionServerTools.test.ts |
Tests referenced tool-input omission. |
src/vs/platform/agentHost/test/node/sessionPermissions.test.ts |
Tests referenced-input confirmation. |
src/vs/platform/agentHost/test/node/protocolServerHandler.test.ts |
Tests automation capability handshake. |
src/vs/platform/agentHost/test/node/e2e/suites/automationSuite.ts |
Adds automation conformance coverage. |
src/vs/platform/agentHost/test/node/e2e/suites/agentHostE2ESuites.ts |
Registers automation E2E tests. |
src/vs/platform/agentHost/test/node/buildSessionEvents.test.ts |
Tests referenced tool inputs. |
src/vs/platform/agentHost/test/node/agentAutomationService.test.ts |
Tests persistence, execution, and cron. |
src/vs/platform/agentHost/test/electron-browser/remoteAgentHostProtocolClient.test.ts |
Tests remote URI translation. |
src/vs/platform/agentHost/node/sessionPermissions.ts |
Handles referenced tool inputs safely. |
src/vs/platform/agentHost/node/protocolServerHandler.ts |
Routes automation protocol operations. |
src/vs/platform/agentHost/node/agentService.ts |
Integrates host automation execution. |
src/vs/platform/agentHost/node/agentHostStateManager.ts |
Stores automation channel state. |
src/vs/platform/agentHost/electron-browser/localAgentHostService.ts |
Proxies local automation commands. |
src/vs/platform/agentHost/common/state/toolInput.ts |
Adds tool-input helpers. |
src/vs/platform/agentHost/common/state/sessionState.ts |
Exposes automation state types. |
src/vs/platform/agentHost/common/state/sessionReducers.ts |
Exports automation reducers. |
src/vs/platform/agentHost/common/state/sessionActions.ts |
Exposes automation actions. |
src/vs/platform/agentHost/common/state/protocol/version/registry.ts |
Versions automation messages. |
src/vs/platform/agentHost/common/state/protocol/state.ts |
Exports automation state modules. |
src/vs/platform/agentHost/common/state/protocol/reducers.ts |
Exports automation reducers. |
src/vs/platform/agentHost/common/state/protocol/common/state.ts |
Extends snapshot state union. |
src/vs/platform/agentHost/common/state/protocol/common/messages.ts |
Registers automation messages. |
src/vs/platform/agentHost/common/state/protocol/common/commands.ts |
Adds automation capabilities. |
src/vs/platform/agentHost/common/state/protocol/common/actions.ts |
Adds automation action types. |
src/vs/platform/agentHost/common/state/protocol/commands.ts |
Exports automation commands. |
src/vs/platform/agentHost/common/state/protocol/channels-session/state.ts |
Adds automation session provenance. |
src/vs/platform/agentHost/common/state/protocol/channels-root/notifications.ts |
Adds automation catalog notifications. |
src/vs/platform/agentHost/common/state/protocol/channels-automation/state.ts |
Defines automation channel state. |
src/vs/platform/agentHost/common/state/protocol/channels-automation/reducer.ts |
Reduces automation actions. |
src/vs/platform/agentHost/common/state/protocol/channels-automation/commands.ts |
Defines automation commands. |
src/vs/platform/agentHost/common/state/protocol/channels-automation/actions.ts |
Defines automation actions. |
src/vs/platform/agentHost/common/state/protocol/channels-automation-run/state.ts |
Defines run state. |
src/vs/platform/agentHost/common/state/protocol/channels-automation-run/reducer.ts |
Reduces run actions. |
src/vs/platform/agentHost/common/state/protocol/channels-automation-run/actions.ts |
Defines run actions. |
src/vs/platform/agentHost/common/state/protocol/actions.ts |
Exports automation actions. |
src/vs/platform/agentHost/common/state/protocol/action-origin.generated.ts |
Adds action-origin unions. |
src/vs/platform/agentHost/common/state/protocol/.ahp-version |
Updates vendored AHP revision. |
src/vs/platform/agentHost/common/state/agentSubscription.ts |
Adds automation subscriptions. |
src/vs/platform/agentHost/common/agentService.ts |
Extends host service contracts. |
src/vs/platform/agentHost/common/agent.ts |
Adds session-origin configuration. |
src/vs/platform/agentHost/browser/remoteAgentHostProtocolClient.ts |
Adds remote automation transport. |
src/vs/platform/agentHost/browser/nullAgentHostService.ts |
Implements null automation methods. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Suppressed comments (2)
src/vs/platform/agentHost/node/agentAutomationService.ts:208
- Disposal removes run state but leaves
_requestRunsand_initialTurnIdspersisted. Recreating the same automation URI and reusing a request ID then returns the deleted run URI instead of starting a run, and repeated create/dispose cycles leak durable metadata.
src/vs/platform/agentHost/node/agentAutomationService.ts:685 - Schedule validation/preview can synchronously scan up to 527,040 minutes, and
getZonedPartsconstructs a newIntl.DateTimeFormatfor every candidate. An impossible cron such as February 31 therefore performs hundreds of thousands of formatter constructions on the Agent Host event loop per request. Reuse one formatter per time zone and use a bounded cron/calendar next-occurrence algorithm rather than minute-by-minute probing.
- Files reviewed: 83/83 changed files
- Comments generated: 6
- Review effort level: Balanced
032f567 to
fa48f6d
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 935e37c8-2b68-40b1-9273-f195cb3af9a0
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1131c2f6-bcd0-4012-9265-fdb2685179e7
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1131c2f6-bcd0-4012-9265-fdb2685179e7
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1131c2f6-bcd0-4012-9265-fdb2685179e7
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1131c2f6-bcd0-4012-9265-fdb2685179e7
- reject server-only automation-run actions from clients instead of applying them as authoritative host state - enforce the advertised run-history retention limit and release the bookkeeping of pruned or disposed runs - claim the single active-run slot per dispatch so several triggers due in the same tick cannot start duplicate runs - reject event triggers this authority neither advertises nor fires - project host-permitted operations and gate edit, run, and delete - resolve run cancellation only once the host reports a terminal run Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1131c2f6-bcd0-4012-9265-fdb2685179e7
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>\nCopilot-Session: 1131c2f6-bcd0-4012-9265-fdb2685179e7
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>\nCopilot-Session: 1131c2f6-bcd0-4012-9265-fdb2685179e7
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>\nCopilot-Session: 1131c2f6-bcd0-4012-9265-fdb2685179e7
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>\nCopilot-Session: 1131c2f6-bcd0-4012-9265-fdb2685179e7
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>\nCopilot-Session: 1131c2f6-bcd0-4012-9265-fdb2685179e7
75b6f6d to
b8de382
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>\nCopilot-Session: 1131c2f6-bcd0-4012-9265-fdb2685179e7
| @IWorkspaceTrustManagementService workspaceTrustManagementService: IWorkspaceTrustManagementService, | ||
| ) { | ||
| super(chatSessionsService, chatService, chatWidgetService, languageModelsService, _configurationService, logService, gitHubService, instantiationService, sessionsService, activeClientService, storageService, dialogService, workspaceTrustManagementService); | ||
| this.automations = this._register(instantiationService.createInstance(AutomationStore, providerAutomationStorageKey(this.id))); |
There was a problem hiding this comment.
It looks like this change will bring us one layer closer to a central automation service that then talks to AHP.
Based on conversations with Sandeep Somavarapu (@sandy081), I think the general direction here would be to keep client-side providers as the thing that talks to the provider itself (so localAgentHostSessionsProvider talks to the agent host directly rather than a service within vs code).
| try { | ||
| await this.sessionsManagementService.cancelCurrentRequest(session); | ||
| status(localize('automationRunSessionStoppedStatus', "Stopped the session for {0}", automationName)); | ||
| await this.automationService.cancelRun(run.id); |
There was a problem hiding this comment.
Sandeep Somavarapu (@sandy081) has given me feedback that generally the only thing that should talk to the providers is the session management service, I wonder if this could stay as cancelCurrentRequest or if we could add some new API to session management service to act as the main communicator between the client and providers
| const current: IAutomation = { | ||
| automation: existing, | ||
| runs: ledger.runs.filter(run => run.automationId === automation.id), | ||
| private async _syncSources(connections: readonly { readonly info: IAgentHostConnectionInfo; readonly support: 'unknown' | 'capable' | 'unsupported' }[]): Promise<void> { |
There was a problem hiding this comment.
Same general comment about central automation service vs. provider-owned object that talks to their respective connections
Sync AHP a8643069, implement the specified cron grammar in the local host, and safely project the simple schedule subset in the Agents window. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1131c2f6-bcd0-4012-9265-fdb2685179e7
Migrate legacy schedules directly into the final AHP cron shape, retain overdue occurrences through the disabled import cutover, and durably claim due runs before execution. Gate scheduled execution on provider-specific authentication and retry immediately when credentials arrive. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1131c2f6-bcd0-4012-9265-fdb2685179e7
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1131c2f6-bcd0-4012-9265-fdb2685179e7 # Conflicts: # .github/skills/sessions/SKILL.md # src/vs/platform/agentHost/common/agent.ts # src/vs/platform/agentHost/node/agentHostAuthenticationService.ts # src/vs/platform/agentHost/node/agentService.ts # src/vs/platform/agentHost/node/claude/claudeAgent.ts # src/vs/platform/agentHost/node/codex/codexAgent.ts # src/vs/platform/agentHost/node/copilot/copilotAgent.ts # src/vs/sessions/SESSIONS.md # src/vs/sessions/contrib/sessions/test/browser/automationsView.test.ts
Point the vendored protocol metadata at the conflict-resolved AHP branch head used by this implementation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1131c2f6-bcd0-4012-9265-fdb2685179e7
Summary
Move Agents-window Automations from renderer-owned scheduling to the Agent
Host, using the shared Automation channels added in
microsoft/agent-host-protocol#393.
The Agent Host now owns definitions, triggers, scheduling, run claims,
execution, and run history. The Agents window is a projection and command
surface over host state. Existing local automations migrate automatically, and
the legacy renderer/provider automation implementations are removed.
Why
Previously each Agents window scheduled from renderer state. Multi-window
correctness depended on leader election, schedules only ran while a window was
open, and no other AHP client could share the catalogue or run history.
Host ownership gives every client connected to one authority a synchronized
catalogue, one scheduler, and one execution claim.
What changed
Agent Host
ahp-automation:andahp-automation-run:state, commands,reducers, subscriptions, catalogue notifications, and local persistence.
months/weekdays, ranges, lists, steps, Sunday
0/7, and Unixday-of-month/day-of-week semantics.
requestIdvalues are durable idempotency keys.effects, so a host restart cannot dispatch the same occurrence twice.
HostRestarted.due run. Due work remains pending while signed out and retries immediately
after authentication; manual runs return structured
AuthRequired.created after cancellation are disposed.
Agents window
AutomationServicediscovers capable Agent Host authorities,projects their catalogues, subscribes to definitions/runs, and routes
mutations by authority-qualified resource.
Arbitrary cron, foreign-time-zone, and unsupported trigger definitions remain
visible but read-only.
fallback execution are removed.
Crash-safe migration
Migration is journaled per legacy source:
previewed → imported → localDisabled → localRemoved → hostEnabled → completed(or
aborted).chat.automations.ledgerandchat.automations.provider.local-agent-host.ledger.intermediate AHP-store migration.
unevaluated occurrence in the journal.
unchanged source with compare-and-swap, then enables the host copy.
therefore runs only after cutover and remains recoverable across restart.
enabling stale work.
history-import command.
Automation-run sessions
Current
mainhides sessions marked withISession.isAutomationfrom theSessions list. This branch preserves that behavior without the retired provider
ledger:
SessionSummary.origintravels through local/remote listings,notifications, and the persisted renderer cache.
AgentHostSessionAdapter.isAutomationderives fromSessionOriginKind.Automation.audit.
Promotion into the normal Sessions list remains a separate protocol design
decision; this PR does not clear provenance or infer promotion from run-history
deletion.
Compatibility with current main
mainthrough590ea12d448.b4620983.customization, custom-view, and Sessions-list contracts.
Validation
npm run typecheck-clientnpm run valid-layers-checknpm run hygieneSessions-list tests
git diff --checkNotes for reviewers
AgentAutomationService→ Agent Host state/transportwiring → renderer
AutomationService→ migration → UI.