Skip to content

Commit 65a0af3

Browse files
test(agentex): correct late-connect test wording to connect-time check
The already-terminal-at-connect case is handled by the authoritative connect-time check, not the removed keepalive fallback. Update the docstring, comments, and assertion message accordingly; drop the now-unneeded ping-interval override. Test logic unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 1910cd9 commit 65a0af3

1 file changed

Lines changed: 10 additions & 12 deletions

File tree

agentex/tests/integration/test_task_stream.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -749,20 +749,18 @@ async def test_stream_ends_on_late_connect_to_terminal_task(
749749
self, test_agent_and_task, tasks_use_case, streams_use_case
750750
):
751751
"""
752-
Fallback termination path: a viewer that connects *after* the task has
753-
already reached a terminal state never receives a terminal task_updated
754-
event (it is behind the snapshot cursor), so the event-driven exit can't
755-
fire. The keepalive-cadence fallback must still end the stream instead of
756-
blocking on the topic forever.
752+
Connect-time termination path: a viewer that connects *after* the task
753+
has already reached a terminal state never receives a terminal
754+
task_updated event via the read loop — the event is behind the snapshot
755+
cursor, so the in-loop check can't fire. The authoritative connect-time
756+
check must end the stream (replay buffered events, then return) instead
757+
of blocking on the topic forever.
757758
"""
758-
# Shrink the keepalive interval so the fallback check runs within ~1s
759-
# instead of the production 15s.
760-
streams_use_case.environment_variables.SSE_KEEPALIVE_PING_INTERVAL = 1
761-
762759
_agent, task = test_agent_and_task
763760

764761
# Finish the task BEFORE anyone subscribes. The terminal task_updated is
765-
# XADDed to the stream now, so a later subscriber snapshots past it.
762+
# XADDed to the stream now, so a later subscriber snapshots past it and
763+
# the read loop never surfaces it.
766764
completed = await tasks_use_case.complete_task(id=task.id)
767765
assert completed.status == TaskStatus.COMPLETED
768766

@@ -775,7 +773,7 @@ async def drain_until_end():
775773

776774
reader_task = asyncio.create_task(drain_until_end())
777775

778-
# With no terminal event to react to, only the fallback can end it.
776+
# The connect-time check should end it near-immediately.
779777
try:
780778
await asyncio.wait_for(reader_task, timeout=10)
781779
except TimeoutError as err:
@@ -786,7 +784,7 @@ async def drain_until_end():
786784
pass
787785
raise AssertionError(
788786
"SSE stream to an already-terminal task did not self-close — the "
789-
"fallback termination check is not firing, so late-connect "
787+
"connect-time terminal check is not firing, so late-connect "
790788
"subscriptions leak as zombies."
791789
) from err
792790

0 commit comments

Comments
 (0)