Skip to content

fix(analyzer): count parallel subagents/tools by wall-clock union, not sum#7

Closed
wan-huiyan wants to merge 1 commit into
dioptx:mainfrom
wan-huiyan:upstream/subagent-union
Closed

fix(analyzer): count parallel subagents/tools by wall-clock union, not sum#7
wan-huiyan wants to merge 1 commit into
dioptx:mainfrom
wan-huiyan:upstream/subagent-union

Conversation

@wan-huiyan
Copy link
Copy Markdown

Aggregates subagent/toolExec by wall-clock interval union instead of summing per-segment, so parallel fan-out (e.g. a panel of review subagents in one turn) isn't double-counted and active-time stays ≤100%. subagent = time with ≥1 agent open; toolExec = busy-with-tool minus subagent. +3 tests; tsc clean.

Supersedes #3 (moved to a dedicated branch, immune to fork-internal churn). 🤖 Generated with Claude Code

…t sum

computeEnhancedStats emitted one segment per tool/agent and summed their
durations. When tools or subagents are fanned out in a single assistant turn
(e.g. a 5-agent review panel, or parallel Read/Bash calls), those segments
overlap in wall-clock time, so summing double-counts the concurrency — the
'Subagents' bar reported cumulative agent-seconds, not real elapsed time, and
the active-time percentages could sum to >100% (e.g. 109%).

Aggregate toolExec and subagent by wall-clock interval UNION instead:
  - subagent = time with >=1 subagent open
  - toolExec = busy-with-a-tool time NOT already counted as subagent
    (subagent wins the rare cross-kind overlap, e.g. Agent + Bash in one turn)
claudeThink / planning / humanWait / humanAway are emitted as sequential,
non-overlapping slices and are still summed (unchanged).

On a fan-out-heavy session this dropped reported subagent time from ~53m
(sum of 19 overlapping agents) to ~38m (true elapsed), and the breakdown now
sums to ~100% instead of 109%. The per-call 'Tools' latency table (avg/p50/p95)
is computed separately and is intentionally unchanged.

Tests: 3 cases (parallel agents → union not sum; parallel non-agent tools →
union; sequential agents still add up). 90/90 tests pass.
@wan-huiyan
Copy link
Copy Markdown
Author

Consolidated into #10 (time-breakdown accuracy + parallelism insight).

@wan-huiyan wan-huiyan closed this May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant