Skip to content

Agent Host: Add Dev Container sessions - #331934

Merged
Christof Marti (chrmarti) merged 19 commits into
mainfrom
chrmarti/bad-earthworm
Aug 27, 2026
Merged

Christof Marti (chrmarti) merged 19 commits into
mainfrom
chrmarti/bad-earthworm

Conversation

@chrmarti

Copy link
Copy Markdown
Collaborator

Summary

Adds an initial Dev Container execution target for Agent Host sessions in the Agents window. Users can start a session from a local folder's existing Dev Container configuration and run the Agent Host inside the container.

Part of #317380.

Session Context

Key decisions from the development session:

  • Existing environment first: This initial implementation reuses the selected folder's .devcontainer/devcontainer.json or .devcontainer.json, matching the primary user need to run agents with the project's existing tools and dependencies. It does not claim that arbitrary Dev Container configurations are hardened security sandboxes.
  • Local initial scope: The checkbox is offered only for local file workspaces when Docker is available. Full composition with SSH, WSL, Dev Tunnels, and named-volume cloning remains future work.
  • Shared-process ownership: Container creation, VS Code CLI installation, Agent Host startup, and the raw relay run in the shared process, parallel to the existing SSH architecture. The renderer owns the protocol client and dynamic Sessions provider.
  • Draft handoff: The composer begins with a local draft because no container provider exists yet. On foreground Send, the draft immediately becomes In Progress while the container starts; once connected, it is replaced by an In Progress container-owned draft before createNewChat.
  • Failure behavior: Preparation failures restore the original local draft to Untitled rather than leaving a stuck in-progress session.
  • CLI distribution: VS Code bundles a pinned @devcontainers/cli and launches it through Electron-as-Node instead of relying on a separately installed CLI.
  • Output channels: Dev Container CLI output is retained in one stable Dev Container (<workspace>) Output channel per source workspace, reused across connection attempts.
  • Control ordering: New Worktree remains left of Dev Container across asynchronous availability and config rerenders.

Changes

  • Add the Dev Container checkbox to local Agent Host drafts when Docker and a supported config are present.
  • Start or reuse the container with the bundled Dev Container CLI.
  • Install/reuse the matching VS Code CLI and standalone Agent Host inside the container.
  • Relay AHP over devcontainer exec through the shared process.
  • Register a dynamic remote Agent Host provider for the container workspace.
  • Transfer compatible config/model/mode state from the local draft to the container draft.
  • Stream container setup output to a workspace-specific Output channel.
  • Add lifecycle, availability, draft replacement, rollback, packaging, and UI-ordering coverage.

Validation

  • Client and build-tool typechecks
  • Hygiene and layer validation
  • Focused and full Sessions/Agent Host unit suites
  • Live end-to-end validation against this repository's Dev Container, including a completed Agent Host turn from /workspaces/vscode

Copilot AI balanced review requested due to automatic review settings August 21, 2026 10:26

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

Adds Dev Container execution for Agent Host sessions in the Agents window.

Changes:

  • Adds Dev Container discovery, UI selection, and draft handoff.
  • Launches and connects Agent Host inside containers through the shared process.
  • Adds packaging, lifecycle, and unit-test coverage.
Show a summary per file
File Description
src/vs/sessions/sessions.desktop.main.ts Loads Dev Container contributions.
src/vs/sessions/services/sessions/test/browser/sessionsManagementService.test.ts Tests draft replacement and rollback.
src/vs/sessions/services/sessions/common/sessionsProvider.ts Adds session preparation contract.
src/vs/sessions/services/sessions/browser/sessionsService.ts Reflects prepared draft replacements.
src/vs/sessions/services/sessions/browser/sessionsManagementService.ts Orchestrates pre-send preparation.
src/vs/sessions/contrib/providers/remoteAgentHost/test/electron-browser/devContainerAgentHostConnector.test.ts Tests availability detection.
src/vs/sessions/contrib/providers/remoteAgentHost/test/browser/devContainerAgentHostService.test.ts Tests dynamic provider lifecycle.
src/vs/sessions/contrib/providers/remoteAgentHost/REMOTE_AGENT_HOST_SESSIONS_PROVIDER.md Documents container connections.
src/vs/sessions/contrib/providers/remoteAgentHost/electron-browser/devContainerAgentHostConnector.contribution.ts Implements renderer connector and output.
src/vs/sessions/contrib/providers/remoteAgentHost/browser/devContainerAgentHostService.ts Manages connections and providers.
src/vs/sessions/contrib/providers/agentHost/test/browser/localAgentHostSessionsProvider.test.ts Tests container draft preparation.
src/vs/sessions/contrib/providers/agentHost/test/browser/agentHost/agentHostSessionConfigPicker.test.ts Tests checkbox rendering and order.
src/vs/sessions/contrib/providers/agentHost/browser/media/agentHostSessionConfigPicker.css Generalizes checkbox styling.
src/vs/sessions/contrib/providers/agentHost/browser/localAgentHostSessionsProvider.ts Implements local-to-container handoff.
src/vs/sessions/contrib/providers/agentHost/browser/baseAgentHostSessionsProvider.ts Restores draft status after activity.
src/vs/sessions/contrib/providers/agentHost/browser/agentHostSessionConfigPicker.ts Adds the Dev Container checkbox.
src/vs/sessions/contrib/providers/agentHost/AGENT_HOST_SESSIONS_PROVIDER.md Documents draft handoff behavior.
src/vs/sessions/common/devContainerAgentHostService.ts Defines the Sessions service contract.
src/vs/sessions/common/agentHostSessionsProvider.ts Exposes container draft controls.
src/vs/platform/agentHost/test/node/devContainerAgentHostService.test.ts Tests CLI launch and relay setup.
src/vs/platform/agentHost/test/electron-browser/remoteAgentHostService.test.ts Covers the new runtime entry type.
src/vs/platform/agentHost/node/sshRemoteAgentHostService.ts Reuses the extracted CLI installer.
src/vs/platform/agentHost/node/remoteAgentHostCliInstaller.ts Extracts shared remote CLI installation.
src/vs/platform/agentHost/node/devContainerAgentHostService.ts Runs Dev Containers and protocol relays.
src/vs/platform/agentHost/common/remoteAgentHostService.ts Adds the Dev Container connection type.
src/vs/platform/agentHost/common/devContainerAgentHost.ts Defines shared-process IPC contracts.
src/vs/platform/agentHost/common/agentHostTelemetry.ts Adds the telemetry connection kind.
src/vs/code/electron-utility/sharedProcess/sharedProcessMain.ts Registers the shared-process service.
package.json Adds the pinned Dev Container CLI.
package-lock.json Locks the CLI dependency.
build/gulpfile.vscode.ts Unpacks the CLI for spawning.

Review details

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

  • Files reviewed: 30/31 changed files
  • Comments generated: 9
  • Review effort level: Balanced

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Well done. The optimization reduces unnecessary allocations.

@chrmarti
Christof Marti (chrmarti) marked this pull request as ready for review August 27, 2026 10:30
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

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

Robo (@deepak1556)

Matched files:

  • src/vs/code/electron-utility/sharedProcess/sharedProcessMain.ts

Ladislau Szomoru (@lszomoru)

Matched files:

  • src/vs/sessions/services/sessions/browser/sessionsManagementService.ts
  • src/vs/sessions/services/sessions/browser/sessionsService.ts
  • src/vs/sessions/services/sessions/common/sessionsProvider.ts
  • src/vs/sessions/services/sessions/test/browser/sessionsManagementService.test.ts

await service.disconnect('connection');

assert.ok(service.execCommands.some(command =>
command.includes('https://update.code.visualstudio.com/latest/cli-alpine-x64/insider')
@chrmarti
Christof Marti (chrmarti) merged commit a3b089b into main Aug 27, 2026
37 of 38 checks passed
@chrmarti
Christof Marti (chrmarti) deleted the chrmarti/bad-earthworm branch August 27, 2026 11:01
@vs-code-engineering vs-code-engineering Bot added this to the 1.136.0 milestone Aug 27, 2026
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Oct 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants