hermes - 💡(How to fix) Fix Secret redaction corrupts code syntax in tool output (write_file, execute_code, terminal)

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Root Cause

The redaction is applied when content is authored (before write), not when it's displayed. The redact.py / mask_secret logic appears to scan and replace substrings matching credential patterns in all tool inputs/outputs, rather than being scoped to display/logging paths only.

Fix Action

Fix / Workaround

  • Agent must rewrite scripts 6-7 times to work around the redaction
  • Every workaround is fragile (splitting key reads across variables, using .join(), avoiding f-strings entirely)
  • execute_code becomes effectively unusable for tasks that involve credentialed API calls
  • In this session alone, this was the single biggest time-waster (~30+ minutes fighting redaction)
RAW_BUFFERClick to expand / collapse

Describe the bug

The API key / secret redaction system operates at the content layer — it replaces key values with *** in the raw text before it's written to files or executed. This corrupts Python/Shell syntax, causing tools to fail silently.

Where it happens

The redaction corrupts content across all tool channels:

  1. write_file — Code like auth = f"Authorization: Bearer {key}" gets mangled to auth = f"Authorization: Bearer *** (unterminated f-string → SyntaxError).

  2. execute_code sandbox — Any Python script that reads an API key from .env and then uses it in a string literal gets corrupted inside the sandbox.

  3. terminal heredocscat > script.py << 'EOF' containing DASHSCOPE_API_KEY=sk-... gets mangled before the heredoc is written.

Impact

  • Agent must rewrite scripts 6-7 times to work around the redaction
  • Every workaround is fragile (splitting key reads across variables, using .join(), avoiding f-strings entirely)
  • execute_code becomes effectively unusable for tasks that involve credentialed API calls
  • In this session alone, this was the single biggest time-waster (~30+ minutes fighting redaction)

Root cause

The redaction is applied when content is authored (before write), not when it's displayed. The redact.py / mask_secret logic appears to scan and replace substrings matching credential patterns in all tool inputs/outputs, rather than being scoped to display/logging paths only.

Expected behavior

Secrets should be redacted at display/logging time only. The actual tool arguments and file contents should never be mutated. Specifically:

  • write_file content must be written verbatim
  • execute_code script source must be executed as-is
  • terminal command strings must not be modified

The current redact.py already lives in agent/redact.py — ideally redaction stays confined to agent-thought display, log messages, and user-facing output, never touching tool parameter payloads.

Reproduction

  1. Have any API key stored in ~/.hermes/.env
  2. Ask the agent to write a Python script that reads the key and uses it in an Authorization: Bearer header
  3. Every approach (f-string, .format(), string concatenation with the raw key in a literal) gets corrupted

Environment

  • Hermes Agent: current origin/main (observed on multiple versions)
  • OS: WSL2 (Ubuntu) on Windows 11
  • Provider: DeepSeek

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Secrets should be redacted at display/logging time only. The actual tool arguments and file contents should never be mutated. Specifically:

  • write_file content must be written verbatim
  • execute_code script source must be executed as-is
  • terminal command strings must not be modified

The current redact.py already lives in agent/redact.py — ideally redaction stays confined to agent-thought display, log messages, and user-facing output, never touching tool parameter payloads.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING