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.

feat: Strip out thinking XML from persisted messages (#1596)

Matthew Zhou1d57f4c93869
diff --git a/letta/interfaces/anthropic_streaming_interface.py b/letta/interfaces/anthropic_streaming_interface.py
index fc0741b9c..84178932a 100644
--- a/letta/interfaces/anthropic_streaming_interface.py
+++ b/letta/interfaces/anthropic_streaming_interface.py
@@ -320,4 +320,10 @@ class AnthropicStreamingInterface:
if current_group:
merged.append(_process_group(current_group, current_group_type))
+ # Strip out XML from any text content fields
+ for content in merged:
+ if isinstance(content, TextContent) and content.text.endswith("</thinking>"):
+ cutoff = len(content.text) - len("</thinking>")
+ content.text = content.text[:cutoff]
+
return merged