fix: 修复 interrupt 日志不上传

This commit is contained in:
claude-code-best
2026-04-13 18:12:23 +08:00
parent 05cabbbd73
commit a7e03a5b30

View File

@@ -254,12 +254,17 @@ export async function* query(
} }
: params : params
let terminal: Terminal let terminal: Terminal | undefined
try { try {
terminal = yield* queryLoop(paramsWithTrace, consumedCommandUuids) terminal = yield* queryLoop(paramsWithTrace, consumedCommandUuids)
} finally { } finally {
// Only end the trace if we created it — sub-agents own their traces // 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 // Only reached if queryLoop returned normally. Skipped on throw (error
@@ -269,7 +274,8 @@ export async function* query(
for (const uuid of consumedCommandUuids) { for (const uuid of consumedCommandUuids) {
notifyCommandLifecycle(uuid, 'completed') notifyCommandLifecycle(uuid, 'completed')
} }
return terminal // biome-ignore lint/style/noNonNullAssertion: terminal is always assigned when queryLoop returns normally
return terminal!
} }
async function* queryLoop( async function* queryLoop(