The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(gateway): status readers flush the queued write before reading the file
kshitijk4poor2ed6387d87b4
diff --git a/tests/gateway/test_drain_active_work_report.py b/tests/gateway/test_drain_active_work_report.pyindex 8e8568b4591..33d3c14b506 100644--- a/tests/gateway/test_drain_active_work_report.py+++ b/tests/gateway/test_drain_active_work_report.py@@ -11,6 +11,7 @@ import cron.scheduler as schedfrom gateway.run import GatewayRunnerfrom gateway.session_state import SessionStatefrom hermes_cli.update_cmd_drain_report import drain_progress_reporter+from gateway.status import flush_runtime_statusclass _FakeAgent:@@ -39,6 +40,7 @@ def test_draining_status_names_chat_and_cron_units_and_clears_when_running(tmp_pwith sched._running_lock:sched._running_worker_pids["job-a"] = 4242runner._update_runtime_status("draining")+ flush_runtime_status()record = json.loads((tmp_path / "gateway_state.json").read_text())by_kind = {unit["kind"]: unit for unit in record["active_work"]}assert by_kind["chat"]["session"] == "telegram:dm:1" and by_kind["chat"]["current_tool"] == "terminal"@@ -48,6 +50,7 @@ def test_draining_status_names_chat_and_cron_units_and_clears_when_running(tmp_psched.release_running_job("job-a")assert sched.get_running_job_details() == []runner._update_runtime_status("running")+ flush_runtime_status()assert json.loads((tmp_path / "gateway_state.json").read_text())["active_work"] is Nonediff --git a/tests/gateway/test_multiplex_adapter_registry.py b/tests/gateway/test_multiplex_adapter_registry.pyindex 4a0d3e1c709..10db9826444 100644--- a/tests/gateway/test_multiplex_adapter_registry.py+++ b/tests/gateway/test_multiplex_adapter_registry.py@@ -13,6 +13,7 @@ import pytestimport gateway.run as gateway_runfrom gateway.config import GatewayConfig, Platform, PlatformConfigfrom gateway.run import GatewayRunner+from gateway.status import flush_runtime_statusclass _FakeAdapter:@@ -880,6 +881,7 @@ class TestSecondaryProfileConfigHandling:runner.config = GatewayConfig(multiplex_profiles=False)assert await runner._start_secondary_profile_adapters() == 0+ flush_runtime_status()assert read_runtime_status(tmp_path / "gateway_state.json")["served_profiles"] == []@pytest.mark.asynciodiff --git a/tests/gateway/test_multiplex_hot_serve.py b/tests/gateway/test_multiplex_hot_serve.pyindex 3f1f1674dc6..ab5fda4e82a 100644--- a/tests/gateway/test_multiplex_hot_serve.py+++ b/tests/gateway/test_multiplex_hot_serve.py@@ -15,6 +15,7 @@ import pytestfrom gateway.config import GatewayConfig, Platformfrom gateway.run import GatewayRunnerfrom gateway.run_profile_reconcile import profile_serve_signature+from gateway.status import flush_runtime_statusclass _Adapter:@@ -75,6 +76,7 @@ def _mkprofile(home, name, env=""):def _served_record(home):+ flush_runtime_status()return json.loads((home / "gateway_state.json").read_text(encoding="utf-8")).get("served_profiles")diff --git a/tests/gateway/test_multiplex_shared_ingress.py b/tests/gateway/test_multiplex_shared_ingress.pyindex 299dc3a78ba..72334e27d05 100644--- a/tests/gateway/test_multiplex_shared_ingress.py+++ b/tests/gateway/test_multiplex_shared_ingress.py@@ -125,7 +125,7 @@ async def test_prefixed_line_webhook_is_verified_by_the_named_profiles_secret_unasync def test_shared_listener_adapter_records_its_public_ingress_url(mux_home, monkeypatch):"""Runtime status carries the /p/<profile>/ URL so `gateway status` / the dashboard can show it."""writes: list[dict] = []- monkeypatch.setattr("gateway.status.write_runtime_status", lambda **kw: writes.append(kw))+ monkeypatch.setattr("gateway.status.publish_runtime_status", lambda **kw: writes.append(kw))coder = _line_adapter("secret-coder", "coder")coder._runtime_status_platform_key = "coder:line"runner = _Runner({"coder": {Platform("line"): coder}})