Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
fix: use message idx for anthropic legacy streaming (#1600)
cthomas0af857d3baaa
diff --git a/letta/llm_api/anthropic.py b/letta/llm_api/anthropic.pyindex 1fa1e2cf8..ca6a91568 100644--- a/letta/llm_api/anthropic.py+++ b/letta/llm_api/anthropic.py@@ -930,6 +930,8 @@ def anthropic_chat_completions_process_stream(stream_interface.stream_start()completion_tokens = 0+ prev_message_type = None+ message_idx = 0try:for chunk_idx, chat_completion_chunk in enumerate(anthropic_chat_completions_request_stream(@@ -945,7 +947,7 @@ def anthropic_chat_completions_process_stream(if stream_interface:if isinstance(stream_interface, AgentChunkStreamingInterface):- stream_interface.process_chunk(+ message_type = stream_interface.process_chunk(chat_completion_chunk,message_id=chat_completion_response.id if create_message_id else chat_completion_chunk.id,message_date=chat_completion_response.created if create_message_datetime else chat_completion_chunk.created,@@ -953,8 +955,11 @@ def anthropic_chat_completions_process_stream(# TODO handle emitting redacted reasoning content (e.g. as concat?)expect_reasoning_content=extended_thinking,name=name,- chunk_index=chunk_idx,+ message_index=message_idx,)+ if message_type != prev_message_type and message_type is not None:+ message_idx += 1+ prev_message_type = message_typeelif isinstance(stream_interface, AgentRefreshStreamingInterface):stream_interface.process_refresh(chat_completion_response)else: