Detect xterm-trimmed Password: prompt so agent doesn't hang on sudo su#314257
Merged
meganrogge merged 3 commits intomainfrom May 4, 2026
Merged
Detect xterm-trimmed Password: prompt so agent doesn't hang on sudo su#314257meganrogge merged 3 commits intomainfrom
Password: prompt so agent doesn't hang on sudo su#314257meganrogge merged 3 commits intomainfrom
Conversation
Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/6f78bb32-4e65-41cc-bc6e-86150cb88f77 Co-authored-by: meganrogge <29464607+meganrogge@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix hanging issue when running sudo su via agent
Detect xterm-trimmed May 4, 2026
Password: prompt so agent doesn't hang on sudo su
meganrogge
approved these changes
May 4, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a hang in the terminal chat agent when running password-prompting commands (notably sudo su) by making the high-confidence prompt detection tolerant of xterm’s trimmed trailing whitespace.
Changes:
- Relax password prompt detection to match both
Password:and xterm-trimmedPassword:. - Add unit tests covering the trimmed
Password:form and a negative case to avoid matching non-prompt “password” mentions.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/monitoring/outputMonitor.ts | Updates the high-confidence password prompt regex and related inline documentation. |
| src/vs/workbench/contrib/terminalContrib/chatAgentTools/test/browser/outputMonitor.test.ts | Adds regression tests for trimmed password prompt detection and a false-positive guard. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 2
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
meganrogge
approved these changes
May 4, 2026
Contributor
Screenshot ChangesBase: Changed (6)Errored (18)Fixtures that failed to render — no screenshot was produced.
|
dmitrivMS
approved these changes
May 4, 2026
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.
Running
sudo su(or any password-prompting command) via the agent hung indefinitely in "Processing" because the password prompt was never detected.Root cause
OutputMonitorreads terminal output through xterm'sline.translateToString(trimRight=true), which strips trailing whitespace from non-wrapped lines. sudo's actualPassword:prompt is therefore captured from the buffer asPassword:(no trailing space).The high-confidence detection regex required one or more trailing spaces:
So
onDidDetectInputNeedednever fired, the foreground execution race inrunInTerminalToolnever resolved with'inputNeeded', and the agent waited until the extended polling timeout.Changes
outputMonitor.ts— relax the password regex to tolerate the xterm-trimmed form:/password:\s*$/iTrailing whitespace is now optional (matches both
Password:andPassword:). The colon is now required, which also tightens the previous regex by rejecting lines ending with the bare wordpassword(no colon) — fewer false positives on log/help output.outputMonitor.test.ts— add positive coverage for'Password:'(the literal buffer-captured prompt) and negative coverage for'Enter your password'to lock in the colon requirement.Once detected, the existing steering text instructs the agent to "never guess passwords ... inform the user and stop", so the hang is replaced with the intended prompt-handling flow.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
redirector.gvt1.com/proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --crashpad-handler-pid=7210 --enable-crash-reporter=a349b8eb-e8ba-47f3-aecf-2775b489a280,no_channel --user-data-dir=/tmp/vscode-tests-1777933277250 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,9844196342287843969,12494621541449140129,262144 --enable-features=PdfUseShowSaveFilePicker --disable-features=LocalNetworkAccessChecks,ScreenAIOCREnabled,SpareRendererForSitePerProcess,TraceSiteInstanceGetProcessCreation --variations-seed-version --trace-process-track-uuid=3190708989122997041(dns block)./.build/electron/code-oss ./.build/electron/code-oss --no-sandbox test/unit/electron/index.js --crash-reporter-directory=/tmp/crash --grep detectsHighConfidenceInputPattern(dns block)/proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --crashpad-handler-pid=7344 --enable-crash-reporter=a349b8eb-e8ba-47f3-aecf-2775b489a280,no_channel --user-data-dir=/tmp/vscode-tests-1777933289920 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,18377526316508826629,11363991505412324434,262144 --enable-features=PdfUseShowSaveFilePicker --disable-features=LocalNetworkAccessChecks,ScreenAIOCREnabled,SpareRendererForSitePerProcess,TraceSiteInstanceGetProcessCreation --variations-seed-version --trace-process-track-uuid=3190708989122997041 ks(dns block)If you need me to access, download, or install something from one of these locations, you can either: