Skip to content

Commit a7e03a5

Browse files
fix: 修复 interrupt 日志不上传
1 parent 05cabbb commit a7e03a5

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/query.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,17 @@ export async function* query(
254254
}
255255
: params
256256

257-
let terminal: Terminal
257+
let terminal: Terminal | undefined
258258
try {
259259
terminal = yield* queryLoop(paramsWithTrace, consumedCommandUuids)
260260
} finally {
261261
// Only end the trace if we created it — sub-agents own their traces
262-
if (ownsTrace) endTrace(langfuseTrace)
262+
if (ownsTrace) {
263+
const isAborted =
264+
terminal?.reason === 'aborted_streaming' ||
265+
terminal?.reason === 'aborted_tools'
266+
endTrace(langfuseTrace, undefined, isAborted ? 'interrupted' : undefined)
267+
}
263268
}
264269

265270
// Only reached if queryLoop returned normally. Skipped on throw (error
@@ -269,7 +274,8 @@ export async function* query(
269274
for (const uuid of consumedCommandUuids) {
270275
notifyCommandLifecycle(uuid, 'completed')
271276
}
272-
return terminal
277+
// biome-ignore lint/style/noNonNullAssertion: terminal is always assigned when queryLoop returns normally
278+
return terminal!
273279
}
274280

275281
async function* queryLoop(

0 commit comments

Comments
 (0)