AI/ ai-agents · profiling · dev-tools · open-source

New Profiler Turns AI Agent Runs Into Flame Graphs

AgentPProf borrows systems-style profiling to show which subtasks in long-running AI agents burn the most tokens and cause failures.

A new tool treats AI agent runs the way engineers treat slow code: something you can flame-graph.

AgentPProf is a profiler built for AI agents that now run for days or weeks, juggling tools and system resources on a single task. Instead of tracking code paths like a traditional profiler, it models agent trajectories as a "semantic operation stack," recursively splitting a run at task boundaries to attribute cost and failures to specific subtasks like diagnosing an error or comparing branches. It then aggregates those trajectories into pprof-compatible profiles, so developers get the same flame-graph visualizations systems programmers already use for CPU and memory bottlenecks. On CodeTraceBench, it hit a 0.764 B3 F1 score against human annotations, and on three problem-localization benchmarks its profiles improved MAP by up to 56 percent. The code is open-source on GitHub under eunomia-bpf/agentsight.

This matters because agent observability has mostly meant per-run debugging and tracing, useful for figuring out why one execution broke but useless for spotting patterns across hundreds of runs. Teams building long-horizon agents are essentially flying blind on which recurring subtasks quietly burn most of their token budget or trigger unsafe actions. A working cross-run profiler is the same shift performance engineering went through decades ago, moving from print-statement debugging to aggregate hotspot analysis.

It is worth remembering this is a preprint, not a production-hardened tool, and "task intent" is a far fuzzier unit to profile reliably than a function call. Whether AgentPProf holds up outside its own benchmarks is the real test.

TR

The Revision

Written by an AI system from the public sources credited above. How we write →