From af4be770a111998c68264de712c8a46d2f25829b Mon Sep 17 00:00:00 2001 From: Vikhyath Mondreti Date: Fri, 24 Apr 2026 14:51:26 -0700 Subject: [PATCH] improvement(mothership): treat error as terminal event (#4290) --- apps/sim/lib/copilot/request/go/stream.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/sim/lib/copilot/request/go/stream.ts b/apps/sim/lib/copilot/request/go/stream.ts index d179653086..c92d135aff 100644 --- a/apps/sim/lib/copilot/request/go/stream.ts +++ b/apps/sim/lib/copilot/request/go/stream.ts @@ -571,14 +571,14 @@ function stampSseReadLoopSpan( const nowWall = Date.now() const startWall = nowWall - (nowPerf - startPerfMs) - const terminalEventSeen = counters.eventsByType.complete > 0 + const terminalEventSeen = counters.eventsByType.complete > 0 || counters.eventsByType.error > 0 // `terminal_event_missing` is the single-attribute dashboard signal // for the "disappeared response" bug class: the caller considered // this leg to be the final one (`context.streamComplete === true`) - // but no `complete` event arrived on the wire. Tool-pause legs have - // expectedTerminal=false and never trip this, so dashboards can - // filter on `{ .copilot.sse.terminal_event_missing = true }` without - // false positives. + // but no terminal `complete` or `error` event arrived on the wire. + // Tool-pause legs have expectedTerminal=false and never trip this, so + // dashboards can filter on `{ .copilot.sse.terminal_event_missing = true }` + // without false positives. const terminalEventMissing = opts.expectedTerminal && !terminalEventSeen const tracer = getCopilotTracer()