Skip to content

The agent that grows with you

fix(telemetry): read marker and receipt JSON BOM-tolerant (Windows footgun gate)

teknium193341d68c034
diff --git a/hermes_cli/observability/shared_metrics_process.py b/hermes_cli/observability/shared_metrics_process.py
index c0fcd27fc9c..c8cee799f71 100644
--- a/hermes_cli/observability/shared_metrics_process.py
+++ b/hermes_cli/observability/shared_metrics_process.py
@@ -127,7 +127,7 @@ def _claim(path: Path) -> Path | None:
else:
record_path = None
try:
- record = json.loads(path.read_text(encoding="utf-8"))
+ record = json.loads(path.read_text(encoding="utf-8-sig"))
except (OSError, ValueError):
return None
if record_path is None and record.get("state") == "running" and runtime_status_pid_is_live(record):
@@ -169,7 +169,7 @@ def _report_dead_markers(home: Path, own: Path) -> None:
if claimed is None:
continue
try:
- record = json.loads(claimed.read_text(encoding="utf-8"))
+ record = json.loads(claimed.read_text(encoding="utf-8-sig"))
except (OSError, ValueError):
record = None
if isinstance(record, dict):
diff --git a/hermes_cli/observability/shared_metrics_update.py b/hermes_cli/observability/shared_metrics_update.py
index 0185cc061c4..d29e9856b90 100644
--- a/hermes_cli/observability/shared_metrics_update.py
+++ b/hermes_cli/observability/shared_metrics_update.py
@@ -173,7 +173,7 @@ def report_pending_updates() -> None:
return
for path in sorted(directory.glob("*.json")):
try:
- receipt = json.loads(path.read_text(encoding="utf-8"))
+ receipt = json.loads(path.read_text(encoding="utf-8-sig"))
path.unlink() # claim first: a concurrent start that loses the unlink records nothing
except (OSError, ValueError):
continue