File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
275281async function * queryLoop (
You can’t perform that action at this time.
0 commit comments