diff --git a/tools/environments/base.py b/tools/environments/base.py index 4510b1749f..9ca26405cf 100644 --- a/tools/environments/base.py +++ b/tools/environments/base.py @@ -386,9 +386,16 @@ class BaseEnvironment(ABC): parts = [] - # Source snapshot (env vars from previous commands) + # Source snapshot (env vars from previous commands). + # Redirect stdout to /dev/null: on macOS (bash 3.2 and certain + # Homebrew bash builds) sourcing a file containing ``declare -x`` + # can emit the declarations to stdout, leaking ~60 lines of env + # vars into every tool response (issue #15459). Linux bash is + # silent here, but the redirect is harmless. if self._snapshot_ready: - parts.append(f"source {self._snapshot_path} 2>/dev/null || true") + parts.append( + f"source {self._snapshot_path} >/dev/null 2>&1 || true" + ) # Preserve bare ``~`` expansion, but rewrite ``~/...`` through # ``$HOME`` so suffixes with spaces remain a single shell word. diff --git a/tools/terminal_tool.py b/tools/terminal_tool.py index a2e8a21898..105c5aa858 100644 --- a/tools/terminal_tool.py +++ b/tools/terminal_tool.py @@ -1851,7 +1851,7 @@ def terminal_tool( # Extract output output = result.get("output", "") returncode = result.get("returncode", 0) - + # Add helpful message for sudo failures in messaging context output = _handle_sudo_failure(output, env_type)