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.

chore: bounds check for assistant message index (#7070)

Ari Webb4878b49fa1f3
diff --git a/letta/services/summarizer/summarizer_sliding_window.py b/letta/services/summarizer/summarizer_sliding_window.py
index 8ff85f43e..d38ca58ec 100644
--- a/letta/services/summarizer/summarizer_sliding_window.py
+++ b/letta/services/summarizer/summarizer_sliding_window.py
@@ -101,7 +101,12 @@ async def summarize_via_sliding_window(
# get index of first assistant message after the cutoff point ()
assistant_message_index = next(
- (i for i in reversed(range(1, message_cutoff_index + 1)) if in_context_messages[i].role in valid_cutoff_roles), None
+ (
+ i
+ for i in reversed(range(1, message_cutoff_index + 1))
+ if i < len(in_context_messages) and in_context_messages[i].role in valid_cutoff_roles
+ ),
+ None,
)
if assistant_message_index is None:
logger.warning(f"No assistant message found for evicting up to index {message_cutoff_index}, incrementing eviction percentage")