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: always strip thinking tags from anthropic stream (#1483)

cthomas6c30dcd20931
diff --git a/letta/llm_api/anthropic.py b/letta/llm_api/anthropic.py
index 4cf3f4200..953ae530f 100644
--- a/letta/llm_api/anthropic.py
+++ b/letta/llm_api/anthropic.py
@@ -1107,4 +1107,9 @@ def anthropic_chat_completions_process_stream(
log_event(name="llm_response_received", attributes=chat_completion_response.model_dump())
+ for choice in chat_completion_response.choices:
+ if choice.message.content is not None:
+ choice.message.content = choice.message.content.replace(f"<{inner_thoughts_xml_tag}>", "")
+ choice.message.content = choice.message.content.replace(f"</{inner_thoughts_xml_tag}>", "")
+
return chat_completion_response