Catalog PyPI
PACKAGE EXPLORERView in registry

agentprof

PyPI

Analyse AI coding agent sessions: call trees, timings, tokens, cost and waste.

agentsaiclaude-codecopilotcostllmobservabilitytokens
Versions collected1
Direct dependencies2From release 0.1.0
Last observed20 Oct, 22:59 UTC

README

Version 0.1.0 documentation

agentprof

PyPI Python versions CI License: MIT

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.

A Claude Code session as a call tree with timeline, cost, tokens and context per row

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.

Node details with timeline, cost per LLM call, context growth, subagents and LLM calls

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]
OptionPurpose
SESSIONOpen 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, --portInterface and port to bind.
--no-browserDo not open a browser.
--claude-root, --codex-root, --copilot-rootRead sessions from a different directory.
--pricingReplace the bundled price table: per-model token prices and the USD value of a Copilot credit (usd_per_credit).

Supported agents

AgentSessions read fromCost
Claude Code~/.claude/projects (or $CLAUDE_CONFIG_DIR/projects), including subagent transcriptsUSD at API list prices, estimated
OpenAI Codex CLI~/.codex/sessions, including subagent rolloutsUSD at API list prices, estimated
VS Code Copilot ChatworkspaceStorage of VS Code and VS Code Insiders on Linux, macOS and WindowsCredits 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.

FindingWhat it looks for
Repeated readsThe same file read several times with overlapping line ranges.
Re-acquired contextA subagent reading files its parent agent had already read.
Retry chainsSibling agents started with very similar tasks.
Repeated or failing commandsThe same command run again and again, or a high tool failure rate.
Polling loopsLong streaks of consecutive polling calls.
Cost outliersAgents that cost far more than their siblings.
Context bloatLarge uncached prompts and low cache hit ratios.
Cold cache rewritesLarge cache writes with little reuse, for example after the cache expired during a wait for the user.
Idle parentsA parent agent idling after a child agent completed.
Context jumpsContext 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: /api lists 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=json returns the same data as the API route.
  • Agent by agent: /summary gives 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: /findings puts the likely waste with the highest estimated cost first.
  • Bounded downloads: depth and fields cut 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, estimated or n/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.
EndpointReturns
/apiEndpoint index with parameters and descriptions
/docsInteractive OpenAPI schema
/api/sessionsAll sessions, newest first
/api/sessions/eventsServer-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}/summaryOne compact row per agent, with its parent, cost and cache breakdowns
/api/sessions/{id}/findingsFindings, 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}/diagnosticsParse counts and redacted details of malformed lines
/api/pricingThe 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

MIT

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
0.1.08 Oct 20262

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
epicodic/agentprof

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 22:59 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:15bdd5e927fa96f5633f69dcd9e2f2e0a2cc4deeff8babe20fc2533f03fca295