fix: unbound var in summarization [LET-6484] (#6568)

* fix: unbound var in summarization

* fix indentation
This commit is contained in:
cthomas
2025-12-08 17:23:11 -08:00
committed by Caren Thomas
parent fd14657e84
commit a7c0bad857

View File

@@ -78,6 +78,7 @@ async def summarize_via_sliding_window(
found_cutoff = False
# Count tokens with system prompt, and message past cutoff point
assistant_message_index = None # Initialize to track if we found an assistant message
while not found_cutoff:
# Mark the approximate cutoff
message_cutoff_index = round(message_count_cutoff_percent * len(all_in_context_messages))
@@ -110,6 +111,9 @@ async def summarize_via_sliding_window(
# If we found the cutoff, summarize and return
# If we didn't find the cutoff and we hit 100%, this is equivalent to complete summarization
if assistant_message_index is None:
raise ValueError("No assistant message found for sliding window summarization") # fall back to complete summarization
messages_to_summarize = all_in_context_messages[1:message_cutoff_index]
summary_message_str = await simple_summary(