Language Model Integration (AI Features)
Relevant source files
The following files were used as context for generating this wiki page:
- src/vscode-dts/vscode.proposed.chatProvider.d.ts
- src/vscode-dts/vscode.proposed.languageModelDataPart.d.ts
- src/vscode-dts/vscode.proposed.inlineCompletionsAdditions.d.ts
- extensions/vscode-api-tests/package.json
- extensions/markdown-language-features/package.json
- extensions/typescript-language-features/package.nls.json
- extensions/markdown-language-features/package.nls.json
- extensions/markdown-math/package.json
Visual Studio Code integrates Language Model (LM) and other AI-driven capabilities to provide rich, intelligent features for developers. This integration is primarily achieved through a set of extension contribution points and proposed APIs that allow extensions to register language models, participate in chat interfaces, and enhance existing language support with smart suggestions and actions.
The architecture is designed to be extensible, enabling both first-party and third-party extensions to contribute AI-powered functionality. This includes features like interactive chat agents, advanced code completions, and automated tasks. Activation of these features is often tied to specific languages or commands, ensuring they are loaded on demand.
Extension Contribution Points for AI
Extensions can register AI-related capabilities through various contribution points in their package.json manifest. These points define how an extension interacts with VS Code's core AI systems.
Sources: extensions/vscode-api-tests/package.json:38-76
The following diagram illustrates how an extension contributes different AI components.
This diagram shows that an extension's package.json can declare language models, chat participants, and tools, which are then registered with the VS Code core to power features like the Chat View.
Language Models (languageModels)
This contribution point allows an extension to declare that it provides a language model from a specific vendor. This is the entry point for an extension to make a new LM available within VS Code.
"contributes": {
"languageModels": [
{
"vendor": "test-lm-vendor"
}
]
}
Sources: extensions/vscode-api-tests/package.json:39-43
Chat Participants (chatParticipants)
Extensions can add new agents or participants to the chat interface using the chatParticipants contribution point. Each participant has a unique ID, a display name, and can register slash commands to trigger specific actions.
"chatParticipants": [
{
"id": "api-test.participant",
"name": "participant",
"description": "test",
"isDefault": true,
"commands": [
{
"name": "hello",
"description": "Hello"
}
],
"modes": [
"agent", "ask", "edit"
]
}
]
Sources: extensions/vscode-api-tests/package.json:44-62
The table below details the properties for a chat participant.
| Property | Type | Description |
|---|---|---|
id | string | A unique identifier for the chat participant. |
name | string | The display name of the participant in the chat UI. |
description | string | A short description of the participant's capabilities. |
isDefault | boolean | If true, this participant may be used to satisfy generic requests. |
commands | array | A list of slash commands that the participant responds to. |
modes | array | Defines the interaction modes the participant supports (e.g., agent, ask, edit). |
Sources: extensions/vscode-api-tests/package.json:45-61
Language Model Tools (languageModelTools)
Extensions can define tools that a language model can invoke. This allows LMs to perform actions beyond text generation, such as triggering confirmations or accessing other editor functionalities.
"languageModelTools": [
{
"name": "requires_confirmation_tool",
"toolReferenceName": "requires_confirmation_tool",
"displayName": "Requires Confirmation Tool",
"modelDescription": "A noop tool to trigger confirmation.",
"canBeReferencedInPrompt": true,
"icon": "$(files)",
"inputSchema": {}
}
]
Sources: extensions/vscode-api-tests/package.json:63-74
Core AI API Proposals
The AI features are powered by a set of proposed APIs that are still under development. An extension must declare its use of these proposals in the enabledApiProposals array in its package.json.
| API Proposal | Description |
|---|---|
chatProvider | Enables extensions to provide chat functionality and participants. |
chatParticipantPrivate | Likely related to private data handling for chat participants. |
defaultChatParticipant | Allows an extension to register a default chat participant. |
embeddings | Provides an API for working with text embeddings, useful for semantic search and other ML tasks. |
interactive | Relates to the interactive session or playground for AI features. |
Sources: extensions/vscode-api-tests/package.json:7-36
AI-Powered Feature Implementations
Several built-in extensions use AI or AI-like "smart" features to enhance the user experience.
Markdown Language Features
The markdown-language-features extension is activated for special language modes like prompt, instructions, and chatmode, indicating its role in AI-driven interactions. It also includes an aiKey for telemetry, suggesting it collects data related to AI feature usage.
Sources: extensions/markdown-language-features/package.json:11, extensions/markdown-language-features/package.json:23-26
The activation flow for a chat-related feature in Markdown can be visualized as follows:
This diagram shows that when a user interacts with a file type like chatmode, VS Code activates the Markdown extension, which then provides its specialized language support.
TypeScript and JavaScript IntelliSense
The built-in TypeScript/JavaScript extension provides numerous "smart" features that behave like AI-driven assistance, enhancing developer productivity. These features are highly configurable.
| Configuration | Description |
|---|---|
typescript.disableAutomaticTypeAcquisition | Disables fetching of @types packages from npm, which improves IntelliSense for external libraries. |
configuration.suggest.autoImports | Enable/disable auto import suggestions. |
configuration.suggest.completeFunctionCalls | Complete functions with their full parameter signature. |
typescript.updateImportsOnFileMove.enabled | Automatically updates import paths when a file is renamed or moved. |
typescript.preferences.includePackageJsonAutoImports | Enable/disable searching package.json dependencies for available auto imports. |
configuration.suggest.names | Enable/disable including unique names from the file in JavaScript suggestions. |
Sources: extensions/typescript-language-features/package.nls.json:13, extensions/typescript-language-features/package.nls.json:96, extensions/typescript-language-features/package.nls.json:9, extensions/typescript-language-features/package.nls.json:126, extensions/typescript-language-features/package.nls.json:117, extensions/typescript-language-features/package.nls.json:52
Conclusion
VS Code's language model integration provides a powerful and flexible framework for building AI-powered developer tools. By leveraging extension contribution points like languageModels and chatParticipants, and a suite of proposed APIs, developers can create sophisticated features ranging from intelligent chat agents to advanced, context-aware code suggestions. The architecture demonstrates a commitment to an extensible ecosystem where both core features and third-party extensions can benefit from the advancements in artificial intelligence.