fix: granular cancellation check (#6540)

This commit is contained in:
cthomas
2025-12-05 23:32:53 -08:00
committed by Caren Thomas
parent b67347dff2
commit 77d1c3365e

View File

@@ -146,6 +146,10 @@ class LettaAgentV3(LettaAgentV2):
async for chunk in response:
response_letta_messages.append(chunk)
# Check if step was cancelled - break out of the step loop
if not self.should_continue and self.stop_reason.stop_reason == StopReasonType.cancelled.value:
break
# Proactive summarization if approaching context limit
if (
self.context_token_estimate is not None
@@ -280,7 +284,7 @@ class LettaAgentV3(LettaAgentV2):
first_chunk = False
# Check if step was cancelled - break out of the step loop
if not self.should_continue:
if not self.should_continue and self.stop_reason.stop_reason == StopReasonType.cancelled.value:
break
# Proactive summarization if approaching context limit