Important
Microsoft Copilot uses AI and might make mistakes or misinterpret instructions. Review requests and results carefully, especially before Copilot Code runs commands, connects to the internet, changes files, or before you share personal information. You're responsible for actions Copilot takes on your behalf. By using Copilot, you agree to the Terms of Use. For more information, see the Microsoft Privacy Statement.
Microsoft Copilot Code for personal accounts is currently in Preview.
This information relates to a prerelease product that may be substantially modified before it's released. Microsoft makes no warranties, expressed or implied, with respect to the information provided here.
Copilot Code can run a project on your device. Review approval prompts before Copilot Code runs commands, connects to the internet, or accesses files outside the project folder. Once approved, you can stop an action at any time before it's complete.
Run a project
Copilot Code works inside the project folders on your device, either the default location or a folder you choose. It can read the files there, install what the project needs, and run the app so the preview stays current. Copilot Code asks for your approval before it reaches outside that folder or makes a network connection.
Approval requests and the sandbox work together. An approval request asks you to decide whether Copilot Code can take an action. The sandbox limits which files and network resources Copilot Code can access. If the sandbox blocks an action, approving the action doesn't override the block. The following table shows the default behavior when the sandbox is on.
| Access | Default behavior |
|---|---|
| Selected project folder | Copilot Code can read and write files. |
| Files required by common build tools | Copilot Code can read the files needed for builds. |
| Other folders on your device | Copilot Code asks for your approval, or the sandbox blocks the action. Approving doesn't override a sandbox block. |
| Internet connections | Copilot Code asks for approval before connecting. The sandbox can also block a network destination. Approving doesn't override a sandbox block. |
Sandbox for local projects
When Copilot Code works on a project on your device, by default it uses a sandbox. The sandbox limits what Copilot Code can read, change, and reach on the network. This helps reduce the chance of unintended changes outside your project. The sandbox is on by default.
What the sandbox covers
The sandbox applies to Copilot Code and the actions it starts on your behalf. Anything it starts has the same limits or stricter ones; it doesn't get more access than Copilot Code.
| What Copilot Code does | How the sandbox applies |
|---|---|
| Reads or changes files in your project | File access is limited to the locations described in the following section. |
| Runs commands to build, test, or preview your project | The commands and any processes they start follow the same or stricter sandbox limits. |
| Uses built-in tools to work with files | The tools follow the sandbox's file-access limits. |
| Opens a web preview | The preview follows the sandbox settings, whether Copilot Code or you interact with it. |
File access
These examples describe the sandbox's default file-access limits. Your device's permissions and approval settings still apply.
| Location | Default access |
|---|---|
| Your project and temporary folders | Read and write |
| Build tool caches, package registries, and configuration files | Read |
| Other folders on your device | No access |
Network access
The network setting controls which hosts Copilot Code can reach from your device. A host is the network address of a service.
| Network setting | What it means |
|---|---|
| Full access | Copilot Code can reach any host. File-access limits still apply. |
| Allowed hosts only | Copilot Code can reach only hosts on the allowed list. |
| No network access | Copilot Code can’t make outbound network connections. |
Some projects need to download packages or other development tools. If a download is blocked, check the sandbox’s network settings. Only allow sites you trust.
Sandbox and approval requests
Approving an action lets Copilot Code do something the sandbox already allows. It doesn’t override a sandbox restriction. See Review an approval request for information about reviewing and responding to approval requests.
The sandbox doesn’t cover an app you start yourself outside a Copilot Code session. Review generated code before running it yourself.
Turn the sandbox off or on
To turn the sandbox on or off, go to Settings > Code > PC settings and change the Sandbox toggle. The sandbox is on by default. On some devices, device settings may prevent you from turning it off.
When the sandbox is off, its file and network restrictions no longer apply. Your approval settings still apply. If you turn on Always allow, Copilot Code can take actions without asking for approval each time.
Review an approval request
You need to give consent before Copilot Code can take any of the following actions:
- Read files outside the selected project folder.
- Write to or change files outside the selected project folder.
- Delete files.
- Download content over a network connection.
- Access, pull from, or push to your GitHub repositories through the GitHub connector.
Before Copilot Code takes a sensitive action, the approval dialog explains what Copilot Code plans to do.
- Read the command, file location, or connection shown in the dialog.
- Confirm that the action is needed for your project.
- Approve the action to continue, or cancel it to stop the action.
Copilot Code asks for your permission before it takes actions that reach beyond the project folder you selected, such as accessing other locations, making network connections, or running commands. Consent prompts describe what's happening in plain language.
Allow for a session or project
When offered, Allow for session or Allow for project lets Copilot Code perform the same type of action again within that session or project without asking each time.
Important
Only choose these options if you're comfortable with further actions of that type proceeding without review. Turn it on only when you trust the project and understand what Copilot Code can do without asking you.
How to revoke consent
To revoke a session permission, delete the session where you granted it. To revoke a project permission, delete the project where you granted it. These approvals apply only within the selected scope; they don't give Copilot Code unrestricted access to your device.
Approvals and the sandbox
Approval requests and the sandbox work together, but they do different things. An approval request lets you decide whether Copilot Code can take a specific action. The sandbox limits which files and network resources Copilot Code can access, even for actions you approve. Approving an action, including with Allow for session or Allow for project, doesn't override a sandbox restriction. For more information, see the “Sandbox for local projects” section.
Important
Review commands and connection destinations carefully. Don't approve an action if you don't understand why the project needs it.
Use Always allow
Important
When you enable Always allow, it remains enabled until you disable it. Always allow applies to existing sessions and workspaces as well as any new sessions started after you enable it. Use caution when enabling Always allow.
By default, Copilot Code asks for your approval before it takes an action outside your project folder or connects to the internet. When you turn on Always allow, Copilot Code stops asking. It takes these actions without confirming with you first.
Warning
Always allow removes the approval step that helps protect your files, accounts, and device. Turn it on only when you trust the project and understand what Copilot Code can do without asking you.
What Always allow approves automatically
When Always allow is on, Copilot Code can do any of the following without asking you first:
- Read files outside the selected project folder.
- Write to or change files outside the selected project folder.
- Delete files.
- Download content over a network connection.
- Access, pull from, or push to your GitHub repositories through the GitHub connector.
What Always allow doesn't change
You can still stop Copilot Code. You can pause Copilot Code at any time, resume when you're ready, or cancel the task. You can also stop an action before it finishes.
Blocked actions stay blocked. Always allow skips approval prompts but doesn't override actions Copilot Code is designed to block. It also doesn't turn off the sandbox. While the sandbox is on, its file and network restrictions still apply to actions that Always allow approves.
Always allow is separate from Automatic mode. Automatic mode reduces how often Copilot Code checks in with you while it works on a task. Always allow controls whether Copilot Code asks before protected actions.
How long Always allow lasts
When you turn on Always allow, it stays on until you turn it off. It applies to your existing sessions and workspaces and to any new sessions you start after you turn it on.
Before you turn on Always allow
Think about what could happen if Copilot Code acts in an unexpected way, such as misunderstanding your request or following misleading instructions in a file or on a website.
For example:
- Files can be changed or deleted. Copilot Code can change or delete files outside your project folder, and you might not be able to recover them.
- Your code can be published. Copilot Code can push changes to your GitHub repositories, including public repositories, without your review.
- Untrusted content can be downloaded. Copilot Code can download packages or content from the internet without showing you where it comes from.
- Prompt injection. Content that Copilot Code reads might include hidden instructions meant to manipulate it. With Always allow on, you have fewer chances to catch an unexpected action.
To reduce risk:
- Back up important files, or commit your work to GitHub before you start.
- Use a dedicated project folder that doesn't contain sensitive files.
- Use Plan mode so you can review the approach before Copilot Code makes changes.
- Watch the task as it runs. Pause or cancel it if something looks unexpected.
- Turn off Always allow when you no longer need it.
- Keep the sandbox on, especially while Always allow is on.
Turn Always allow on or off
To turn Always allow on or off, follow these steps:
- In Copilot Code, go to Settings and more > Code.
- Select Manage PC Settings.
- Turn Run tools without asking on or off.
When an action is blocked
If an action isn't allowed, Copilot Code explains what it blocked, such as a file outside the selected folder or a network destination that isn't available. The action doesn't run without the required protection.
You can:
- Choose a different project folder.
- Remove the step from your request.
- Ask Copilot Code for another way to complete the task.
- Ask Copilot Code to use a file in your project folder instead.