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: send message tests (#2656)

cthomas64ac7a7debf1
diff --git a/letta/interfaces/anthropic_streaming_interface.py b/letta/interfaces/anthropic_streaming_interface.py
index 2471ba785..4e643afb5 100644
--- a/letta/interfaces/anthropic_streaming_interface.py
+++ b/letta/interfaces/anthropic_streaming_interface.py
@@ -252,7 +252,7 @@ class AnthropicStreamingInterface:
# Strip out the inner thoughts from the buffered tool call arguments before streaming
tool_call_args = ""
for buffered_msg in self.tool_call_buffer:
- tool_call_args += buffered_msg.tool_call.arguments
+ tool_call_args += buffered_msg.tool_call.arguments if buffered_msg.tool_call.arguments else ""
tool_call_args = tool_call_args.replace(f'"{INNER_THOUGHTS_KWARG}": "{current_inner_thoughts}"', "")
tool_call_msg = ToolCallMessage(
diff --git a/letta/llm_api/helpers.py b/letta/llm_api/helpers.py
index c5ca5c92a..749ae974c 100644
--- a/letta/llm_api/helpers.py
+++ b/letta/llm_api/helpers.py
@@ -296,6 +296,8 @@ def unpack_inner_thoughts_from_kwargs(choice: Choice, inner_thoughts_key: str) -
except json.JSONDecodeError as e:
warnings.warn(f"Failed to strip inner thoughts from kwargs: {e}")
+ print(f"\nFailed to strip inner thoughts from kwargs: {e}")
+ print(f"\nTool call arguments: {tool_call.function.arguments}")
raise e
else:
warnings.warn(f"Did not find tool call in message: {str(message)}")