From 898c0ed83e433dacf5bcb5c5092e7e2681bb45cb Mon Sep 17 00:00:00 2001 From: cthomas Date: Mon, 24 Nov 2025 23:39:37 -0800 Subject: [PATCH] test: cancellation edge case in test (#6379) --- tests/integration_test_send_message_v2.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/integration_test_send_message_v2.py b/tests/integration_test_send_message_v2.py index e38c9715..66028048 100644 --- a/tests/integration_test_send_message_v2.py +++ b/tests/integration_test_send_message_v2.py @@ -224,6 +224,11 @@ def assert_tool_call_response( assert messages[index].otid and messages[index].otid[-1] == str(otid_suffix) index += 1 + # If cancellation happens before tool return, we might get LettaStopReason directly + if with_cancellation and index < len(messages) and isinstance(messages[index], LettaStopReason): + assert messages[index].stop_reason == "cancelled" + return # Skip remaining assertions for very early cancellation + # Tool return message otid_suffix = 0 assert isinstance(messages[index], ToolReturnMessage)