agentprof
A profiler for AI coding agents: see where your agents spend time, tokens and money.
agentprof reads the session logs that Claude Code, OpenAI Codex CLI and VS Code Copilot Chat already write on your machine. It shows each session as a call tree of turns, subagents and tool calls, with an inline timeline, token counts, context growth, costs and hints about likely waste. Everything runs locally, so your sessions never leave your machine.
Features
- Call tree with timeline: every prompt, subagent and tool call becomes a row with its duration, cost, tokens and peak context, next to a timeline bar for when it ran. Nested subagents get their own colour-coded agent numbers, so you can follow a delegation chain at a glance.
- Cost and token accounting: costs and tokens are given both per node and rolled up per subtree, with input, output, cache read and cache write tokens counted separately.
Estimated values are marked
≈, and values the logs do not contain are shown as–instead of being guessed. - Context tracking: see how the context window grows call by call, where it peaks and where it was compacted.
- Agent summary: one row per agent with its model, cache TTL, resumes, duration, own cost, share of the session cost and token breakdown.
- Node details: open any turn or agent to see its timeline, cost per LLM call, context chart, subagents and a searchable list of LLM and tool calls, down to the raw prompt, result and tool arguments.
- Waste findings: hints, not verdicts, about where time and money may have gone (see Findings).
- Live updates: the session list fills in within seconds, and open sessions update while an agent is still working.
- JSON API for AI agents: everything in the UI is also available as compact JSON, so an AI agent can analyse sessions itself, including how the agents and subagents in them worked together.
Installation
agentprof is a command-line tool that starts a local web app. Install it in its own isolated environment with uv or pipx:
uv tool install agentprof
# or
pipx install agentprof
Or run it once without installing it:
uvx agentprof
agentprof requires Python 3.12 or newer.
Usage
agentprof
This starts a local server on 127.0.0.1:8765 and opens your browser.
The session list appears immediately and fills in while sessions are summarised in the background; a session is analysed in full when you open it.
agentprof [SESSION] [--host 127.0.0.1] [--port 8765] [--no-browser]
[--claude-root DIR] [--codex-root DIR] [--copilot-root DIR]
[--pricing FILE]
| Option | Purpose |
|---|---|
SESSION |
Open a session directly: <agent>:<id> (e.g. claude-code:<id>), a bare id, or a session file path such as a Copilot chat export. |
--host, --port |
Interface and port to bind. |
--no-browser |
Do not open a browser. |
--claude-root, --codex-root, --copilot-root |
Read sessions from a different directory. |
--pricing |
Replace the bundled price table: per-model token prices and the USD value of a Copilot credit (usd_per_credit). |
Supported agents
| Agent | Sessions read from | Cost |
|---|---|---|
| Claude Code | ~/.claude/projects (or $CLAUDE_CONFIG_DIR/projects), including subagent transcripts |
USD at API list prices, estimated |
| OpenAI Codex CLI | ~/.codex/sessions, including subagent rollouts |
USD at API list prices, estimated |
| VS Code Copilot Chat | workspaceStorage of VS Code and VS Code Insiders on Linux, macOS and Windows |
Credits as reported by Copilot, converted to USD at $0.01 per credit |
Claude Code and Codex costs are API-equivalent estimates; on a subscription you do not pay per token. Costs keep their native unit and are never added across units.
Findings
agentprof flags likely waste as hints, not verdicts. Each finding is attached to the turn or agent it is about, and the session header counts them.
| Finding | What it looks for |
|---|---|
| Repeated reads | The same file read several times with overlapping line ranges. |
| Re-acquired context | A subagent reading files its parent agent had already read. |
| Retry chains | Sibling agents started with very similar tasks. |
| Repeated or failing commands | The same command run again and again, or a high tool failure rate. |
| Polling loops | Long streaks of consecutive polling calls. |
| Cost outliers | Agents that cost far more than their siblings. |
| Context bloat | Large uncached prompts and low cache hit ratios. |
| Cold cache rewrites | Large cache writes with little reuse, for example after the cache expired during a wait for the user. |
| Idle parents | A parent agent idling after a child agent completed. |
| Context jumps | Context that grew sharply between two calls. |
Local API for AI agents
agentprof is useful to people, and just as useful to AI agents. While it runs, everything it knows about a session is available as JSON on the same port, so you can point an agent at a session and ask it what went wrong, why a run was expensive or how its subagents worked together.
The API is built for this:
- Self-describing:
/apilists every endpoint with its parameters, and each session page links to its JSON, so a URL from the browser is enough to start with./sessions/{id}?format=jsonreturns the same data as the API route. - Agent by agent:
/summarygives one row per agent with its parent agent, so the delegation tree can be rebuilt without the full call tree. Each row has the agent's topic, models, LLM calls, peak context, tokens, cache TTL, resumes, longest gap, its own cost and the cost of everything it delegated. - Findings first:
/findingsputs the likely waste with the highest estimated cost first. - Bounded downloads:
depthandfieldscut a large call tree down to what fits in a context window; prompts, results and tool arguments are only fetched for the node that needs them. - Honest numbers: every value says whether it is
exact,estimatedorn/a, so an agent can tell measurements from guesses.
For example, ask your agent:
agentprof is running on http://127.0.0.1:8765. Start at /api, open session
claude-code:<id> and explain which subagents drove the cost, where they
waited for each other, and what we could do differently next time.
| Endpoint | Returns |
|---|---|
/api |
Endpoint index with parameters and descriptions |
/docs |
Interactive OpenAPI schema |
/api/sessions |
All sessions, newest first |
/api/sessions/events |
Server-sent events for session list updates |
/api/sessions/{id} |
The full call tree with metrics and findings; depth and fields=session,diagnostics,tree bound a large download |
/api/sessions/{id}/summary |
One compact row per agent, with its parent, cost and cache breakdowns |
/api/sessions/{id}/findings |
Findings, ordered by estimated avoidable cost, severity and time |
/api/sessions/{id}/nodes/{node_id} |
Prompt, result and raw tool arguments of one node |
/api/sessions/{id}/diagnostics |
Parse counts and redacted details of malformed lines |
/api/pricing |
The effective price table and its model matching rule |
Development
./bootstrap.sh # install uv, Node (nvm), pnpm and all dependencies
uv run agentprof # run against your own sessions
pnpm --dir frontend dev # frontend dev server, proxies /api to port 8765
uv run qa # lint, type check and tests for Python and the frontend
uv run build-dist # build and smoke-test the distributions
See docs/architecture.md for how the code fits together, AGENTS.md for conventions and docs/releasing.md for releases.
License
Metadata
Release files for agentprof 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| agentprof-0.1.0.tar.gz | 342.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| agentprof-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 707.1 kB
Release files / agentprof-0.1.0.tar.gz
| Download URL | agentprof-0.1.0.tar.gz |
|---|---|
| Size | 342.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
24f1c642b9fc77a90024ceeb6f6fc897a9dc2833e9e3dc1fc645f381b81f86ad
|
|
BLAKE2b-256 checksum How to use checksums |
4b95ba41e2131f340050592161807b7d13aa688c3d16a7e4e9899c96baec0f01
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency logRelease files / agentprof-0.1.0-py3-none-any.whl
| Download URL | agentprof-0.1.0-py3-none-any.whl |
|---|---|
| Size | 365.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5e5359ee0087ad57e3b8cb0b2b7d2431039f6cedf4153649aeae3bcfe230b30d
|
|
BLAKE2b-256 checksum How to use checksums |
96de4e779de3427266f253b628fccfc9b367ba79ac8412137331f06145c714e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency log