macOS terminal declare -x output leak fixes

NousResearch/hermes-agent · cluster 15459

Data as of

Nothing open on GitHub. Fix merged in #16384. Check it covers your case.

The short answer

0open issues
0open PRs
6items grouped
Known?
Yes. 6 related items grouped here, 1 issue already closed.
Fix event
A fix was merged to main in PR #16384. Check it covers your case. No release data is tracked.
Tracker
The maintainers' tracker marks this unresolved. That is separate from the fix event.
Still open
Nothing open on GitHub.

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.

Open issues0

No open issues.

Open PRs0

No open pull requests.

Fixes on record

Merged to main. A stamp counts the issues a fix is linked to.

  • #16384 fix: strip leaked declare-x env dump from terminal output on macOS (#15459)

    merged to main

    files: tools/environments/base.py, tools/terminal_tool.py

    Show the diff
    • tools/environments/base.py
      @@ -386,9 +386,16 @@ def _wrap_command(self, command: str, cwd: str) -> str:
       
               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.
    • 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)
       

4 PRs closed without merging

From the close comments: merged via another change 2 · closed without comment 1 · done elsewhere 1

  • #15469 fix: strip leaked state-sync output from terminal (defense-in-depth for #15459) · closed without comment
  • #15472 fix: strip leaked declare-x env dump from terminal output on macOS (#15459) · merged via another change → #16384
  • #15474 fix: suppress declare -x stdout leak when sourcing snapshot on macOS · merged via another change → #16384, #15472
  • #16385 fix(terminal): suppress declare -x stdout leak when sourcing snapshot on macOS · done elsewhere → 2e6699b, #15472
Closed issues · 1
  • Closed#15459[Bug]: [Bug]: terminal() tool leaks "declare -x" state-sync output into LLM context window (macOS)
How this cluster was grouped
  • Link evidence (structural links throughout): every member is connected by structural evidence: shared changed files, or a closing/superseded reference.
  • Pairwise link density 0.33: the share of item pairs that carry a link, counting a structural link in full and a relevance-only link at 0.36. 1.00 means every pair is linked.

Pick up a Lab task

Check whether a fix covers the open issues here, with your own agent. Bring back evidence for maintainers.

Open the Lab

At a glance

Merged PRs
#16384
Closed issues
1
Attempts
4 PRs closed without merging
Fix link checked
27 Apr 2026

For your agent

The same facts, typed.