(map: Map<string, ToolStat>, node: ToolCallNode)
| 425 | } |
| 426 | |
| 427 | function recordToolStat(map: Map<string, ToolStat>, node: ToolCallNode): void { |
| 428 | let s = map.get(node.name); |
| 429 | if (!s) { |
| 430 | s = { name: node.name, count: 0, errorCount: 0, truncatedCount: 0, timedCount: 0, totalMs: 0, avgMs: null, maxMs: null, totalOutputBytes: 0 }; |
| 431 | map.set(node.name, s); |
| 432 | } |
| 433 | s.count += 1; |
| 434 | if (node.isError) s.errorCount += 1; |
| 435 | if (node.truncated) s.truncatedCount += 1; |
| 436 | if (node.outputBytes !== undefined) s.totalOutputBytes += node.outputBytes; |
| 437 | if (node.durationMs !== undefined) { |
| 438 | s.timedCount += 1; |
| 439 | s.totalMs += node.durationMs; |
| 440 | s.maxMs = s.maxMs === null ? node.durationMs : Math.max(s.maxMs, node.durationMs); |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | function summarize( |
| 445 | turns: readonly TurnNode[], |
no test coverage detected