Skip to content

automations: feat: move automations to the agent host via AHP - #330463

Draft
Ulugbek Abdullaev (ulugbekna) wants to merge 16 commits into
microsoft:mainfrom
ulugbekna:ulugbekna/agents/vscode-github-copilot-automation-comparison
Draft

automations: feat: move automations to the agent host via AHP#330463
Ulugbek Abdullaev (ulugbekna) wants to merge 16 commits into
microsoft:mainfrom
ulugbekna:ulugbekna/agents/vscode-github-copilot-automation-comparison

Conversation

@ulugbekna

@ulugbekna Ulugbek Abdullaev (ulugbekna) commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

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

  • Added durable ahp-automation: and ahp-automation-run: state, commands,
    reducers, subscriptions, catalogue notifications, and local persistence.
  • Added portable five-field cron evaluation with IANA time zones, named
    months/weekdays, ranges, lists, steps, Sunday 0/7, and Unix
    day-of-month/day-of-week semantics.
  • Manual requestId values are durable idempotency keys.
  • Due schedule cursors advance with the durable run record before session side
    effects, so a host restart cannot dispatch the same occurrence twice.
  • Interrupted non-terminal runs recover as failed with HostRestarted.
  • Provider/model-route-specific authentication is checked before claiming a
    due run. Due work remains pending while signed out and retries immediately
    after authentication; manual runs return structured AuthRequired.
  • Cancellation is rechecked after asynchronous boundaries, and sessions
    created after cancellation are disposed.

Agents window

  • The global AutomationService discovers capable Agent Host authorities,
    projects their catalogues, subscribes to definitions/runs, and routes
    mutations by authority-qualified resource.
  • The simple hourly/daily/weekly editor round-trips through canonical cron.
    Arbitrary cron, foreign-time-zone, and unsupported trigger definitions remain
    visible but read-only.
  • Renderer scheduling, leader election, provider automation stores, and local
    fallback execution are removed.

Crash-safe migration

Migration is journaled per legacy source:

previewed → imported → localDisabled → localRemoved → hostEnabled → completed
(or aborted).

  • Migrates both chat.automations.ledger and
    chat.automations.provider.local-agent-host.ledger.
  • Writes the final portable-cron AHP shape directly; there is no unpublished
    intermediate AHP-store migration.
  • Pins the normalized disabled definition and the legacy scheduler's next
    unevaluated occurrence in the journal.
  • Imports the host definition disabled, verifies it, disables/removes the exact
    unchanged source with compare-and-swap, then enables the host copy.
  • Enablement persists before an immediate scheduler tick. An overdue occurrence
    therefore runs only after cutover and remains recoverable across restart.
  • Concurrent legacy cursor/run changes block destructive migration rather than
    enabling stale work.
  • Legacy execution history stays in the inert backup because AHP 0.8 has no
    history-import command.

Automation-run sessions

Current main hides sessions marked with ISession.isAutomation from the
Sessions list. This branch preserves that behavior without the retired provider
ledger:

  • AHP SessionSummary.origin travels through local/remote listings,
    notifications, and the persisted renderer cache.
  • AgentHostSessionAdapter.isAutomation derives from
    SessionOriginKind.Automation.
  • The immutable automation/run provenance remains available for navigation and
    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

  • Merged VS Code main through 590ea12d448.
  • Vendored protocol metadata points at conflict-resolved AHP head b4620983.
  • Preserves current instruction resolution, authentication revocation, scoped
    customization, custom-view, and Sessions-list contracts.

Validation

  • npm run typecheck-client
  • npm run valid-layers-check
  • npm run hygiene
  • 458 focused automation, protocol, provider, Automations-view, and
    Sessions-list tests
  • 2 focused Copilot/Claude model-route authentication tests
  • pre-commit hygiene and git diff --check

Notes for reviewers

  • Suggested reading order: AgentAutomationService → Agent Host state/transport
    wiring → renderer AutomationService → migration → UI.
  • This draft depends on the AHP PR above.

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

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 _requestRuns and _initialTurnIds persisted. 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 getZonedParts constructs a new Intl.DateTimeFormat for 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

Comment thread src/vs/platform/agentHost/node/protocolServerHandler.ts
Comment thread src/vs/platform/agentHost/node/agentAutomationService.ts Outdated
Comment thread src/vs/platform/agentHost/node/agentAutomationService.ts Outdated
Comment thread src/vs/platform/agentHost/node/agentAutomationService.ts
Comment thread src/vs/workbench/contrib/chat/common/automations/automation.ts
Comment thread src/vs/sessions/contrib/automations/browser/automationService.ts
@ulugbekna
Ulugbek Abdullaev (ulugbekna) force-pushed the ulugbekna/agents/vscode-github-copilot-automation-comparison branch from 032f567 to fa48f6d Compare August 12, 2026 16:24
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
@ulugbekna
Ulugbek Abdullaev (ulugbekna) force-pushed the ulugbekna/agents/vscode-github-copilot-automation-comparison branch from 75b6f6d to b8de382 Compare August 12, 2026 17:09
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)));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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> {

@benvillalobos Ben Villalobos (benvillalobos) Aug 12, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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
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.

3 participants