From fa0b0a5b9f51274140d616f978351d332c898dde Mon Sep 17 00:00:00 2001 From: Charles Packer Date: Tue, 8 Oct 2024 17:47:29 -0700 Subject: [PATCH] fix: CLI patches - patch runtime error on main loop + duplicate internal monologue (#1852) --- letta/agent.py | 5 ++++- letta/main.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/letta/agent.py b/letta/agent.py index 5589fec0..b8cc51f2 100644 --- a/letta/agent.py +++ b/letta/agent.py @@ -556,9 +556,12 @@ class Agent(BaseAgent): ) # extend conversation with assistant's reply printd(f"Function call message: {messages[-1]}") + nonnull_content = False if response_message.content: # The content if then internal monologue, not chat self.interface.internal_monologue(response_message.content, msg_obj=messages[-1]) + # Flag to avoid printing a duplicate if inner thoughts get popped from the function call + nonnull_content = True # Step 3: call the function # Note: the JSON response may not always be valid; be sure to handle errors @@ -619,7 +622,7 @@ class Agent(BaseAgent): if "inner_thoughts" in function_args: response_message.content = function_args.pop("inner_thoughts") # The content if then internal monologue, not chat - if response_message.content: + if response_message.content and not nonnull_content: self.interface.internal_monologue(response_message.content, msg_obj=messages[-1]) # (Still parsing function args) diff --git a/letta/main.py b/letta/main.py index 160b83da..f663148d 100644 --- a/letta/main.py +++ b/letta/main.py @@ -366,7 +366,7 @@ def run_agent_loop( first_message=False, skip_verify=no_verify, stream=stream, - inner_thoughts_in_kwargs=inner_thoughts_in_kwargs, + inner_thoughts_in_kwargs_option=inner_thoughts_in_kwargs, ms=ms, ) new_messages = step_response.messages