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) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GqMidYEGUJG5fxeoTELBu2
This commit is contained in:
2026-08-25 23:48:07 +01:00
parent 89db09a12d
commit 14eb2623bc

View File

@@ -144,9 +144,14 @@ export function createTraceCommand(deps?: Partial<TraceCommandDeps>): Command {
if (degraded !== null) degradedCount++; if (degraded !== null) degradedCount++;
if (err !== null) errorCount++; if (err !== null) errorCount++;
const ms = num(e.payload['durationMs']) ?? num(e.payload['totalDurationMs']); // Only real steps compete for "slowest" — tool_call_trace and
const label = str(e.payload['stage']) ?? e.eventKind; // pipeline_execution are aggregates OF those steps, so including them
if (ms !== null && (slowest === null || ms > slowest.ms)) slowest = { name: label, ms }; // 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 = [ const marks = [
degraded !== null ? `${degraded}` : null, degraded !== null ? `${degraded}` : null,