When running a langgraph agent for a long time I eventually get:
<class ‘httpx.TransportError’> Exceeded maximum SSE reconnection attempts
This comes from a loop using this:
async for chunk in client.runs.stream
How do I reconnect to the run without dropping output? (join_stream docs say it doesnt buffer output)
Docs also mention:
A background run can execute for longer than 1 hour, but a client must reconnect to the server (e.g. join stream via POST /threads/{thread_id}/runs/{run_id}/stream) to retrieve output from the run if the run is taking longer than 1 hour.
join_stream uses GET but stream doesn’t take a run_id argument
Edit: I set BG_JOB_TIMEOUT_SECS to 10 hours, this disconnection happens long before that and I can see the run continuing in the langsmith trace