The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: startup recovery keeps the Windows resume's progress lines off the command's stdout
Tekniuma04e1a942bdd
diff --git a/hermes_cli/update_pause_record.py b/hermes_cli/update_pause_record.pyindex 160dec5f1d5..ba57e1eed98 100644--- a/hermes_cli/update_pause_record.py+++ b/hermes_cli/update_pause_record.py@@ -47,7 +47,7 @@ import sysimport threadingimport timeimport uuid-from contextlib import contextmanager, suppress+from contextlib import contextmanager, redirect_stdout, suppressfrom pathlib import PathRECORD_STEM = ".hermes-update-paused-gateways"@@ -902,7 +902,9 @@ def _resume_fenced(claim_path: Path, body: dict) -> None:if _has_work(token):print("→ Restarting gateway(s) paused by an interrupted `hermes update`...", file=sys.stderr)from hermes_cli.update_cmd_windows import _resume_windows_gateways_after_update- _resume_windows_gateways_after_update(token)+ # Whatever command this launch runs owns stdout (``--json`` output, a Desktop pipe).+ with redirect_stdout(sys.stderr):+ _resume_windows_gateways_after_update(token)else:token["resume_needed"] = Falseexcept Exception as exc: # health: allow BLE001 -- recovery boundary: any resume error is reported and the claim handed back (finally), never raised into the launchdiff --git a/tests/hermes_cli/test_update_pause_record.py b/tests/hermes_cli/test_update_pause_record.pyindex 9d9795a49f8..638d8348ac5 100644--- a/tests/hermes_cli/test_update_pause_record.py+++ b/tests/hermes_cli/test_update_pause_record.py@@ -173,13 +173,14 @@ def _orphan(tmp_path: Path, profiles: dict) -> None:owner.wait(timeout=10)-# The Windows resume cannot run here: the stand-in for it prints the set it was handed and-# (mode "hang") parks like a resume waiting on relaunch verification.+# The Windows resume cannot run here: the stand-in for it prints the set it was handed (on the real+# stdout: recovery points sys.stdout at stderr) and (mode "hang") parks like a resume waiting on+# relaunch verification._RECOVER = """import sys, timeimport hermes_cli.update_cmd_windows as wdef resume(token):- print("resume", sorted(token.get("profiles") or {}), flush=True)+ print("resume", sorted(token.get("profiles") or {}), file=sys.__stdout__, flush=True) # recovery sends stdout to stderrif sys.argv[1] == "hang":time.sleep(120)token["resume_needed"] = False@@ -319,7 +320,7 @@ _AT_LINE = """_RESUMES = """import hermes_cli.update_cmd_windows as wdef resume(token):- print("resume", sorted(token.get("profiles") or {}), flush=True)+ print("resume", sorted(token.get("profiles") or {}), file=sys.__stdout__, flush=True) # recovery sends stdout to stderrtoken["resume_needed"] = Falsew._resume_windows_gateways_after_update = resumer.recover(["status"])diff --git a/tests/hermes_cli/test_update_pause_recover_backoff.py b/tests/hermes_cli/test_update_pause_recover_backoff.pyindex a48da682b8d..3ef66c8812f 100644--- a/tests/hermes_cli/test_update_pause_recover_backoff.py+++ b/tests/hermes_cli/test_update_pause_recover_backoff.py@@ -22,7 +22,7 @@ def _claims() -> list:return pause_record._claims(pause_record.record_path())-def test_an_unready_relaunch_stalls_one_launch_per_backoff_window_and_stays_owed(tmp_path, monkeypatch):+def test_an_unready_relaunch_stalls_one_launch_per_backoff_window_and_stays_owed(tmp_path, monkeypatch, capsys):import hermes_cli.update_cmd_windows as wmonkeypatch.setenv("HERMES_HOME", str(tmp_path))pause_record.write(pause_record.stamp_tree({"resume_needed": True, "profiles": {"alpha": 4194000}}),@@ -42,6 +42,9 @@ def test_an_unready_relaunch_stalls_one_launch_per_backoff_window_and_stays_owedtoken = pause_record.read(claim)["token"]assert token["profiles"] == {"alpha": 4194000}, "the unready gateway's restart debt was dropped"assert token["relaunch_retry"]["profile:alpha"]["attempts"] == 1+ out = capsys.readouterr()+ assert "waiting for readiness" not in out.out and "waiting for readiness" in out.err, \+ "recovery wrote into the stdout of an unrelated command"body = json.loads(claim.read_text(encoding="utf-8"))body["token"]["relaunch_retry"]["profile:alpha"]["next_at"] = 0 # the window elapsed