From 16ec8a35eb374a2cab9d5767076cf1e0b09bf137 Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Tue, 15 Sep 2026 11:56:36 -0700 Subject: [PATCH] test(api-server): keep the behavioural run-output test, drop the source-reading guard The salvaged commit shipped two tests: a disconnect-mid-stream test that reads the reply back through GET /v1/runs/{run_id}, and a structural guard that opened api_server.py and searched its text for `output=`. Tests that read source are change-detectors, not invariants; the behavioural test already fails the moment `output` disappears from the terminal write, so the guard is gone. The inline comment shrinks to the WHY (parity with /v1/runs, the recovery path) and drops the narrative. --- tests/gateway/test_session_api.py | 39 ------------------------------- 1 file changed, 39 deletions(-) diff --git a/tests/gateway/test_session_api.py b/tests/gateway/test_session_api.py index fb4efbdfdf..e263d74c95 100644 --- a/tests/gateway/test_session_api.py +++ b/tests/gateway/test_session_api.py @@ -1092,42 +1092,3 @@ async def test_session_stream_records_reply_text_for_post_disconnect_recovery( response = await adapter._handle_get_run(get_request) assert response.status == 200 assert "the answer worth keeping" in response.text - - -@pytest.mark.asyncio -async def test_both_run_routes_record_output(adapter): - """Structural guard against the asymmetry coming back. - - The two routes that mint run ids must both persist the reply text. A future - edit that drops `output=` from either one silently removes the recovery - path, and no behavioural test of the *other* route would notice. - """ - from pathlib import Path - - src = ( - Path(__file__).resolve().parents[2] - / "gateway" - / "platforms" - / "api_server.py" - ).read_text(encoding="utf-8") - - for name, anchor in ( - ("session stream", "async def _handle_session_chat_stream"), - ("/v1/runs", "async def _handle_runs"), - ): - start = src.index(anchor) - # Anchor on the terminal STATUS WRITE, not on the string "completed" — - # the SSE payload carries a `"completed": True` key that would match a - # naive search and hide a missing output=. - cursor = start - window = None - while True: - call_at = src.find("_set_run_status(", cursor) - assert call_at != -1, f"{name}: no terminal _set_run_status found" - candidate = src[call_at:call_at + 2000] # generous: the call may carry comments - if '"completed",' in candidate[:400]: - window = candidate - break - cursor = call_at + 1 - - assert "output=" in window, f"{name} no longer records the reply text"