keepcalculator

06 Numbers and Powers

Copilot Sandboxing in VS Code: Setup and Configuration

Card No. 06·29127 · Updated · Standard formula, shown below

Copilot sandboxing in Visual Studio Code limits what Copilot’s agent can do when it runs terminal commands, helping reduce unintended access to files, processes, and network resources. Availability and controls depend on your operating system, VS Code build, and the agent features enabled for your account, so check the current VS Code documentation if a setting is missing.

What You’ll Need

  • A current version of Visual Studio Code. Use Help > Check for Updates on Windows or Linux, or Code > Check for Updates on macOS.
  • GitHub Copilot access and the relevant Copilot Chat or agent features available in your VS Code installation.
  • An operating system supported by the sandbox feature. Sandboxing support and setup steps can differ by platform; consult VS Code’s current documentation for the supported platforms and prerequisites.
  • A project you can safely test with, preferably a disposable folder or version-controlled repository with no sensitive files.

Step-by-Step

  1. Update VS Code and confirm Copilot works. Install updates, restart VS Code if prompted, and open the Copilot Chat view from the Activity Bar or the View menu. Sign in to the GitHub account that has access to Copilot. If you cannot use Copilot Chat or agent mode, resolve that access or extension issue before configuring sandboxing.
  2. Check whether your installation supports sandboxing. Open the VS Code documentation and search for its current Copilot agent sandboxing instructions. Verify support for your operating system and any required system components. Do not assume that a setting shown in instructions for another platform will be available on yours.
  3. Find the sandbox controls in Settings. Open Settings with Ctrl+, on Windows or Linux, or Cmd+, on macOS. Search for sandbox and review settings whose descriptions refer to Copilot, agents, or terminal execution. You can also use the Command Palette with Ctrl+Shift+P or Cmd+Shift+P, search for Preferences: Open Settings (UI), then search there. Use the exact setting names and instructions shown by your installed VS Code version; do not paste a setting name from an old guide if it is not recognized.
  4. Enable the documented sandbox option. If the current documentation provides a supported setting or setup action for your platform, follow it exactly. Some environments may require installing or enabling a host-level dependency, approving a permission, or restarting VS Code. Avoid editing undocumented settings or launching VS Code with elevated privileges as a workaround.
  5. Review workspace trust. When you open a project, VS Code may ask whether you trust its authors. Only trust folders whose contents and source you understand. Workspace Trust and agent sandboxing are separate protections: trust does not automatically mean agent commands are sandboxed, and sandboxing does not make an untrusted project safe to run.
  6. Inspect what the agent is allowed to do. Open Copilot Chat, select an agent workflow if available, and review any permission, tool, or command approval prompts. Check the proposed command and its working directory before approving it. Keep approval requirements in place unless the product documentation explicitly describes a safe configuration for your task.
  7. Test in a disposable project. Create or open a temporary folder with a harmless text file. Ask the agent to make a small change or run a harmless command, then inspect the proposed action and resulting file changes. Confirm that actions outside the intended project are blocked or require the expected permission. Do not test by asking it to access personal files, credentials, or production systems.
  8. Set project-specific boundaries. Keep sensitive material outside the workspace where practical. Review repository instructions and any configuration files that influence agent behavior. Grant access only to the folders and tools needed for the task, and inspect changes in Source Control before keeping them.
  9. Verify after updates or environment changes. Recheck the documented setting and test behavior after updating VS Code, changing operating systems, switching remote development environments, or changing agent configuration. A sandbox setting on your local computer may not govern commands executed in a remote container, SSH host, or other environment.

Common Mistakes

  • Assuming sandboxing is enabled because Copilot is installed. Copilot access and sandbox enforcement are different. Confirm the relevant control and the platform-specific setup instead of inferring protection from a working chat panel.
  • Copying configuration from another release or platform. Settings can change, be experimental, or apply only to particular environments. Prefer current documentation and settings descriptions shown by your installation.
  • Treating a trusted workspace as a sandbox. Trust controls whether VS Code enables certain project features; it is not a substitute for command isolation or permission review.
  • Approving commands without reading them. Commands can modify or delete files, install software, or access network resources. Check the command, directory, and requested permissions before approval.
  • Assuming remote work is protected by local settings. The command may run on a remote host or inside a separate environment with its own controls. Confirm where execution occurs.

Tips

  • Use version control and review the diff after agent edits; commit only changes you understand.
  • Start with a minimal test repository and ordinary tasks before allowing broader tool access.
  • Keep credentials, private keys, tokens, and unrelated personal data out of test workspaces.
  • When in doubt, decline a permission request, inspect the agent’s explanation, and consult the current VS Code documentation before retrying.
  • For teams, document the supported setup and ask each user to verify the environment where commands actually run.

Troubleshooting

No sandbox setting appears: Update VS Code, search Settings for “sandbox,” and check the current documentation for platform support and prerequisites. The feature may not be available in your version, environment, or release channel. Do not invent a setting in settings.json; VS Code may ignore it or behave unpredictably.

The setting is present but has no apparent effect: Follow any restart or host-component instructions, then test again in a disposable folder. Check whether the agent command runs locally, remotely, or in a container. Review the terminal or Copilot prompt for permission details, and check VS Code’s Output and Problems panels for relevant messages.

Commands fail after enabling the feature: A sandbox can intentionally restrict access to files, network resources, or system tools. Read the denial message and determine whether the action is necessary. Use the documented permission flow or move the task into an appropriate test environment; do not disable protections broadly just to make a command succeed.

Copilot Chat or agent mode is unavailable: Confirm you are signed in, that your account has access to the feature, and that the relevant extension or built-in component is enabled. Update VS Code and reload the window using the Command Palette’s Developer: Reload Window. If access still fails, consult the account or organization administrator.

Behavior differs in SSH, containers, or Codespaces: Identify the machine or container executing the command and check its own sandbox support and configuration. Local settings may not carry over or control remote execution.

Frequently Asked Questions

Does VS Code sandbox every Copilot response?
Sandboxing concerns agent actions such as running commands; it does not mean every suggestion or response is isolated. Review proposed edits and commands.

Is sandboxing available on every operating system?
Support and prerequisites vary. Check the current VS Code documentation for your operating system and execution environment.

Do I need to trust a folder to use Copilot?
Some features may be restricted in an untrusted workspace. Trust a project only when you understand its source; trust is distinct from sandboxing.

Can I allow an agent to access the internet?
Network permissions depend on the supported sandbox configuration and environment. Follow the documented controls and grant only access needed for the task.

Does sandboxing protect files outside the project?
Its exact boundaries depend on the platform and configuration. Do not assume any file is protected without verifying the documented behavior and testing safely.

What should I do if sandboxing blocks a necessary command?
Read the restriction, confirm the command is necessary and safe, and use the documented approval or configuration process. Avoid disabling protections indiscriminately.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →