diff --git a/letta/agent.py b/letta/agent.py index 3217a52d0d..831e0f4a71 100644 --- a/letta/agent.py +++ b/letta/agent.py @@ -551,18 +551,19 @@ def _handle_ai_response( ) # extend conversation with assistant's reply printd(f"Function call message: {messages[-1]}") - # The content if then internal monologue, not chat - self.interface.internal_monologue(response_message.content, msg_obj=messages[-1]) + if response_message.content: + # The content if then internal monologue, not chat + self.interface.internal_monologue(response_message.content, msg_obj=messages[-1]) # Step 3: call the function # Note: the JSON response may not always be valid; be sure to handle errors - - # Failure case 1: function name is wrong function_call = ( response_message.function_call if response_message.function_call is not None else response_message.tool_calls[0].function ) function_name = function_call.name printd(f"Request to call function {function_name} with tool_call_id: {tool_call_id}") + + # Failure case 1: function name is wrong try: function_to_call = self.functions_python[function_name] except KeyError: