Skip to content

fix(tools): stabilize runTerminalCommand output capture for agents - #13138

Open
saknopp wants to merge 2 commits into
continuedev:mainfrom
saknopp:fix-agent-terminal-output
Open

fix(tools): stabilize runTerminalCommand output capture for agents#13138
saknopp wants to merge 2 commits into
continuedev:mainfrom
saknopp:fix-agent-terminal-output

Conversation

@saknopp

@saknopp saknopp commented Aug 16, 2026

Copy link
Copy Markdown

This PR fixes an issue where autonomous agents (or external MCP runtimes) attempting to observe terminal output through runTerminalCommand would frequently receive empty strings or garbled text instead of the actual command stdout.

The Problem:

  1. Login Shells: The implementation previously invoked bash -l (login shell). In non-TTY background execution contexts, user .bash_profile or .bashrc scripts often hang, execute interactive terminal-only utilities (like tmux), or prematurely exit, causing the node child_process to capture no output.
  2. ANSI Color Pollution: getColorEnv() previously forced FORCE_COLOR=1 and TERM=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:

  • Replaced the login shell flag -l with a standard /bin/bash -c execution to bypass user-specific interactive profile quirks.
  • Modified 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.

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
@saknopp
saknopp requested a review from a team as a code owner August 16, 2026 00:59
@saknopp
saknopp requested review from sestinj and removed request for a team August 16, 2026 00:59
@github-actions

Copy link
Copy Markdown
Contributor


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


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.

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.

1 participant