Local agents in Visual Studio Code
Local agents run directly within VS Code on your machine. You interact with local agents through chat to get immediate results to your prompts. Local agents work on your workspace and have access to the full range of tools and models available in VS Code. By creating custom agents, you can let the agent assume a specific role or persona for a task, such as a code reviewer, tester, or documentation writer.
Local agents operate in the chat interface in VS Code. When you close a chat session, the local agent remains active and you can track it in the sessions view.
Why use local agents?
- Interactive conversations that require immediate feedback, such as brainstorming, planning, or tasks that aren't yet fully defined
- Tasks that require context from your developer environment, such as linting errors, stack traces, unit test results
- Tasks that require access to specific tools from VS Code extensions or MCP servers or need to use specific models like BYOK models
- Tasks that don't require collaboration from other team members
Key characteristics
- Runs within VS Code on your local machine and works on your current workspace
- Interactive chat-based interface for real-time feedback and iteration
- Full access to your workspace, files, and context
- Can access all agent tools configured in VS Code, such as built-in tools, MCP tools, and extension-provided tools
- Can use all models available to you in VS Code, including BYOK models and models from other providers
Built-in agents
Local agent sessions use one of three built-in agents, each optimized for different types of tasks. You can switch between agents at any time during a chat session by selecting a different agent from the agent picker in the Chat view. For more specialized workflows, you can create your own custom agents.
Agent
Agent is optimized for complex coding tasks based on high-level requirements that might require running terminal commands and tools. The AI operates autonomously, determining the relevant context and files to edit, planning the work needed, and iterating to resolve problems as they arise.
VS Code directly applies code changes in the editor, and the editor overlay controls enable you to navigate between the suggested edits and review them. The agent might invoke multiple tools to accomplish different tasks.
You can customize chat with extra tools by adding MCP servers or installing extensions that contribute tools.
Open chat with Agent: Stable | Insiders
If you don't see the agent option, make sure agents are enabled in your VS Code settings (
Plan
The plan agent is optimized for creating a structured implementation plan for a coding task. Use the plan agent when you want to break down a complex feature or change into smaller, manageable steps before implementation.
The plan agent generates a detailed plan outlining the steps needed and asks clarifying questions to ensure a comprehensive understanding of the task. You can then hand off the plan to an implementation agent or use it as a guide.
Open chat with Plan: Stable | Insiders
Learn more about planning with agents.
Ask
The Ask feature works best for answering questions about your codebase, coding, and general technology concepts. Use Ask when you want to understand how something works, explore ideas, or get help with coding tasks.
Ask uses agentic capabilities to research your codebase and gather relevant context. Responses can contain code blocks that you apply individually to your codebase. To apply a code block, hover over the code block and select the Apply in Editor button.
Open chat by using Ask: Stable | Insiders
Get started
For a hands-on tutorial that demonstrates working with different agent types including background and cloud agents, see the agents tutorial.
To start a local agent session:
-
Select Agent from the agent picker in the Chat view.
-
Type a high-level prompt in the chat input field. For example, you might ask:
Implement a user authentication system with OAuth2 and JWT.or
Set up a CI/CD pipeline for this project. -
Use the tools picker to enable tools and give the agent more capabilities.
-
Select Send or press Enter to submit your prompt.
-
Review and confirm code changes and tool invocations as the agent works through your request.
TipVS Code helps you protect against inadvertent edits to sensitive files, such as workspace configuration settings or environment settings. Learn more about editing sensitive files.
To start with Ask:
-
Type your prompt in the chat input field. For example, you might ask:
Provide 3 ways to implement a search feature in React.or
Where is the db connection configured in this project? #codebase -
Select Ask from the agent picker in the Chat view.
-
Optionally, add context to your prompt to get more accurate responses.
-
Select Send or press Enter to submit your prompt.
Related resources
- Agents overview: Overview of agent types and session management.
- Agents tutorial: Hands-on tutorial for working with different agent types.
- Tools: Extend agents with built-in, MCP, and extension tools.
- Custom agents: Create your own AI agents and extensions.
- Chat: Learn about the chat interface and interaction features.