* agentHost: support copilotd metadata and schema controls Normalize VS Code and copilotd metadata behind host-neutral helpers and recognize the advertised session/model configuration keys. Preserve compatible outgoing metadata, retries, steering display records, and context usage across restoration. Keep generated declarations pinned without vendoring schemas, and add shared compatibility and real-handler wire regression coverage. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * agentHost: add app-compatible tool presentation fallbacks Recognize known Copilot app tool aliases when host presentation is generic, while preserving explicit metadata and existing tool cards. Keep replacement request metadata across retries. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * agentHost: simplify config properties and defer prompt metadata Replace generic enum bindings with concrete schema-property selectors and explicit approval/isolation conversions. Remove model-text and command-marker support, their generated contracts, contribution and custom persistence for a separate change. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * agentHost: break tool presentation import cycle Move inline tool-input extraction to the dependency-light input module and retain the sessionState re-export. Keep Copilot tool presentation from importing the state facade that already depends on metadata readers. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * agentHost: repair session picker fixture setup Keep fixture providers aligned with schema-aware pickers and register their quick input dependency, fixing screenshot render failures without changing production behavior. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
3.5 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.
Protocol Metadata
Put new readers for namespaced protocol _meta slots under common/meta. Readers must validate every value they return and expose typed data; callers should pass the parent protocol object rather than inspecting _meta fields directly. Existing unnamespaced and legacy readers live elsewhere and should be migrated separately when touched. Use type guards for dynamic properties; do not bypass type narrowing or lint rules with Reflect.get.
Host-specific parsers and writers live under common/meta/vscode and common/meta/copilotd. Feature code imports only top-level common/meta helpers, which own source selection and domain conversion; ESLint enforces this boundary for value and type imports.
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.