Skip to content

The agent that grows with you

fix(core,cli,gateway,plugins): add encoding='utf-8' to read_text() calls

AlexFucuson9cf35fd6de5c3
diff --git a/agent/auxiliary_client.py b/agent/auxiliary_client.py
index 151ed79512d..bd852d54df1 100644
--- a/agent/auxiliary_client.py
+++ b/agent/auxiliary_client.py
@@ -1716,7 +1716,7 @@ def _read_nous_auth() -> Optional[dict]:
try:
if not _AUTH_JSON_PATH.is_file():
return None
- data = json.loads(_AUTH_JSON_PATH.read_text())
+ data = json.loads(_AUTH_JSON_PATH.read_text(encoding="utf-8"))
if data.get("active_provider") != "nous":
return None
provider = data.get("providers", {}).get("nous", {})
diff --git a/agent/copilot_acp_client.py b/agent/copilot_acp_client.py
index 572e10758ad..9cbdcd34944 100644
--- a/agent/copilot_acp_client.py
+++ b/agent/copilot_acp_client.py
@@ -708,7 +708,7 @@ class CopilotACPClient:
if block_error:
raise PermissionError(block_error)
try:
- content = path.read_text()
+ content = path.read_text(encoding="utf-8")
except FileNotFoundError:
content = ""
line = params.get("line")
diff --git a/agent/shell_hooks.py b/agent/shell_hooks.py
index 45772d0578f..80453bc3713 100644
--- a/agent/shell_hooks.py
+++ b/agent/shell_hooks.py
@@ -632,7 +632,7 @@ def allowlist_path() -> Path:
def load_allowlist() -> Dict[str, Any]:
"""Return the parsed allowlist, or an empty skeleton if absent."""
try:
- raw = json.loads(allowlist_path().read_text())
+ raw = json.loads(allowlist_path().read_text(encoding="utf-8"))
except (FileNotFoundError, json.JSONDecodeError, OSError):
return {"approvals": []}
if not isinstance(raw, dict):
diff --git a/hermes_cli/profiles.py b/hermes_cli/profiles.py
index 1b99eca3922..df5c5984d19 100644
--- a/hermes_cli/profiles.py
+++ b/hermes_cli/profiles.py
@@ -414,7 +414,7 @@ def check_alias_collision(name: str) -> Optional[str]:
expected = wrapper_dir / (f"{canon}.bat" if is_windows else canon)
if existing_path == str(expected):
try:
- content = expected.read_text()
+ content = expected.read_text(encoding="utf-8")
if "hermes -p" in content:
return None # it's our wrapper, safe to overwrite
except Exception:
@@ -496,7 +496,7 @@ def remove_wrapper_script(name: str) -> bool:
if wrapper_path.exists():
try:
# Verify it's our wrapper before removing
- content = wrapper_path.read_text()
+ content = wrapper_path.read_text(encoding="utf-8")
if "hermes -p" in content:
wrapper_path.unlink()
return True
@@ -1755,7 +1755,7 @@ def _stop_gateway_process(profile_dir: Path) -> None:
return
try:
- raw = pid_file.read_text().strip()
+ raw = pid_file.read_text(encoding="utf-8").strip()
data = json.loads(raw) if raw.startswith("{") else {"pid": int(raw)}
pid = int(data["pid"])
# Route through terminate_pid so Windows uses the appropriate
@@ -1796,7 +1796,7 @@ def get_active_profile() -> str:
"""
path = _get_active_profile_path()
try:
- name = path.read_text().strip()
+ name = path.read_text(encoding="utf-8").strip()
if not name:
return "default"
return name
diff --git a/plugins/memory/hindsight/__init__.py b/plugins/memory/hindsight/__init__.py
index 9f5974b7b54..f27f5d352bf 100644
--- a/plugins/memory/hindsight/__init__.py
+++ b/plugins/memory/hindsight/__init__.py
@@ -746,7 +746,7 @@ class HindsightMemoryProvider(MemoryProvider):
existing = {}
if config_path.exists():
try:
- existing = json.loads(config_path.read_text())
+ existing = json.loads(config_path.read_text(encoding="utf-8"))
except Exception:
pass
existing.update(values)
diff --git a/plugins/memory/honcho/__init__.py b/plugins/memory/honcho/__init__.py
index 8ac56aec27d..c90734ad8a0 100644
--- a/plugins/memory/honcho/__init__.py
+++ b/plugins/memory/honcho/__init__.py
@@ -317,7 +317,7 @@ class HonchoMemoryProvider(MemoryProvider):
existing = {}
if config_path.exists():
try:
- existing = json.loads(config_path.read_text())
+ existing = json.loads(config_path.read_text(encoding="utf-8"))
except Exception:
pass
existing.update(values)
diff --git a/plugins/memory/mem0/__init__.py b/plugins/memory/mem0/__init__.py
index 35f413ed37a..b060a7bf7a8 100644
--- a/plugins/memory/mem0/__init__.py
+++ b/plugins/memory/mem0/__init__.py
@@ -240,7 +240,7 @@ class Mem0MemoryProvider(MemoryProvider):
existing = {}
if config_path.exists():
try:
- existing = json.loads(config_path.read_text())
+ existing = json.loads(config_path.read_text(encoding="utf-8"))
except Exception:
pass
existing.update(values)
diff --git a/tools/skills_hub.py b/tools/skills_hub.py
index 928c212a4b4..70e72fc5ad6 100644
--- a/tools/skills_hub.py
+++ b/tools/skills_hub.py
@@ -1144,7 +1144,7 @@ class GitHubSource(SkillSource):
stat = cache_file.stat()
if time.time() - stat.st_mtime > INDEX_CACHE_TTL:
return None
- return json.loads(cache_file.read_text())
+ return json.loads(cache_file.read_text(encoding="utf-8"))
except (OSError, json.JSONDecodeError):
return None
@@ -3409,7 +3409,7 @@ class HubLockFile:
if not self.path.exists():
return {"version": 1, "installed": {}}
try:
- return json.loads(self.path.read_text())
+ return json.loads(self.path.read_text(encoding="utf-8"))
except (json.JSONDecodeError, OSError):
return {"version": 1, "installed": {}}