Skip to content

terminal: drop sandbox output retry heuristics#312920

Open
dileepyavan wants to merge 2 commits intomainfrom
DileepY/312718
Open

terminal: drop sandbox output retry heuristics#312920
dileepyavan wants to merge 2 commits intomainfrom
DileepY/312718

Conversation

@dileepyavan
Copy link
Copy Markdown
Member

Fixes #312718

Summary

This change removes the remaining sandbox-output text heuristics from the terminal chat agent sandbox flow.

  • stop gating shouldAutomaticallyRetryUnsandboxed on outputLooksSandboxBlocked
  • only surface sandbox remediation guidance from SandboxOutputAnalyzer for explicit non-zero exit failures
  • replace the old helper-focused unit tests with behavior-focused coverage for the analyzer and retry logic

Testing

  • npm run compile-check-ts-native
  • node --experimental-strip-types build/hygiene.ts src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/sandboxOutputAnalyzer.ts src/vs/workbench/contrib/terminalContrib/chatAgentTools/test/browser/sandboxOutputAnalyzer.test.ts
  • ./scripts/test.sh --run src/vs/workbench/contrib/terminalContrib/chatAgentTools/test/browser/sandboxOutputAnalyzer.test.ts

Remove sandbox-output heuristics from terminal unsandbox retry handling and only surface sandbox guidance for explicit command failures.

Update the focused tests to cover the current analyzer and retry behavior instead of the removed helper.

Refs #312718.
Copilot AI review requested due to automatic review settings April 27, 2026 22:13
@dileepyavan dileepyavan enabled auto-merge (squash) April 27, 2026 22:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Removes remaining sandbox-output string heuristics from the terminal chat agent sandbox flow so retries and remediation guidance are driven by execution outcomes rather than parsing terminal text.

Changes:

  • Update sandbox output analysis to only emit remediation guidance for explicit non-zero exit failures.
  • Simplify automatic unsandbox retry gating by removing output-text inspection.
  • Replace heuristic-focused unit tests with behavior-focused coverage for the analyzer and retry logic.
Show a summary per file
File Description
src/vs/workbench/contrib/terminalContrib/chatAgentTools/test/browser/sandboxOutputAnalyzer.test.ts Replaces heuristic tests with analyzer/remediation and retry behavior coverage.
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/sandboxOutputAnalyzer.ts Drops “suspected failure” (output-text) path and only returns guidance on explicit failures.
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts Removes dependency on output-text heuristic for automatic unsandbox retry.

Copilot's findings

Comments suppressed due to low confidence (1)

src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/sandboxOutputAnalyzer.ts:45

  • outputLooksSandboxBlocked is still exported below, but it no longer has any call sites in the repo (it appears to be unused after removing the retry/analyzer heuristics). Consider removing the unused export (and its comment) to avoid keeping a deprecated heuristic around unintentionally and to better match the PR’s goal of dropping sandbox-output heuristics.
}
  • Files reviewed: 3/3 changed files
  • Comments generated: 2

@@ -409,8 +409,7 @@ export function shouldAutomaticallyRetryUnsandboxed(options: IAutomaticUnsandbox
&& !options.isPersistentSession
&& !options.isBackgroundExecution
&& !options.didTimeout
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

shouldAutomaticallyRetryUnsandboxed treats exitCode: undefined as a failure because undefined !== 0 is true, which can trigger an automatic unsandbox retry even when the exit code is simply unavailable. Consider only retrying on an explicit non-zero exit code (eg require exitCode !== undefined && exitCode !== 0) to avoid unnecessary confirmation prompts/retries when the strategy cannot determine an exit code.

Suggested change
&& !options.didTimeout
&& !options.didTimeout
&& options.exitCode !== undefined

Copilot uses AI. Check for mistakes.
Comment on lines 25 to 29
const knownFailure = options.exitCode !== undefined && options.exitCode !== 0;
const suspectedFailure = !knownFailure && options.exitCode === undefined && this._outputLooksSandboxBlocked(options.exitResult);

if (!knownFailure && !suspectedFailure) {
if (!knownFailure) {
return undefined;
}
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

With the new early-return, knownFailure is effectively a guard ensuring the rest of analyze only runs for explicit non-zero exit codes. Since the remaining logic no longer needs to distinguish between “known” vs “suspected” failures, consider simplifying by inlining this guard (and removing any now-unreachable non-failure branches later in the method) to keep the control flow straightforward.

This issue also appears on line 45 of the same file.

Copilot uses AI. Check for mistakes.
Update the electron-browser automatic sandbox retry tests to reflect that retry decisions no longer depend on sandbox-output heuristics.

Refs #312718.
@dileepyavan dileepyavan disabled auto-merge April 27, 2026 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Linux: Sandbox doesn't always distinguish inexistent file from file outside sandbox

3 participants