Skip to content

The agent that grows with you

fix: read the unified runtime's journals and group metadata BOM-tolerantly

teknium11b49728ef4c0
diff --git a/agent/runtime_session_store.py b/agent/runtime_session_store.py
index 57a8c881e3d..18f3ba89c37 100644
--- a/agent/runtime_session_store.py
+++ b/agent/runtime_session_store.py
@@ -121,7 +121,7 @@ class RuntimeSessionStore(RuntimeSessionCompressionMixin, RuntimeSessionLifecycl
if self.path.exists():
if self.path.stat().st_size > max_bytes:
raise WorkerPersistenceError('outbox_full')
- self.journal = json.loads(self.path.read_text(encoding="utf-8"))
+ self.journal = json.loads(self.path.read_text(encoding="utf-8-sig"))
if self.journal['scope'] != self.scope:
raise WorkerPersistenceError('outbox_scope_mismatch')
else:
diff --git a/cron/scheduler_authority.py b/cron/scheduler_authority.py
index bba09dea2c7..c9605550a62 100644
--- a/cron/scheduler_authority.py
+++ b/cron/scheduler_authority.py
@@ -27,7 +27,7 @@ def run_canonical_job(job, *, extra_prompt=None, cancel_event=None, execution_id
journal = journal_path(params['job_id'], params['request_id'])
record = {'params': params, 'receipt': None}
if journal.exists():
- record = json.loads(journal.read_text(encoding='utf-8'))
+ record = json.loads(journal.read_text(encoding='utf-8-sig'))
if record['params'] != params:
raise CronExecutionUnknown('cron admission identity conflict')
attempted = journal.exists()
@@ -90,7 +90,7 @@ def reconcile_pending():
root = get_hermes_home() / 'cron' / 'admissions'
for journal in sorted(root.glob('*.json')):
try:
- record = json.loads(journal.read_text(encoding='utf-8'))
+ record = json.loads(journal.read_text(encoding='utf-8-sig'))
params = record['params']
if journal != journal_path(params['job_id'], params['request_id']):
raise ValueError('cron journal identity conflict')
diff --git a/gateway/session_group_controls.py b/gateway/session_group_controls.py
index d3df6be7899..275ef3900c1 100644
--- a/gateway/session_group_controls.py
+++ b/gateway/session_group_controls.py
@@ -242,7 +242,7 @@ def _profiles(authority, actor, home, params):
'description': profile.description or '', 'display_name': profile.display_name or '',
'skill_count': profile.skill_count or 0}
path = home / 'profile.yaml'
- meta = yaml.safe_load(path.read_text(encoding='utf-8')) if path.is_file() else {}
+ meta = yaml.safe_load(path.read_text(encoding='utf-8-sig')) if path.is_file() else {}
meta = meta if isinstance(meta, dict) else {}
revisions = meta.get('_ui_meta_revisions')
row['ui_meta_revisions'] = {str(k): max(0, v) for k, v in revisions.items()
@@ -299,7 +299,7 @@ def _profiles(authority, actor, home, params):
'skill_count': 0}
meta_path = target / 'profile.yaml'
try:
- meta = yaml.safe_load(meta_path.read_text(encoding='utf-8')) if meta_path.is_file() else {}
+ meta = yaml.safe_load(meta_path.read_text(encoding='utf-8-sig')) if meta_path.is_file() else {}
except (OSError, yaml.YAMLError):
meta = {}
if isinstance(meta, dict):
diff --git a/hermes_cli/gateway_chat.py b/hermes_cli/gateway_chat.py
index 13fc37cafa6..d523cd8f22d 100644
--- a/hermes_cli/gateway_chat.py
+++ b/hermes_cli/gateway_chat.py
@@ -204,7 +204,7 @@ def launch_from_args(args) -> int:
return failed("credentials or agent init failed", 1)
query_file = getattr(args, "query_file", None)
if query_file:
- args.query = sys.stdin.read() if query_file == "-" else Path(query_file).read_text(encoding="utf-8")
+ args.query = sys.stdin.read() if query_file == "-" else Path(query_file).read_text(encoding="utf-8-sig")
if not args.query.strip():
raise GatewayClientError("--query-file is empty")
if not (getattr(args, "query", None) or getattr(args, "q", None) or getattr(args, "oneshot", None) or sys.stdin.isatty()):