The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(relay): trim the push-RuntimeError arm to two invariants
teknium1deaa20d7d87d
diff --git a/tests/agent/test_relay_session_segments.py b/tests/agent/test_relay_session_segments.pyindex d01cd2f3c57..902166d85db 100644--- a/tests/agent/test_relay_session_segments.py+++ b/tests/agent/test_relay_session_segments.py@@ -194,36 +194,6 @@ class TestSessionScopeFallback:runtime.ensure_session({"session_id": "sess-ref"})assert len(_session_pushes(fake)) == 1-- def test_push_failure_degrades_to_uninstrumented_lease_e2e(self, coordinator):- """End to end through the coordinator: a failing session push invokes push- once, the conversation degrades to an uninstrumented lease, and the next- acquire opens a working scope once the Relay recovers."""- fake = _FakeRelay()- runtime = _make_runtime(fake)- original_push = fake.scope.push- calls: list = []-- def failing_push(*args, **kwargs):- calls.append(args)- raise RuntimeError("scope push failed")-- fake.scope.push = failing_push-- lease = _acquire(coordinator, runtime, session_id="sess-e2e")- assert lease.session is None- assert len(calls) == 1-- turn = _run_turn(coordinator, lease, "t1")- assert turn.handle is None-- fake.scope.push = original_push- lease2 = _acquire(coordinator, runtime, session_id="sess-e2e")- assert lease2.session is not None- assert lease2.session.handle is not None- assert len(_session_pushes(fake)) == 1--def _acquire(coordinator, runtime, session_id="sess-1"):class _Registry:def for_profile(self, key):diff --git a/tests/hermes_cli/test_relay_shared_metrics_runtime.py b/tests/hermes_cli/test_relay_shared_metrics_runtime.pyindex 1eecaaed734..13fbdb9e638 100644--- a/tests/hermes_cli/test_relay_shared_metrics_runtime.py+++ b/tests/hermes_cli/test_relay_shared_metrics_runtime.py@@ -2614,3 +2614,35 @@ def test_skill_lifecycle_does_not_fallback_across_an_explicit_session(for event in direct_runtime.eventsif event[0] == "scope.event" and event[1] == "hermes.skill.lifecycle"] == []+++def test_real_binding_concurrent_task_close_skips_pop_under_sibling_scope(+ real_binding_runtime, caplog,+):+ """Two concurrent turns in one session open two task scopes on the same physical+ stack; finishing the LOWER one first must not raise "scope handle is not at the top+ of the stack" (#115471) nor pop the sibling's live scope. The orphan is reclaimed by+ the session-close drain, so both scopes are gone after the session ends."""+ event = {"session_id": "shared-session", "task_id": "task-A", "turn_id": "turn-A", "platform": "cli"}+ lifecycle.invoke_hook("on_session_start", **event)+ relay_shared_metrics.start_task_run(session_id="shared-session", task_id="task-A", platform="cli")+ relay_shared_metrics.start_task_run(session_id="shared-session", task_id="task-B", platform="cli")+ runtime = relay_shared_metrics._get_runtime()+ assert runtime is not None+ session = runtime._session(event)+ task_b_handle = session.tasks["task-B"].handle++ with caplog.at_level("WARNING"):+ relay_shared_metrics.finish_task_run(+ session_id="shared-session", task_id="task-A", platform="cli", result={"ok": True},+ )++ assert not [r for r in caplog.records if "task close failed" in r.getMessage()], caplog.text+ # Task B's live scope is still the top: the sibling was not popped through.+ assert relay_runtime._same_handle(relay_runtime._current_top(runtime.relay), task_b_handle)++ relay_shared_metrics.finish_task_run(+ session_id="shared-session", task_id="task-B", platform="cli", result={"ok": True},+ )+ lifecycle.invoke_hook("on_session_end", **event)+ assert "task close failed" not in caplog.text