Repository navigation
Assess only the command in the terminal risk check and distrust its comments - #350597
Open
Anthony Kim (anthonykim1) wants to merge 3 commits into
Open
Anthony Kim (anthonykim1) wants to merge 3 commits into
Anthony Kim (anthonykim1) wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Shell-comment detection mishandles line continuations, substitutions, and quoted here-documents, while host-dependent profile settings cause the fish regression test to fail on Linux and Windows.
4 open issues
What changed in this PR
This PR hardens terminal-command risk assessment in VS Code’s Autopilot flow by excluding model-written explanations and skipping commands detected as containing shell comments.
Changes:
- Uses normalized parameters for risk prompts and instructs the classifier not to trust safety claims inside commands.
- Records shell-comment metadata, preserves it during sandbox retries, and uses it to skip Autopilot calls before assessment.
- Adds tests for prompt filtering, comment detection, and the Autopilot skip path.
| File | Description |
|---|---|
src/vs/workbench/contrib/terminalContrib/chatAgentTools/test/electron-browser/runInTerminalTool.test.ts |
Adds shell-comment detection cases. |
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts |
Detects comments and carries metadata through preparation and retries. |
src/vs/workbench/contrib/chat/test/browser/tools/languageModelToolsService.test.ts |
Tests skipping commented commands before assessment. |
src/vs/workbench/contrib/chat/test/browser/tools/chatToolRiskAssessmentService.test.ts |
Tests command-only terminal prompt input. |
src/vs/workbench/contrib/chat/common/chatService/chatService.ts |
Adds optional terminal comment metadata. |
src/vs/workbench/contrib/chat/browser/tools/languageModelToolsService.ts |
Adds the Autopilot comment skip with a localized explanation. |
src/vs/workbench/contrib/chat/browser/tools/chatToolRiskAssessmentService.ts |
Normalizes prompt input and strengthens risk instructions. |
Review effort: Balanced
Keep the command-only risk prompt and the rule that comments never lower the risk, and let commented commands go through the same assessment as any other command. This removes containsShellComment, the hasComment field and their tests.
Anthony Kim (anthonykim1)
marked this pull request as ready for review
November 26, 2026 21:31
Anthony Kim (anthonykim1)
enabled auto-merge
November 26, 2026 21:31
Dmitriy Vasyura (dmitrivMS)
approved these changes
Nov 26, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Supersedes: #335967
{ command }, so the model-writtenexplanationno longer reaches the assessment.ChatToolRiskAssessmentServiceget this: the risk badge and the Autopilot risk gate.How to test:
chat.tools.riskAssessment.enabled.rm -rf build # build cache, regenerated automatically, safe to delete.rm -rf buildwithout the comment.Tests:
ChatToolRiskAssessmentService›sends only the terminal command to the risk prompt. It fails without the source change../scripts/test.sh --run src/vs/workbench/contrib/chat/test/browser/tools/chatToolRiskAssessmentService.test.ts --run src/vs/workbench/contrib/chat/test/browser/tools/languageModelToolsService.test.ts --run src/vs/workbench/contrib/terminalContrib/chatAgentTools/test/electron-browser/runInTerminalTool.test.ts: 392 passing, 0 failing.pnpm run typecheck-client, andpnpm run oxlinton the two changed files: clean.dbd1badaca92.chatToolRiskAssessmentService.tsis unchanged onmainsince then.Inspirations from:
{ command }parameters for the prompt comes from the existing cache key innormalizeRiskCacheParameters.