Skip to content

The agent that grows with you

test(telemetry): settle the routed turns before snapshotting the revoked profile's rows

Teknium31ef97fde726
diff --git a/tests/hermes_cli/test_shared_metrics_exit_flush.py b/tests/hermes_cli/test_shared_metrics_exit_flush.py
index 172a49d7660..72b491b3126 100644
--- a/tests/hermes_cli/test_shared_metrics_exit_flush.py
+++ b/tests/hermes_cli/test_shared_metrics_exit_flush.py
@@ -210,7 +210,14 @@ def test_exit_flush_applies_each_profiles_own_consent(tmp_path, monkeypatch):
token = set_hermes_home_override(str(home))
try:
_finished_task_in_open_session(f"open-{home.name}")
- _wait_for(home, "hermes.task_run.finished")
+ # Relay delivers the task end event on its own thread, and the subscriber commits
+ # that one event's counters one by one (task_run.finished, then task_run.duration).
+ # The Relay barrier returns once the whole event is stored; polling for the first
+ # row snapshotted the turn mid-event, and its duration row "appeared" at exit.
+ runtime = relay_shared_metrics._get_runtime()
+ assert runtime is not None
+ runtime.relay.subscribers.flush()
+ assert "hermes.task_run.finished" in _metric_names(home)
finally:
reset_hermes_home_override(token)
_write_policy(revoked, enabled=False, send=False)