From b56430062e918ec11e957439e554c1bb7f6c21db Mon Sep 17 00:00:00 2001 From: Charles Packer Date: Wed, 21 Jan 2026 15:11:41 -0800 Subject: [PATCH] fix: prevent premature cancellation of server-side tools in mixed execution (#619) Co-authored-by: Letta --- src/cli/App.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/cli/App.tsx b/src/cli/App.tsx index 286c446..220fd08 100644 --- a/src/cli/App.tsx +++ b/src/cli/App.tsx @@ -1776,11 +1776,16 @@ export default function App({ // If we're sending a new message, old pending state is no longer relevant // Pass false to avoid setting interrupted=true, which causes race conditions // with concurrent processConversation calls reading the flag - markIncompleteToolsAsCancelled( - buffersRef.current, - false, - "internal_cancel", - ); + // IMPORTANT: Skip this when allowReentry=true (continuing after tool execution) + // because server-side tools (like memory) may still be pending and their results + // will arrive in this stream. Cancelling them prematurely shows "Cancelled" in UI. + if (!allowReentry) { + markIncompleteToolsAsCancelled( + buffersRef.current, + false, + "internal_cancel", + ); + } // Reset interrupted flag since we're starting a fresh stream buffersRef.current.interrupted = false;