From a7e03a5b309faa80f7f864f25ea5589739935acc Mon Sep 17 00:00:00 2001 From: claude-code-best Date: Mon, 13 Apr 2026 18:12:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20interrupt=20?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E4=B8=8D=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/query.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/query.ts b/src/query.ts index 026f0d74e..8bfca6111 100644 --- a/src/query.ts +++ b/src/query.ts @@ -254,12 +254,17 @@ export async function* query( } : params - let terminal: Terminal + let terminal: Terminal | undefined try { terminal = yield* queryLoop(paramsWithTrace, consumedCommandUuids) } finally { // Only end the trace if we created it — sub-agents own their traces - if (ownsTrace) endTrace(langfuseTrace) + if (ownsTrace) { + const isAborted = + terminal?.reason === 'aborted_streaming' || + terminal?.reason === 'aborted_tools' + endTrace(langfuseTrace, undefined, isAborted ? 'interrupted' : undefined) + } } // Only reached if queryLoop returned normally. Skipped on throw (error @@ -269,7 +274,8 @@ export async function* query( for (const uuid of consumedCommandUuids) { notifyCommandLifecycle(uuid, 'completed') } - return terminal + // biome-ignore lint/style/noNonNullAssertion: terminal is always assigned when queryLoop returns normally + return terminal! } async function* queryLoop(