fix(tools): stabilize runTerminalCommand output capture for agents - #13138
Open
saknopp wants to merge 2 commits into
Open
fix(tools): stabilize runTerminalCommand output capture for agents#13138saknopp wants to merge 2 commits into
saknopp wants to merge 2 commits into
Conversation
The previous allowlist (LOCAL_ONLY = ['', 'local']) caused VS Code forks like Cursor to fall into the remote terminal path, which silently drops stdout from runTerminalCommand tool results. Switch to a blocklist of known remote environment names (wsl, ssh-remote, dev-container, codespaces, tunnel) so any non-remote environment — including Cursor — correctly uses childProcess.spawn for full output capture.
… bypassing login shell profiles and stripping ANSI colors
Contributor
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
6 tasks
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.
This PR fixes an issue where autonomous agents (or external MCP runtimes) attempting to observe terminal output through
runTerminalCommandwould frequently receive empty strings or garbled text instead of the actual commandstdout.The Problem:
bash -l(login shell). In non-TTY background execution contexts, user.bash_profileor.bashrcscripts often hang, execute interactive terminal-only utilities (liketmux), or prematurelyexit, causing the nodechild_processto capture no output.getColorEnv()previously forcedFORCE_COLOR=1andTERM=xterm-256color. While this looks great in the UI, agents expecting machine-readable text struggle to parse ANSI-polluted streams, and some CLI tools alter their output buffering behavior when they detect forced color sequences in a non-TTY pipe.The Solution:
-lwith a standard/bin/bash -cexecution to bypass user-specific interactive profile quirks.getColorEnv()to explicitly request a plaintext environment (NO_COLOR="1",TERM="dumb"), ensuring that the output returned to the agent is clean and strictly decodable.Testing:
Verified locally that terminal execution commands reliably return their stdout streams to external LLM runtimes without hangs or formatting corruption.