src/vs/platform/agentHost/sessions.md
Keep this document in sync with the code. If you change how session types are registered, modify the extension point, or update the agent-host's registration pattern, update this document as part of the same change.
There are three layers that connect to form a chat session type (like "Background Agent" / "Copilot CLI"):
chatSessions Extension Point (package.json)In package.json, the extension contributes to the "chatSessions" extension point. Each entry declares a session type (used as a URI scheme), a name (used as a chat participant name like @cli), display metadata, capabilities, slash commands, and a when clause for conditional availability.
On the VS Code side:
chatSessions.contribution.ts -- Registers the chatSessions extension point via ExtensionsRegistry.registerExtensionPoint. When extensions contribute to it, the ChatSessionsService processes each contribution: it sets up context keys, icons, welcome messages, commands, and -- if canDelegate is true -- also registers a dynamic chat agent.
chatSessionsService.ts -- The IChatSessionsService interface manages two kinds of providers:
IChatSessionItemController -- Lists available sessionsIChatSessionContentProvider -- Provides session content (history + request handler) when you open a specific sessionagentSessions.ts -- The AgentSessionProviders enum maps well-known types to their string identifiers:
Local = 'local'Background = 'copilotcli'Cloud = 'copilot-cloud-agent'Claude = 'claude-code'Codex = 'openai-codex'Growth = 'copilot-growth'AgentHostCopilot = 'agent-host-copilot'Each session type registers three things via the proposed API:
vscode.chat.registerChatSessionItemProvider(type, provider) -- Provides the list of sessionsvscode.chat.createChatParticipant(type, handler) -- Creates the chat participantvscode.chat.registerChatSessionContentProvider(type, contentProvider, chatParticipant) -- Binds content provider to participantThe agent-host session types (agent-host-copilot) bypass the extension point entirely. A single AgentHostContribution discovers available agents from the agent host process via listAgents() and dynamically registers each one:
For each IAgentDescriptor returned by listAgents():
IChatSessionsService.registerChatSessionContribution()IChatSessionsService.registerChatSessionItemController()IChatSessionsService.registerChatSessionContentProvider()ILanguageModelsService.registerLanguageModelProvider()descriptor.requiresAuth is true)All use the same generic AgentHostSessionHandler class, configured with the descriptor's metadata.
| # | Entry Point | File |
|---|---|---|
| 1 | package.json chatSessions contribution | package.json -- declares type, name, capabilities |
| 2 | Extension point handler | chatSessions.contribution.ts -- processes contributions |
| 3 | Service interface | chatSessionsService.ts -- IChatSessionsService |
| 4 | Proposed API | vscode.proposed.chatSessionsProvider.d.ts |
| 5 | Agent session provider enum | agentSessions.ts -- AgentSessionProviders |
| 6 | Agent Host contribution | agentHost/agentHostChatContribution.ts -- AgentHostContribution (discovers + registers dynamically) |
| 7 | Agent Host process | src/vs/platform/agent/ -- utility process, SDK integration |
| 8 | Desktop registration | electron-browser/chat.contribution.ts -- registers AgentHostContribution |