The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(tui_gateway): teardown tests prove agent.close() reached the row finalizer
kshitijk4poorf0b2ba4160e4
diff --git a/tests/tui_gateway/test_cross_process_orphan_ownership.py b/tests/tui_gateway/test_cross_process_orphan_ownership.pyindex 750fc6a86cb..8658289d4d0 100644--- a/tests/tui_gateway/test_cross_process_orphan_ownership.py+++ b/tests/tui_gateway/test_cross_process_orphan_ownership.py@@ -393,7 +393,7 @@ def test_liveness_guard_serializes_cross_process_acquire(tmp_path: Path) -> None_stop_child(child, release_file)-def test_automatic_desktop_cleanup_preserves_sibling_and_ends_sole_owner(+def test_automatic_desktop_cleanup_preserves_sibling_and_releases_sole_owner_lease(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:"""Every automatic cleanup reason must preserve another Desktop backend."""diff --git a/tests/tui_gateway/test_gateway_owned_session_reap.py b/tests/tui_gateway/test_gateway_owned_session_reap.pyindex 4ca4c9444e5..5d58e936b6f 100644--- a/tests/tui_gateway/test_gateway_owned_session_reap.py+++ b/tests/tui_gateway/test_gateway_owned_session_reap.py@@ -72,6 +72,7 @@ def _make_real_session(tmp_path, monkeypatch, *, source, session_id):agent._session_messages = []agent._active_children_lock = threading.Lock()agent._active_children = []+ agent._memory_manager = None # close() reads it directly; a stub must not rely on _quietly swallowingsession = _make_session(session_id)session["agent"] = agent@@ -128,6 +129,7 @@ class TestGatewayOwnedSessionTeardown:assert row["ended_at"] is Noneassert row["end_reason"] is Noneassert agent._end_session_on_close is False+ assert agent._owns_session_db is False # close() reached _finalize_owned_session_rowclass TestDesktopAutomaticReclaimTeardown:@@ -146,10 +148,11 @@ class TestDesktopAutomaticReclaimTeardown:row = _read_real_row(db_path, f"desktop-{reason}")assert (row["ended_at"], row["end_reason"]) == (None, None)assert agent._end_session_on_close is False+ assert agent._owns_session_db is False # close() reached _finalize_owned_session_row@pytest.mark.parametrize("source,reason", [("desktop", "tui_close"), ("tui", "ws_orphan_reap")])def test_explicit_close_and_non_desktop_reap_still_end_row(self, tmp_path, monkeypatch, source, reason):- db_path, session, _agent = _make_real_session(+ db_path, session, agent = _make_real_session(tmp_path, monkeypatch, source=source, session_id=f"{source}-{reason}")@@ -158,3 +161,4 @@ class TestDesktopAutomaticReclaimTeardown:row = _read_real_row(db_path, f"{source}-{reason}")assert row["ended_at"] is not Noneassert row["end_reason"] == reason+ assert agent._end_session_on_close is True # flag untouched when the row was ended here