From 1d57f4c93869a20ec9d54f52cd595eae58590f03 Mon Sep 17 00:00:00 2001 From: Matthew Zhou Date: Mon, 7 Apr 2025 10:39:45 -0700 Subject: [PATCH] feat: Strip out thinking XML from persisted messages (#1596) --- letta/interfaces/anthropic_streaming_interface.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/letta/interfaces/anthropic_streaming_interface.py b/letta/interfaces/anthropic_streaming_interface.py index fc0741b9..84178932 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(""): + cutoff = len(content.text) - len("") + content.text = content.text[:cutoff] + return merged