mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
fix(backend/copilot): yield final StreamError after transient retry exhaustion for _HandledStreamError
When _run_stream_attempt raises a _HandledStreamError and all transient retries are exhausted, the outer retry loop sets ended_with_stream_error but stream_err remains None. The post-loop code only emits a StreamError when stream_err is not None, so the SSE stream closes silently and the frontend never learns the request failed. Yield a StreamError with the attempt's error message and code just before breaking out of the retry loop, ensuring clients always receive an error notification.
This commit is contained in:
@@ -2274,6 +2274,14 @@ async def stream_chat_completion_sdk(
|
||||
retryable=True,
|
||||
)
|
||||
ended_with_stream_error = True
|
||||
# After exhausting all transient retries the stream is about
|
||||
# to end. Yield a final StreamError so the client knows the
|
||||
# request failed — without this the SSE stream would close
|
||||
# silently and the frontend would never show an error.
|
||||
yield StreamError(
|
||||
errorText=exc.error_msg or FRIENDLY_TRANSIENT_MSG,
|
||||
code=exc.code or "transient_api_error",
|
||||
)
|
||||
break
|
||||
except Exception as e:
|
||||
stream_err = e
|
||||
|
||||
Reference in New Issue
Block a user