diff --git a/libs/superagent/app/agents/llm.py b/libs/superagent/app/agents/llm.py index d1c80cfb3..2776c4be2 100644 --- a/libs/superagent/app/agents/llm.py +++ b/libs/superagent/app/agents/llm.py @@ -261,7 +261,7 @@ async def _process_stream_response(self, res: CustomStreamWrapper): async for chunk in res: new_message = chunk.choices[0].delta - if new_message.tool_calls: + if hasattr(new_message, "tool_calls"): new_tool_calls = self._process_tool_calls(new_message) tool_calls.extend(new_tool_calls) @@ -281,7 +281,7 @@ async def _process_model_response(self, res: ModelResponse): new_messages = self.messages new_message = res.choices[0].message - if new_message.tool_calls: + if hasattr(new_message, "tool_calls"): new_tool_calls = self._process_tool_calls(new_message) tool_calls.extend(new_tool_calls)