* Simplify AgentService composition Narrow internal service dependencies, move runtime collaborators out of AgentService, and replace two-phase initialization with a constructor-complete composition. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Define Agent Host service ownership Give the complete Agent Host service graph one disposable runtime owner and document workbench-style placement rules for bootstrap instances, shared orchestration services, and runtime activation. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Document Agent Host service construction Add the target service-placement model and a tested sealable process-local service collection without enabling the seal in production yet. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Create Agent Host service foundation Build callback, state, configuration, authentication, endpoint, proxy, and request foundations before telemetry and share the synchronous path with AgentService tests. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Register Agent Host bootstrap services Migrate bootstrap-owned core and host services to local descriptors, eagerly resolve them under strict DI, and preserve typed test overrides. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Seal the Agent Host service graph Migrate composition-owned and Copilot-dependent services atomically to local descriptors, resolve the complete graph eagerly, and reject late registrations. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Inject AgentService runtime dependencies Make network diagnostics and edit attribution immutable AgentService dependencies and order test-graph teardown after composition-owned listeners. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Activate Agent Host contributions separately Move changeset and completion registrations into an order-preserving post-graph activation phase with explicit disposable ownership. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Finalize the Agent Host service runtime Resolve runtime services through DI, reduce the runtime facade, harden proxy and disposal invariants, and mark the service construction guide current. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Clarify Agent Host child service scopes Define one primary runtime graph while allowing explicitly owned child instantiation services and scoped service collections when isolation requires them. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Document Agent Host service model debt Separate stable service-graph contracts from accepted callback, worktree, foundation, concrete-type, and test-seam warts with explicit exit conditions. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Focus Agent Host bootstrap documentation Rename the service guide, add maintenance rules, explain eager resolution as migration-risk control, and distinguish one primary graph from valid scoped child graphs. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Type customization worktree binding Expose worktree binding as a narrow customization-enablement capability and remove the composition root's concrete implementation assertion. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Remove AgentService state manager escape hatch Route tests through the composition-owned state manager and fix bootstrap cleanup ordering found during review. Clarify descriptor rules for trailing defaulted parameters. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Dispose partial Agent Host contributions Ensure activation failures clean up registrations created earlier in the contribution phase and cover the failure path with a focused test. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Tighten sealed service resolution Allow a sealed descriptor to be replaced only by an instance of its registered constructor, and reject unrelated implementations before descriptor resolution. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2.7 KiB
description, applyTo
| description | applyTo |
|---|---|
| Architecture documentation for VS Code AI Customization view. Use when working in `src/vs/workbench/contrib/chat/browser/aiCustomization` | src/vs/platform/agentHost/** |
Agent Host
The agent host communicates via the Agent Host Protocol. The specification for this lives in a directory ../agent-host-protocol as a sibling of the VS Code directory.
If this directory doesn't exist, you should use the "ask questions" tool to ask the user if they want to clone git@github.com:microsoft/agent-host-protocol.git to that directory. After doing so, you should also prompt the user to add file:///<path/to/agent-host-protocol>/plugins/copilot-plugin as a plugin in their chat.pluginLocations settings.
Overall Protocol
The sessions process is a portable, standalone server that multiple clients can connect to. Clients see a synchronized view of sessions and can send commands that are reflected back as state-changing actions. The protocol is designed around four requirements:
- Synchronized multi-client state — an immutable, redux-like state tree mutated exclusively by actions flowing through pure reducers. While there is the option to implement functionality via imperative commands, we ALWAYS prefer to model features as pure state and actions.
- Lazy loading — clients subscribe to state by URI and load data on demand. The session list is fetched imperatively. Large content (images, long tool outputs) is stored by reference and fetched separately.
- Write-ahead with reconciliation — clients optimistically apply their own actions locally, then reconcile when the server echoes them back alongside any concurrent actions from other clients or the server itself.
- Forward-compatible versioning — newer clients can connect to older servers. A single protocol version number maps to a capabilities object; clients check capabilities before using features.
See the agent host protocol documentation for more details.
Service Construction
Read src/vs/platform/agentHost/node/serviceBootstrapping.md before adding or
moving a node Agent Host service. It is the canonical guide for service
placement, static constructor arguments, activation, test overrides, and
disposal ownership.
End to End Testing
You can run node ./scripts/code-agent-host.js to start an agent host. If you pass --enable-mock-agent, then the ScriptedMockAgent will be used.
By default this will listen on ws://127.0.0.1:8081. You can then use the ahp-websocket client, when available, to connect to and communicate with it.
Learnings
- Provider-owned session configuration inheritance must be selected by the owning
IAgent;AgentServiceonly orchestrates transfer and must not encode provider-specific configuration keys.