Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

fix: Check that content is not None before setting to internal_monologue (#1813)

Matthew Zhoue4bf9f668113
diff --git a/letta/agent.py b/letta/agent.py
index 3217a52d0..831e0f4a7 100644
--- a/letta/agent.py
+++ b/letta/agent.py
@@ -551,18 +551,19 @@ class Agent(BaseAgent):
) # 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: