Repository navigation
agent host pwsh tool should use pwsh grammar for terminal auto-approval - #328133
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds shell-aware Agent Host terminal auto-approval, particularly for PowerShell.
Changes:
- Propagates shell-language metadata through permission handling.
- Adds PowerShell parsing, matching, and redirect safeguards.
- Expands focused test coverage across the approval flow.
Show a summary per file
| File | Description |
|---|---|
common/agentService.ts |
Defines shell-language signal metadata. |
node/agentSideEffects.ts |
Forwards shell language to permissions. |
node/commandAutoApprover.ts |
Implements PowerShell-aware approval analysis. |
node/copilot/copilotAgentSession.ts |
Correlates SDK shell tools with languages. |
node/sessionPermissions.ts |
Applies language-aware rules and redirect checks. |
test/node/agentSideEffects.test.ts |
Tests metadata forwarding. |
test/node/commandAutoApprover.test.ts |
Tests PowerShell parsing and approval behavior. |
test/node/copilotAgentSession.test.ts |
Tests shell-tool correlation. |
test/node/sessionPermissions.test.ts |
Tests language and redirect enforcement. |
Review details
Comments suppressed due to low confidence (1)
src/vs/platform/agentHost/node/commandAutoApprover.ts:110
- PowerShell permits an output redirect to be adjacent to the preceding argument (for example,
Write-Host hi>../../outside.txt). The grammar can keephi>../../outside.txtas onegeneric_token, but this anchored check only recognizes tokens that begin with the redirect operator. The command is then matched by theWrite-Hostallow rule with no unsafe destination recorded, so an out-of-workspace write can be auto-approved. Treat any>in a PowerShell generic token as a redirect candidate (escaped/literal cases can conservatively require confirmation), and add coverage for redirects with no whitespace on either side.
const pwshNoSpaceRedirectRegex = /^[0-9*]?>>?/;
- Files reviewed: 9/9 changed files
- Comments generated: 1
- Review effort level: Medium
Bhavya U (bhavyaus)
previously approved these changes
Jul 30, 2026
Anthony Kim (anthonykim1)
marked this pull request as draft
July 30, 2026 05:45
Anthony Kim (anthonykim1)
marked this pull request as ready for review
July 30, 2026 05:50
Justin Chen (justschen)
approved these changes
Jul 30, 2026
Closed
3 tasks done
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Resolves: #328052
shellpermissions withtool.execution_start, and recognize Agent Host terminal overrides reported ascustom-toolrequests namedbashorpowershell.bashorpowershelllanguage on Agent Host's internal confirmation signal. Only those values are eligible for terminal-rule auto-approval and rule suggestions; missing language requires confirmation.$nulland no-space redirects, and--flag=valuearguments with PowerShell-specific handling.$nullremain eligible for auto-approval.Inspirations from:
runInTerminalTool.ts.--flag=valueworkaround come fromTreeSitterCommandParser.CommandLineAutoApprover._commandMatchesRule.CommandLineAutoApprover.isCommandLineAutoApproved.commandLineFileWriteAnalyzer.ts.