Commit 2f4c9e6

benny-dou <60535774+benny-dou@users.noreply.github.com>
2026-05-21 07:33:48
fix(ai): handle empty responses from AI APIs
1 parent 709053a
src/ai/texts/claude.py
@@ -239,6 +239,7 @@ async def single_api_response(
                 silent=silent,
                 **kwargs,
             )
+        return {}
     return {
         "texts": answers,
         "thoughts": thoughts,
src/ai/texts/gemini.py
@@ -214,6 +214,7 @@ async def single_api_generate_content(
                 hide_thinking=hide_thinking,
                 **kwargs,
             )
+        return {}
     return {"texts": answers, "thoughts": thoughts, "sent_messages": sent_messages}
 
 
src/ai/texts/openai_chat.py
@@ -232,6 +232,7 @@ async def single_api_chat_completions(
                 silent=silent,
                 **kwargs,
             )
+        return {}
     return {"texts": answers, "thoughts": thoughts, "tool_name": tool_name.strip(), "tool_args": tool_args.strip(), "sent_messages": sent_messages}
 
 
src/ai/texts/openai_response.py
@@ -297,6 +297,7 @@ async def single_api_response(
                 silent=silent,
                 **kwargs,
             )
+        return {}
     return {"texts": answers, "thoughts": thoughts, "full_response": full_response, "response_id": response_id, "sent_messages": [m for m in sent_messages if isinstance(m, Message)]}