-
Stefy Lanza (nextime / spora ) authored
The first pass only retried when pick_engine returned no engine or the engine returned a non-200. But the real empty-reply case is a CONNECTION failure: during the engine startup/restart window the engine process isn't accepting yet, so self._long.send raises "All connection attempts failed" — caught by the outer except and relayed as a single empty SSE chunk (chunks=1) over the broker. Move the send inside the retry loop on both broker paths (streaming + buffered): retry on a connection exception and on not-ready statuses (425/429/500/502/503/504), attempt-bound (6 x 5s), and only surface the error once exhausted. A 4xx is a real client error and is still relayed as-is. Confirmed against debug.log: all failures were in the engine-startup window; requests after the engine came up streamed fine. Co-Authored-By:
Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RdMufYvtTbtGDWsiZVoXce
cfe21d56