Agent Trace Debugger
A before-and-after regression report that explains overlap, own time and failed-token spending. Export one Span JSON object per line from your instrumentation and retain trace.json beside trace.html in CI.
A before-and-after regression report that explains overlap, own time and failed-token spending.
- Export one Span JSON object per line from your instrumentation and retain trace.json beside trace.html in CI.
- Node 22.18+ and Python 3 for the grader
- TypeScript objects, arrays, Map, sorting and interval arithmetic.
Agent Trace Debugger in 4 stages
A before-and-after regression report that explains overlap, own time and failed-token spending.
Read a JSONL trace
Parse one JSON object per nonempty line. Require stable ids, names, finite start and end times, nonnegative token counts and an explicit ok or error state. A malformed line stops processing with its line number. Silently dropping bad spans would distort timing and cost conclusions. Times are relative milliseconds, not wall-clock timestamps.
starter · ~2 hours · TypeScript
parseTraceValidate parent relationships
A child span must reference an existing parent and fit inside the parent interval. Check every ancestor chain for cycles and reject duplicate ids. Multiple roots are allowed because a trace can contain overlapping independent runs. Validation happens before aggregation so corrupted graphs cannot produce convincing charts.
core · ~2 hours · TypeScript
validateTreeSeparate work time from waiting time
Inclusive duration is end minus start. Exclusive duration subtracts the union of immediate child intervals, not their sum, because parallel children overlap. Root interval union provides wall time across runs. Tokens are local per span and summed once. The slowest result names the span with greatest exclusive duration, avoiding a root that is mostly waiting on children.
core · ~2 hours · TypeScript
unionDurationanalyzeRender an inspectable timeline
Generate a standalone HTML timeline with one row per span, scaled bars and error coloring. Escape span names before inserting them into markup. Include own time, total time, wall time, tokens and error count. Empty traces still produce a readable artifact. The output is a local static report and does not load third-party scripts.
core · ~2 hours · TypeScript
render