agentpprof
agentpprof turns local AI coding-agent sessions into pprof-compatible semantic
profiles. It reads Codex and Claude Code JSONL history through AgentSight's
agent-session crate, assigns one-word tags to sessions, prompts, and LLM
calls, and writes one explicit output file.
The profiles are not CPU profiles. They are projections over agent activity: tool events, file effects, network effects, or token usage.
Install
From this repository:
pprof Output
Generate a semantic task profile for the current repository:
Open it with standard Go pprof:
The default tasks view makes prompt tags the pprof leaf frame, so pprof -top
shows where the agent spent most of its session activity semantically.
Folded, SVG, and JSON outputs keep the full context-first task stack for
drilldown.
Views
Use --view to choose the projection:
Widths mean different things by view:
tasks: event count across tool and LLM-call activity.system: system-effect count, including tool category, process chain, effect, path/domain, and status frames.tools: compatibility alias for the system-effect projection.tokens: token count when reported by the agent log; otherwise bounded text estimates. Very large unsafe estimates are recorded asunknown=1so one replayed transcript cannot dominate the profile with bogus token width.files: file/path effect count.network: network/domain effect count.
Other Formats
The default format is pprof protobuf, gzipped when the output path ends in
.gz. The output extension also selects common formats:
Folded stacks are compatible with common flamegraph tooling. SVG output is a
single prefix-merged flamegraph built from the folded stacks. JSON output
includes redacted session summaries and the stack table. Passing
--include-previews writes prompt, command, and LLM-output previews into JSON;
avoid it for public artifacts unless the source sessions are already sanitized.
Path frames outside the selected project root are grouped into stable
external/* buckets so home-directory names are not emitted in public
profiles.
See ../docs/flamegraph/ for a flamegraph gallery and view-by-view usage
examples.
Tags
The default tagger is deterministic:
Add project-specific deterministic rules with repeated --tag-rule
arguments. Rules use KIND:TAG=REGEX, are tried in command-line order before
the built-in rules, and support session, prompt, llm, or all as
KIND:
For model-produced one-word tags, run a llama.cpp-compatible server and use:
LLM tags are cached under the user cache directory by default, for example
$XDG_CACHE_HOME/agentpprof/tags.json. Override with --cache, or pass
--no-cache to avoid saving new entries.
Selecting Sessions
By default, agentpprof scans recent local Codex and Claude Code sessions that
match --project-root.
Those logs can contain prompts, paths, model outputs, and tool results. For
repeatable private investigations, use explicit --session-file inputs.
Useful selectors:
No output directory is created unless the explicit -o/--output path contains
one.
Development