Skip to content

feat(file_safety): support multiple HERMES_WRITE_SAFE_ROOT dirs (fix #49535) - #49557

Closed
xydigit-zt wants to merge 4 commits into
NousResearch:mainfrom
xydigit-zt:fix/issue-49535-multiple-safe-roots
Closed

feat(file_safety): support multiple HERMES_WRITE_SAFE_ROOT dirs (fix #49535)#49557
xydigit-zt wants to merge 4 commits into
NousResearch:mainfrom
xydigit-zt:fix/issue-49535-multiple-safe-roots

Conversation

@xydigit-zt

Copy link
Copy Markdown
Contributor

Supports multiple directories separated by ':' (Unix PATH-style).
E.g., HERMES_WRITE_SAFE_ROOT=/opt/data:/var/www/html

Testing:

  • All 18 existing file_safety tests pass
  • Manual test confirms multiple directories work correctly

Fixes #49535

Claude and others added 2 commits June 20, 2026 17:05
In _read_file() and _detect_external_drift(), the code used strict UTF-8
encoding but only caught OSError/IOError, not UnicodeDecodeError.
This caused the memory tool to crash when encountering non-UTF-8
encoded files (e.g., GBK, CP936, Latin-1).

Now catches UnicodeDecodeError and returns empty results instead of crashing.

Fixes NousResearch#49508
Supports multiple directories separated by ':' (Unix PATH-style).
E.g., HERMES_WRITE_SAFE_ROOT=/opt/data:/var/www/html

Fixes NousResearch#49535
@alt-glitch alt-glitch added type/feature New feature or request comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint tool/memory Memory tool and memory providers P2 Medium — degraded but workaround exists labels Jun 20, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related: #49535 (the feature request this implements). Core change is multi-root (PATH-style :-separated) support in agent/file_safety.py; the tools/memory_tool.py change is incidental UnicodeDecodeError hardening on two reads. Triaged type/feature, comp/agent, tool/memory, P2.

@Morad37 Morad37 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean approach. The colon-separated format makes sense for env vars and the backwards compat is fine since single-path still works. One thing: the existing docs and config templates reference HERMES_WRITE_SAFE_ROOT as a single path. If they show an example, updating it to mention the multi-path format would save someone figuring it out from source.

@xydigit-zt

Copy link
Copy Markdown
Contributor Author

Thanks for the approval!

Good point about the docs. I can add a note about the multi-path format. Do you have a specific doc file or section that references HERMES_WRITE_SAFE_ROOT that I should update? Or would you prefer a follow-up PR for the docs?

Add note about colon-separated multiple directories support.
@xydigit-zt

Copy link
Copy Markdown
Contributor Author

Thanks for the review! I've updated the docs to mention the multi-path format:

Changes:

  • Added note about colon-separated multiple directories in English docs ()
  • Added corresponding Chinese translation ()

Example:

kshitijk4poor added a commit to kshitijk4poor/hermes-agent that referenced this pull request Jun 26, 2026
- Use os.pathsep instead of literal ':' so Windows paths (C:\dir) and
  the Windows separator ';' work correctly.
- Add 9 tests covering multi-root behavior: writes inside first/second
  root, writes outside all roots, trailing/leading/double separators,
  all-separators edge case, static deny priority, duplicate dedup.
- Update hermes_cli/tips.py tip string to mention multiple paths.
- Update docs to mention os.pathsep / ; on Windows.

Follow-up for salvaged PR NousResearch#49557.
kshitijk4poor added a commit that referenced this pull request Jun 26, 2026
- Use os.pathsep instead of literal ':' so Windows paths (C:\dir) and
  the Windows separator ';' work correctly.
- Add 9 tests covering multi-root behavior: writes inside first/second
  root, writes outside all roots, trailing/leading/double separators,
  all-separators edge case, static deny priority, duplicate dedup.
- Update hermes_cli/tips.py tip string to mention multiple paths.
- Update docs to mention os.pathsep / ; on Windows.

Follow-up for salvaged PR #49557.
@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Merged via #53292. Your commits cherry-picked with authorship preserved (rebase-merge). The unrelated tools/memory_tool.py UnicodeDecodeError fix was dropped from this PR — it belongs in a separate PR targeting #49508. Thanks for the contribution!

pai-scaffolde pushed a commit to pai-scaffolde/hermes-agent that referenced this pull request Jun 28, 2026
- Use os.pathsep instead of literal ':' so Windows paths (C:\dir) and
  the Windows separator ';' work correctly.
- Add 9 tests covering multi-root behavior: writes inside first/second
  root, writes outside all roots, trailing/leading/double separators,
  all-separators edge case, static deny priority, duplicate dedup.
- Update hermes_cli/tips.py tip string to mention multiple paths.
- Update docs to mention os.pathsep / ; on Windows.

Follow-up for salvaged PR NousResearch#49557.
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
- Use os.pathsep instead of literal ':' so Windows paths (C:\dir) and
  the Windows separator ';' work correctly.
- Add 9 tests covering multi-root behavior: writes inside first/second
  root, writes outside all roots, trailing/leading/double separators,
  all-separators edge case, static deny priority, duplicate dedup.
- Update hermes_cli/tips.py tip string to mention multiple paths.
- Update docs to mention os.pathsep / ; on Windows.

Follow-up for salvaged PR NousResearch#49557.
habarmc1223-sudo pushed a commit to habarmc1223-sudo/hermes-agent-fluxmem that referenced this pull request Jul 8, 2026
- Use os.pathsep instead of literal ':' so Windows paths (C:\dir) and
  the Windows separator ';' work correctly.
- Add 9 tests covering multi-root behavior: writes inside first/second
  root, writes outside all roots, trailing/leading/double separators,
  all-separators edge case, static deny priority, duplicate dedup.
- Update hermes_cli/tips.py tip string to mention multiple paths.
- Update docs to mention os.pathsep / ; on Windows.

Follow-up for salvaged PR NousResearch#49557.
santhreal pushed a commit to santhreal/hermes-agent that referenced this pull request Jul 13, 2026
- Use os.pathsep instead of literal ':' so Windows paths (C:\dir) and
  the Windows separator ';' work correctly.
- Add 9 tests covering multi-root behavior: writes inside first/second
  root, writes outside all roots, trailing/leading/double separators,
  all-separators edge case, static deny priority, duplicate dedup.
- Update hermes_cli/tips.py tip string to mention multiple paths.
- Update docs to mention os.pathsep / ; on Windows.

Follow-up for salvaged PR NousResearch#49557.
Gravezzz pushed a commit to Gravezzz/hermes-agent that referenced this pull request Jul 21, 2026
- Use os.pathsep instead of literal ':' so Windows paths (C:\dir) and
  the Windows separator ';' work correctly.
- Add 9 tests covering multi-root behavior: writes inside first/second
  root, writes outside all roots, trailing/leading/double separators,
  all-separators edge case, static deny priority, duplicate dedup.
- Update hermes_cli/tips.py tip string to mention multiple paths.
- Update docs to mention os.pathsep / ; on Windows.

Follow-up for salvaged PR NousResearch#49557.
leewenjie pushed a commit to leewenjie/hermes-agent that referenced this pull request Aug 7, 2026
- Use os.pathsep instead of literal ':' so Windows paths (C:\dir) and
  the Windows separator ';' work correctly.
- Add 9 tests covering multi-root behavior: writes inside first/second
  root, writes outside all roots, trailing/leading/double separators,
  all-separators edge case, static deny priority, duplicate dedup.
- Update hermes_cli/tips.py tip string to mention multiple paths.
- Update docs to mention os.pathsep / ; on Windows.

Follow-up for salvaged PR NousResearch#49557.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists tool/memory Memory tool and memory providers type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Support multiple HERMES_WRITE_SAFE_ROOT directories

4 participants