fix(analyzer): count parallel subagents/tools by wall-clock union, not sum#7
Closed
wan-huiyan wants to merge 1 commit into
Closed
fix(analyzer): count parallel subagents/tools by wall-clock union, not sum#7wan-huiyan wants to merge 1 commit into
wan-huiyan wants to merge 1 commit into
Conversation
…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.
This was referenced May 29, 2026
Author
|
Consolidated into #10 (time-breakdown accuracy + parallelism insight). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Aggregates
subagent/toolExecby 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