msradam commited on
Commit
f9c55e4
·
verified ·
1 Parent(s): 6969759

fix(sse): send keepalive comments to prevent proxy idle timeout

Browse files
Files changed (1) hide show
  1. web/main.py +4 -0
web/main.py CHANGED
@@ -765,6 +765,10 @@ async def api_agent_stream(q: str):
765
  try:
766
  ev = await asyncio.to_thread(out_q.get, True, 1.0)
767
  except Exception:
 
 
 
 
768
  continue
769
  kind = ev.get("kind")
770
  if kind == "_done":
 
765
  try:
766
  ev = await asyncio.to_thread(out_q.get, True, 1.0)
767
  except Exception:
768
+ # No event for 1 s — send an SSE comment so the HF Space
769
+ # proxy doesn't close the idle connection (proxy idle timeout
770
+ # is ~15-20 s; the reconciler's vLLM call can take longer).
771
+ yield ": keepalive\n\n"
772
  continue
773
  kind = ev.get("kind")
774
  if kind == "_done":