The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: detect in-stream error chunks in SSE streaming path
AlexFucuson948cca664c6cf
diff --git a/agent/chat_completion_helpers.py b/agent/chat_completion_helpers.pyindex 3c5a90370ab..cc6299d39c8 100644--- a/agent/chat_completion_helpers.py+++ b/agent/chat_completion_helpers.py@@ -3916,6 +3916,20 @@ def interruptible_streaming_api_call(agent, api_kwargs: dict, *, on_first_delta=# Usage comes in the final chunk with empty choicesif hasattr(chunk, "usage") and chunk.usage:usage_obj = chunk.usage+ # Some OpenAI-compatible providers (DeepInfra, etc.)+ # return validation errors as in-stream error chunks:+ # choices=None with error_type/error_message in+ # model_extra. Without this check the error is+ # silently dropped and the stream ends empty →+ # EmptyStreamError → misleading "empty stream" message+ # and pointless retries on the same bad request. (#65631)+ _err_type = getattr(chunk, "error_type", None)+ _err_msg = getattr(chunk, "error_message", None)+ if _err_type or _err_msg:+ raise RuntimeError(+ f"Provider in-stream error"+ f" ({_err_type or 'unknown'}): {_err_msg or chunk}"+ )continuedelta = chunk.choices[0].delta