Skip to content

fix(tools,agent): add explicit encoding to read_text/write_text calls - #50660

Closed
AlexFucuson9 wants to merge 1 commit into
NousResearch:mainfrom
AlexFucuson9:fix-encoding-tools-agent
Closed

fix(tools,agent): add explicit encoding to read_text/write_text calls#50660
AlexFucuson9 wants to merge 1 commit into
NousResearch:mainfrom
AlexFucuson9:fix-encoding-tools-agent

Conversation

@AlexFucuson9

Copy link
Copy Markdown
Contributor

Summary

Companion to PR #50655 (hermes_cli/ files). Add encoding="utf-8" to remaining read_text()/write_text() calls in tools/ and agent/ directories.

7 files, 22 calls fixed:

  • tools/skills_hub.py: 15 calls (read + write)
  • agent/auxiliary_client.py: 1 read_text
  • agent/copilot_acp_client.py: 1 read + 1 write
  • agent/shell_hooks.py: 1 read_text
  • tools/managed_tool_gateway.py: 1 read_text
  • tools/skills_sync.py: 1 read_text
  • tools/xai_http.py: 1 read_text

Test plan

  • CI passes

Path.read_text() and write_text() without encoding default to
system locale. On Windows this is cp1252, causing UnicodeDecodeError
for UTF-8 content. Add encoding="utf-8" to 22 calls across 7 files:

- tools/skills_hub.py: 15 calls (read + write)
- agent/auxiliary_client.py: 1 read_text
- agent/copilot_acp_client.py: 1 read + 1 write
- agent/shell_hooks.py: 1 read_text
- tools/managed_tool_gateway.py: 1 read_text
- tools/skills_sync.py: 1 read_text
- tools/xai_http.py: 1 read_text
@alt-glitch alt-glitch added type/bug Something isn't working comp/tools Tool registry, model_tools, toolsets comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have labels Jun 22, 2026

@heliamuso heliamuso left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hermes Agent Review — PR #50660

Verdict: Changes Requested

🔴 Critical Bug Found

tools/skills_hub.py:3320 — Duplicate encoding keyword argument.

The old line already had encoding="utf-8", the find-and-replace doubled it:

file_dest.write_text(file_content, encoding="utf-8", encoding="utf-8")

This raises TypeError: write_text() got multiple values for keyword argument encoding at runtime. Fix:

file_dest.write_text(file_content, encoding="utf-8")

✅ Everything Else Looks Good

The other 21 changes across 6 files are correct. Clean, focused PR otherwise.


Reviewed by Hermes Agent via github-code-review skill

Comment thread tools/skills_hub.py
file_dest.write_bytes(file_content)
else:
file_dest.write_text(file_content, encoding="utf-8")
file_dest.write_text(file_content, encoding="utf-8", encoding="utf-8")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 Critical: Duplicate encoding="utf-8" keyword argument. The old line already had encoding="utf-8" — the find-and-replace doubled it. This causes TypeError: write_text() got multiple values for keyword argument encoding at runtime.

Fix: remove the second encoding="utf-8".

@heliamuso heliamuso left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Test: fine-grained PAT GraphQL access works!

@heliamuso heliamuso left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Classic PAT confirmed working

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 comp/tools Tool registry, model_tools, toolsets P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants