From b3a213a56f0790604bba55d489eaec58ffe4ee1d Mon Sep 17 00:00:00 2001 From: cthomas Date: Mon, 19 Jan 2026 12:10:33 -0800 Subject: [PATCH] =?UTF-8?q?revert:=20fix:=20include=20assistant=20response?= =?UTF-8?q?=20in=20sliding=20window=20summarizati=E2=80=A6=20(#8929)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit revert: fix: include assistant response in sliding window summarization slice --- letta/services/summarizer/summarizer_sliding_window.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/letta/services/summarizer/summarizer_sliding_window.py b/letta/services/summarizer/summarizer_sliding_window.py index e7969a2b..d38ca58e 100644 --- a/letta/services/summarizer/summarizer_sliding_window.py +++ b/letta/services/summarizer/summarizer_sliding_window.py @@ -127,9 +127,7 @@ async def summarize_via_sliding_window( # need to keep the last message (might contain an approval request) raise ValueError(f"Assistant message index {assistant_message_index} is at the end of the message buffer, skipping summarization") - # Include the assistant message at the cutoff point so conversations are complete - # (otherwise the slice ends with a user question and the LLM answers it instead of summarizing) - messages_to_summarize = in_context_messages[1 : assistant_message_index + 1] + messages_to_summarize = in_context_messages[1:assistant_message_index] logger.info( f"Summarizing {len(messages_to_summarize)} messages, from index 1 to {assistant_message_index} (out of {total_message_count})" ) @@ -146,7 +144,5 @@ async def summarize_via_sliding_window( logger.warning(f"Summary length {len(summary_message_str)} exceeds clip length {summarizer_config.clip_chars}. Truncating.") summary_message_str = summary_message_str[: summarizer_config.clip_chars] + "... [summary truncated to fit]" - # Start remaining messages FROM the assistant message we included in the summary - # (to preserve tool call sequences if the assistant message has tool_calls) updated_in_context_messages = in_context_messages[assistant_message_index:] return summary_message_str, [system_prompt] + updated_in_context_messages