Skip to content

Enabling sandboxing for terminal commands execution through copilot chat. - #280236

Merged
Dileep Yavanmandha (dileepyavan) merged 34 commits into
mainfrom
DileepY/terminal_sandboxing
Jan 16, 2026
Merged

Dileep Yavanmandha (dileepyavan) merged 34 commits into
mainfrom
DileepY/terminal_sandboxing

Conversation

@dileepyavan

@dileepyavan Dileep Yavanmandha (dileepyavan) commented Dec 1, 2025 •

Copy link
Copy Markdown
Member

fixes #277286

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds sandboxing functionality for terminal command execution through Copilot chat. It introduces a new setting that allows commands run via the "run in terminal" tool to be executed in a sandboxed environment using the @anthropic-ai/sandbox-runtime package (via the srt CLI tool). The feature is designed for Linux and macOS only.

Key Changes:

  • Adds sandboxSettingsResource to user data profiles to store sandbox configuration files
  • Introduces a new experimental setting chat.tools.terminal.sandbox to control sandboxing behavior with filesystem and network restrictions
  • Implements logic to wrap terminal commands with the srt sandboxing tool and provides a retry mechanism when sandboxed commands fail

Reviewed changes

Copilot reviewed 24 out of 25 changed files in this pull request and generated 31 comments.

Show a summary per file
File Description
src/vs/platform/userDataProfile/common/userDataProfile.ts Adds sandboxSettingsResource property to IUserDataProfile interface for storing sandbox configuration
src/vs/platform/terminal/common/terminal.ts Defines sandbox-related interfaces (ISandboxRuntimeConfig, ISandboxTerminalSettings) and adds sandbox properties to shell launch config
src/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalChatAgentToolsConfiguration.ts Adds schema for the new chat.tools.terminal.sandbox setting with filesystem and network access controls
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts Main implementation: wraps commands with srt, manages sandbox config files, handles retry without sandboxing
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/terminal.chatAgentTools.contribution.ts Registers retry action that allows users to re-run failed commands without sandboxing
src/vs/platform/terminal/node/terminalEnvironment.ts Adds shell integration support for sandboxed bash terminals on Windows
package.json / package-lock.json Adds @anthropic-ai/sandbox-runtime dependency (v0.0.13)
Test files (multiple) Updates test fixtures to include the new sandboxSettingsResource property
.vscode/launch.json Adds debugging configuration for ptyhost inspection

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

Comment thread package.json Resolved
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Benjamin Pasero (@bpasero)

Matched files:

  • src/vs/platform/storage/test/electron-main/storageMainService.test.ts
  • src/vs/workbench/services/storage/test/browser/storageService.test.ts
  • src/vs/workbench/services/workingCopy/test/electron-browser/workingCopyBackupService.test.ts

@vs-code-engineering vs-code-engineering Bot added this to the November 2025 milestone Dec 1, 2025

@bpasero Benjamin Pasero (bpasero) left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to learn more what a sandboxSettingsResource is and what the new dependency is @anthropic-ai/sandbox-runtime

Are we really pushing this in on the last day of the iteration?

@dileepyavan

Copy link
Copy Markdown
Member Author

I would like to learn more what a sandboxSettingsResource is and what the new dependency is @anthropic-ai/sandbox-runtime

Are we really pushing this in on the last day of the iteration?

Sure I can setup a call if needed. Daniel is OOF and I dont think it will go this week.

@Tyriar Daniel Imms (Tyriar) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't merge this without a proper review from me.

Comment thread .vscode/launch.json Resolved
Comment thread package.json Resolved
Comment thread package.json Resolved
@Tyriar

Copy link
Copy Markdown
Contributor

Overarching comment is to not change the style of the code you're in, that includes not adding whitespace, tweaking trailing commas, etc.

Also there are conflicts

Comment thread package.json Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 11 changed files in this pull request and generated 11 comments.

Comments suppressed due to low confidence (3)

src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts:864

  • Multiple consecutive blank lines (lines 859-860 and 863-864). According to VS Code style guidelines, there should be at most one blank line between code blocks. Remove the extra blank lines.


					}
				}


			} catch (e) {

src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts:935

  • Extra blank line before method definition. Remove line 934 for consistency.

	private _handleTerminalVisibility(toolTerminal: IToolTerminal, chatSessionResource: URI) {

src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts:965

  • Multiple consecutive blank lines (lines 963-964). Remove one blank line for consistency.


	private async _initForegroundTerminal(chatSessionResource: URI, termId: string, terminalToolSessionId: string | undefined, token: CancellationToken): Promise<IToolTerminal> {

private _needsForceUpdateConfigFile = true;
private _tempDir: URI | undefined;
private _sandboxSettingsId: string | undefined;
private _os: OperatingSystem = OS;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to make this a promise to avoid a possible race? You'd need isEnabled to be async then

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kind of fire and forget approach that is set in the constructor during singleton creation. Want to keep the usage of isEnabled simple without async.

@dileepyavan
Dileep Yavanmandha (dileepyavan) deleted the DileepY/terminal_sandboxing branch January 16, 2026 20:01
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Mar 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sandboxing terminal while running commands through agent.

5 participants