Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
fix: patch bug w/ extended thinking mode involving `text` leaking into `reasoning` (#4341)
Charles Packerdc5da0ba363d
diff --git a/letta/interfaces/anthropic_streaming_interface.py b/letta/interfaces/anthropic_streaming_interface.pyindex 2b167e231..8f84c23ae 100644--- a/letta/interfaces/anthropic_streaming_interface.py+++ b/letta/interfaces/anthropic_streaming_interface.py@@ -289,6 +289,13 @@ class AnthropicStreamingInterface:if not self.anthropic_mode == EventMode.TEXT:raise RuntimeError(f"Streaming integrity failed - received BetaTextDelta object while not in TEXT EventMode: {delta}")+ # Weird bug happens with native thinking where a single response can contain:+ # [reasoning, text, tool_call]+ # In these cases, we should pipe text out to null / ignore it+ # TODO this will have to be redone to support non-tool calling message sending+ if not self.put_inner_thoughts_in_kwarg:+ return+# Combine buffer with current text to handle tags split across chunkscombined_text = self.partial_tag_buffer + delta.textdiff --git a/tests/integration_test_send_message.py b/tests/integration_test_send_message.pyindex 82363d07a..756adb5d2 100644--- a/tests/integration_test_send_message.py+++ b/tests/integration_test_send_message.py@@ -136,6 +136,7 @@ USER_MESSAGE_ROLL_DICE_LONG_THINKING: List[MessageCreate] = ["Explain the concept of randomness and how true random number generation works. ""End with some interesting facts about polyhedral dice and their history in gaming. ""Remember, make your response detailed and at least 800 characters long."+ "Absolutely do NOT violate this order of operations: (1) Think / reason, (2) Roll die, (3) Think / reason, (4) Call send_message tool."),otid=USER_MESSAGE_OTID,)