{"repo":"NousResearch/hermes-agent","public_id":"15459","display_label":"macOS terminal declare -x output leak fixes","summary":"Multiple fixes and a bug report addressing a macOS-specific issue where 'declare -x' environment variable output leaks into terminal tool stdout. Approaches include suppressing the output at source and stripping it defensively from terminal output.","subsystem":null,"counts":{"members":6,"open_issues":0,"open_issues_distinct":0,"open_prs":0,"closed_issues":1,"merged_prs":1,"attempt_prs":4},"landed_fix":{"status":"merged_to_main","basis":"structural","pr":16384},"resolution":{"state":"unresolved","by":null},"freshness":{"state":"verified","last_verified_at":"2026-04-27T07:19:49+00:00","is_stale":false},"grouping":{"backbone":"STRUCTURAL_SPANNING","link_density":0.3333333333333333},"fix_edges":[{"issue_number":15459,"pr_number":16384,"tier":"verified","basis":"superseded_ref","confidence":0.9,"recoverable_from_timeline":false}],"members":[{"kind":"issue","number":15459,"title":"[Bug]: [Bug]: terminal() tool leaks \"declare -x\" state-sync output into LLM context window (macOS)","url":null,"state":"closed"},{"kind":"pr","number":15469,"title":"fix: strip leaked state-sync output from terminal (defense-in-depth for #15459)","url":null,"state":"closed","close_reason":{"category":"silent_close","implication":"active"},"merged":false},{"kind":"pr","number":15472,"title":"fix: strip leaked declare-x env dump from terminal output on macOS (#15459)","url":null,"state":"closed","close_reason":{"refs":[{"kind":"pr","value":"#16384","number":16384}],"category":"merged_via","implication":"superseded"},"merged":false},{"kind":"pr","number":15474,"title":"fix: suppress declare -x stdout leak when sourcing snapshot on macOS","url":null,"state":"closed","close_reason":{"refs":[{"kind":"pr","value":"#16384","number":16384},{"kind":"pr","value":"#15472","number":15472}],"category":"merged_via","implication":"superseded"},"merged":false},{"kind":"pr","number":16384,"title":"fix: strip leaked declare-x env dump from terminal output on macOS (#15459)","url":null,"state":"merged","close_reason":{"category":"merged","implication":"superseded"},"merged":true,"is_fix_pr":true,"fix_tier":"verified","files_changed":["tools/environments/base.py","tools/terminal_tool.py"],"fix_hunks":[{"file":"tools/environments/base.py","hunks":["@@ -386,9 +386,16 @@ def _wrap_command(self, command: str, cwd: str) -> str:\n \n         parts = []\n \n-        # Source snapshot (env vars from previous commands)\n+        # Source snapshot (env vars from previous commands).\n+        # Redirect stdout to /dev/null: on macOS (bash 3.2 and certain\n+        # Homebrew bash builds) sourcing a file containing ``declare -x``\n+        # can emit the declarations to stdout, leaking ~60 lines of env\n+        # vars into every tool response (issue #15459).  Linux bash is\n+        # silent here, but the redirect is harmless.\n         if self._snapshot_ready:\n-            parts.append(f\"source {self._snapshot_path} 2>/dev/null || true\")\n+            parts.append(\n+                f\"source {self._snapshot_path} >/dev/null 2>&1 || true\"\n+            )\n \n         # Preserve bare ``~`` expansion, but rewrite ``~/...`` through\n         # ``$HOME`` so suffixes with spaces remain a single shell word."]},{"file":"tools/terminal_tool.py","hunks":["@@ -1851,7 +1851,7 @@ def terminal_tool(\n             # Extract output\n             output = result.get(\"output\", \"\")\n             returncode = result.get(\"returncode\", 0)\n-            \n+\n             # Add helpful message for sudo failures in messaging context\n             output = _handle_sudo_failure(output, env_type)\n \n"]}]},{"kind":"pr","number":16385,"title":"fix(terminal): suppress declare -x stdout leak when sourcing snapshot on macOS","url":null,"state":"closed","close_reason":{"refs":[{"kind":"commit","value":"2e6699b31","number":0},{"kind":"pr","value":"#15472","number":15472}],"category":"implemented_elsewhere","implication":"superseded"},"merged":false}],"trust":{"default_tier":"verified","includes_suggested":false}}