From b0e10cf4799e870b8647d57c424bd382fb728b28 Mon Sep 17 00:00:00 2001 From: Rin <144466399+rin259@users.noreply.github.com> Date: Sun, 15 Mar 2026 22:17:12 +0800 Subject: [PATCH] fix: add null check for delta in streaming mode to prevent AttributeError when tool calls are returned (#6365) --- astrbot/core/provider/sources/openai_source.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/astrbot/core/provider/sources/openai_source.py b/astrbot/core/provider/sources/openai_source.py index c40234ed4..982118619 100644 --- a/astrbot/core/provider/sources/openai_source.py +++ b/astrbot/core/provider/sources/openai_source.py @@ -322,7 +322,7 @@ class ProviderOpenAIOfficial(Provider): if reasoning: llm_response.reasoning_content = reasoning _y = True - if delta.content: + if delta and delta.content: # Don't strip streaming chunks to preserve spaces between words completion_text = self._normalize_content(delta.content, strip=False) llm_response.result_chain = MessageChain(