From 14eb2623bc03f0d2eee9d446e9fed6577507295c Mon Sep 17 00:00:00 2001 From: Michal Date: Tue, 25 Aug 2026 23:48:07 +0100 Subject: [PATCH] fix(cli): trace's 'slowest' names a step, not the aggregate tool_call_trace and pipeline_execution are aggregates OF the stages, so letting them compete always named the total and told you nothing. Verified live: now reports 'slowest: paginate (252ms)' rather than 'tool_call_trace (509ms)'. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01GqMidYEGUJG5fxeoTELBu2 --- src/cli/src/commands/trace.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/cli/src/commands/trace.ts b/src/cli/src/commands/trace.ts index 9c25042..a3f2a41 100644 --- a/src/cli/src/commands/trace.ts +++ b/src/cli/src/commands/trace.ts @@ -144,9 +144,14 @@ export function createTraceCommand(deps?: Partial): Command { if (degraded !== null) degradedCount++; if (err !== null) errorCount++; - const ms = num(e.payload['durationMs']) ?? num(e.payload['totalDurationMs']); - const label = str(e.payload['stage']) ?? e.eventKind; - if (ms !== null && (slowest === null || ms > slowest.ms)) slowest = { name: label, ms }; + // Only real steps compete for "slowest" — tool_call_trace and + // pipeline_execution are aggregates OF those steps, so including them + // would always name the total and tell you nothing. + const ms = num(e.payload['durationMs']); + const label = str(e.payload['stage']); + if (ms !== null && label !== null && (slowest === null || ms > slowest.ms)) { + slowest = { name: label, ms }; + } const marks = [ degraded !== null ? `⚠ ${degraded}` : null,