Skip to content

Commit ddd3343

Browse files
authored
Clarify sandbox-first guidance for terminal tool unsandboxing (#307783)
* Clarify sandbox-first guidance for terminal tool * Refine terminal sandbox schema wording
1 parent b33353e commit ddd3343

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ function createSandboxLines(networkDomains?: ITerminalSandboxResolvedNetworkDoma
151151
'- Tools and scripts should respect the TMPDIR environment variable, which is automatically set to an appropriate path within the sandbox',
152152
'- When a command fails due to sandbox restrictions, immediately re-run it with requestUnsandboxedExecution=true. Do NOT ask the user for permission — setting this flag automatically shows a confirmation prompt to the user',
153153
'- Only set requestUnsandboxedExecution=true when there is evidence of failures caused by the sandbox, e.g. \'Operation not permitted\' errors, network failures, or file access errors, etc',
154+
'- Do NOT set requestUnsandboxedExecution=true without first executing the command in sandbox mode. Always try the command in the sandbox first, and only set requestUnsandboxedExecution=true when retrying after that sandboxed execution failed due to sandbox restrictions.',
154155
'- When setting requestUnsandboxedExecution=true, also provide requestUnsandboxedExecutionReason explaining why the command needs unsandboxed access',
155156
];
156157
if (networkDomains) {
@@ -296,11 +297,11 @@ export async function createRunInTerminalToolData(
296297
const sandboxProperties: IJSONSchemaMap = isSandboxEnabled ? {
297298
requestUnsandboxedExecution: {
298299
type: 'boolean',
299-
description: 'Request that this command run outside the terminal sandbox. Only set this when the command clearly needs unsandboxed access. The user will be prompted before the command runs unsandboxed.'
300+
description: 'Request that this command run outside the terminal sandbox. Only set this after first executing the command in sandbox and observing that sandboxing caused the failure. The user will be prompted before the command runs unsandboxed.'
300301
},
301302
requestUnsandboxedExecutionReason: {
302303
type: 'string',
303-
description: 'A short explanation of why this command must run outside the terminal sandbox. Only provide this when requestUnsandboxedExecution is true.'
304+
description: 'A short explanation of the sandboxed execution failure or blocked-domain requirement that justifies retrying outside the sandbox. Only provide this when requestUnsandboxedExecution is true.'
304305
},
305306
} : {};
306307

src/vs/workbench/contrib/terminalContrib/chatAgentTools/test/electron-browser/runInTerminalTool.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,13 @@ suite('RunInTerminalTool', () => {
274274

275275
const toolData = await instantiationService.invokeFunction(createRunInTerminalToolData);
276276
const properties = toolData.inputSchema?.properties as Record<string, object> | undefined;
277+
const requestUnsandboxedExecutionProperty = properties?.['requestUnsandboxedExecution'] as { description?: string } | undefined;
278+
const requestUnsandboxedExecutionReasonProperty = properties?.['requestUnsandboxedExecutionReason'] as { description?: string } | undefined;
277279

278280
ok(properties?.['requestUnsandboxedExecution'], 'Expected requestUnsandboxedExecution in schema when sandbox is enabled');
279281
ok(properties?.['requestUnsandboxedExecutionReason'], 'Expected requestUnsandboxedExecutionReason in schema when sandbox is enabled');
282+
ok(requestUnsandboxedExecutionProperty?.description?.includes('after first executing the command in sandbox and observing that sandboxing caused the failure'), 'Expected schema description to require a sandboxed first attempt');
283+
ok(requestUnsandboxedExecutionReasonProperty?.description?.includes('sandboxed execution failure or blocked-domain requirement'), 'Expected reason schema description to require concrete sandbox justification');
280284
});
281285

282286
test('should not include requestUnsandboxedExecution in schema when sandbox is disabled', async () => {
@@ -343,6 +347,7 @@ suite('RunInTerminalTool', () => {
343347

344348
ok(toolData.modelDescription?.includes('github.com, npmjs.org'), 'Expected allowed domains in description');
345349
ok(toolData.modelDescription?.includes('evil.com'), 'Expected denied domains in description');
350+
ok(toolData.modelDescription?.includes('without first executing the command in sandbox mode'), 'Expected model description to require a sandboxed first attempt before unsandboxing');
346351
});
347352

348353
test('should exclude denied domains from effective allowed list', async () => {

0 commit comments

Comments
 (0)