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

This commit is contained in:
Matthew Zhou
2025-04-07 10:39:45 -07:00
committed by GitHub
parent 7d6aeba822
commit 1d57f4c938

View File

@@ -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