fix agent idle stream heartbeat visibility
This commit is contained in:
@@ -2385,9 +2385,9 @@ async def run_agent_stream(
|
||||
message = await asyncio.wait_for(queue.get(), timeout=0.25)
|
||||
except TimeoutError:
|
||||
if perf_counter() - last_output_at >= AGENT_STREAM_HEARTBEAT_SECONDS:
|
||||
# Keep otherwise-idle SSE connections alive while the model
|
||||
# or a local tool is taking several minutes to finish.
|
||||
yield ": keep-alive\n\n"
|
||||
# Send a visible SSE event (not only a comment) so clients
|
||||
# can reset idle timers and tell the user the agent is alive.
|
||||
yield "event: heartbeat\ndata: {}\n\n"
|
||||
last_output_at = perf_counter()
|
||||
continue
|
||||
yield f"event: progress\ndata: {json.dumps({'message': message}, ensure_ascii=False)}\n\n"
|
||||
|
||||
Reference in New Issue
Block a user