Plan, build, test, and fix — all from one prompt.
Agent mode is now available in public preview for all users in Visual Studio 17.14. Agent mode in Visual Studio allows you to define tasks using natural language, with Copilot autonomously planning, editing your codebase, invoking tools, and iterating to resolve issues. Unlike Copilot Chat or Edits, agent mode doesn’t stop at one suggestion or file edit but works iteratively until the task is complete.
What can agent mode do?
Agent mode doesn’t just help you write code — it helps you finish the job. All of this is done iteratively, meaning that Copilot will continue to examine and perform your task on its own output and the result of that output until it completes your prompt. This means agent mode can:
Autonomously determine the relevant context and files to edit.
Suggest terminal commands for you to approve and run.
Iterate until the task is complete — checking for errors, and running builds/tests to validate results.
Invoke trusted tools via MCP servers — including linters, test runners, and static analyzers in your dev environment.
We’re also simplifying the Copilot experience by making agent mode the new default way to apply code changes. You can think of agent mode as the next evolution of Edits which developers have come to love in GitHub Copilot chat with even more power!
How to enable it
Agent mode is off by default in this preview phase. To turn it on:
- Use Visual Studio Code 17.14 GA or later
- Go to Feature Search (Ctrl + Q)
- Search: copilot-chat.agent
- Enable: Copilot Chat: Agent Enabled
- In the Copilot Chat window switch to “Agent” and try a high-level prompt. You can access the Copilot Chat window from the Copilot badge in the upper right of the IDE.
Using agent mode
Agent mode is a powerful tool that can be applied in many scenarios. It can create apps from scratch, refactor code across multiple files, write and run tests, generate documentation, integrate new libraries, implement terminal-heavy tasks, and answer questions about complex codebases. It enhances productivity by orchestrating your development flow while keeping you in control. When determining if agent mode is the right tool for the job, consider the following.
- Edit scope: Agent mode takes the reins, autonomously searching your codebase and determining the relevant context and files to edit.
- Task complexity: For intricate tasks that go beyond simple code edits, agent mode shines. It handles tool invocations and terminal commands, making it ideal for complex projects.
- Duration: Agent mode is thorough, involving multiple steps to process a request. It might take longer to get a response as it determines the context, plans the action, and more.
- Self-iteration: One of the standout features of agent mode is its ability to evaluate the outcome of generated edits and iterate multiple times to resolve intermediate issues.
- Multiple requests: Depending on the complexity of the task, agent mode might result in multiple requests to the backend from a single prompt.
Once you’ve determined that agent mode is the right tool for the job, you just need to give it a good prompt. Here are some example prompts to give you an idea of what you can ask the agent to do:
- “Add error handling to this API”
- “Convert this project to use environment variables”
- “Write tests for this class and fix anything that fails”
- “Add structured logging with Serilog”
- “Replace HttpClient with IHttpClientFactory”
A key to better, more accurate responses from Copilot is providing it with sufficient context about your preferred coding standards, team preferences, libraries, and more. You can provide this context with custom instructions. The custom instructions feature enables you to automatically add pre-specified contextual details to your chat questions. To configure custom instructions, follow the documentation instructions.
Boost agent mode with MCP servers
This release further extends the power of agent mode by supporting Model Context Protocol (MCP) servers. MCP servers provide additional context to the Copilot agent and give it access to tools, data, and resources. The MCP website describes MCP as a universal adaptor for AI applications. In the same way that a universal adaptor lets you connect your physical devices to accessories, MCP lets you connect AI applications to other data and tools without needing to build a custom connection to each data source. For example, you can connect directly to your database and analyze schemes, pull in information for GitHub repos such as issues and pull requests, automate end-to-end testing with Playwright, or you can even build your own with several SDKs including C#! Here are a few other examples of what you can do with MCP servers:
Interact with your cloud environment: For example, the official Azure MCP server gives access to list, query, and interact with services and tools like Azure Storage, Cosmos DB, the Azure CLI, and more.
Query and manage database: Execute queries against Cosmos DB containers, get Azure Storage container properties and metadata, and manage blob containers and blobs.
Search and manage version control platform: For example, the GitHub API allows batch creation of issues or batch updates of files, can search for code and issues across GitHub repositories, and more.
More updates with new monthly release schedule for Copilot
We’re constantly evolving to get Copilot features out so that you, the developer, are never behind. As such, we’re excited to announce that Visual Studio is moving to a monthly release schedule for Copilot updates. You can access the latest Copilot updates by continuing to update Visual Studio to the latest version.
Check out the new Visual Studio Hub
Stay connected with everything Visual Studio in one place! Visit the Visual Studio Hub for the latest release notes, YouTube videos, social updates, and community discussions.
Appreciation for your feedback
Your feedback helps us improve Visual Studio, making it an even more powerful tool for developers. We are immensely grateful for your contributions and look forward to your continued support. By sharing your thoughts, ideas, and any issues you encounter through Developer Community, you help us improve and shape the future of Visual Studio.
The post Agent mode has arrived in preview for Visual Studio appeared first on Visual Studio Blog.