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.
This commit is contained in:
teknium1
2026-09-15 11:56:36 -07:00
committed by Teknium
parent bb89074ef2
commit 16ec8a35eb
-39
View File
@@ -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"