Agent Profiler

See where a slow Claude Code session spends time

·

source at 93fa0f7

·

Apache-2.0 license

Execution profiler for Claude Code: model wait vs tools vs subagents, live, with OTLP export

What this mod can do

  • Reviewed at commit 93fa0f7
  • Writes files
  • Connects to the internet
  • Reads environment variables
  • Sees each tool call before it runs and can block or change it
  • Also uses telemetry.log{to=collector}, which this page doesn't describe yet
5 more things it can do
  • Adds the /profile-export command
  • Adds the /profile-pane command
  • Adds the /profile command
  • Runs on a timer
  • Runs on Claude Code hooks, such as session start
Good to know (3)
  • Nothing leaves your machine until you set otlpEndpoint; left empty, traces are only written as files
  • Turn prompts, Bash commands and search patterns are exported only with exportCommandText on
  • Time inside the model server can't be split: time to first token lumps network, queueing and prefill
Are mods safe?

Preview

Terminal

⎿ agent-profiler: Agent Profiler pane opened (shown in the terminal and the desktop app). ╭────────────────────────────────────────────────────────────────────────────────────────────────✕─╮ │ 125ms agent time · 1 turn(s) │ │ model ███████░░░░░░░░░░░░░ 33% │ │ tools ░░░░░░░░░░░░░░░░░░░░ 0% │ │ subagents ░░░░░░░░░░░░░░░░░░░░ 0% │ │ engine/other █████████████░░░░░░░ 67% │ │ │ │ Running │ │ idle │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ ⚠ agent-profiler: ⏱ model 33% · tools 0%

Claude Desktop

Agent Profiler in Claude Desktop

What it does

A live pane and status entry that split agent time into model wait, tools, subagents and engine overhead, with /profile reports and OTLP traces for Jaeger or Grafana Tempo.

What you see
A live pane, a status entry, and a toast if export fails
Works in
Terminal and Claude Desktop
Slash commands
/profile-export, /profile-pane, /profile
Uses your tokens
No
Changes files
.otlp.json trace files under ~/.claude/agent-profiler
Network access
Your own OTLP collector, only if you set otlpEndpoint
Reviewed commit
93fa0f7
Preview recorded with
Claude Code 2.1.296

How it works

  1. Times every turn, model request, tool call and subagent from the start of the session
  2. Reads tool durations from Claude Code and the token usage the API reports
  3. Updates a status entry like model 61% - tools 28% at most twice a second
  4. Writes OTLP trace files after each turn; /profile-pane opens the live pane

Common questions

Why is my Claude Code session slow?

This mod splits agent time into model wait, tool execution, subagents and engine overhead, so you can see which part is large. /profile prints a report for the whole session and /profile turn for the last turn, with tool and model stats, repeated file reads and findings.

How do I send Claude Code traces to Jaeger or Grafana Tempo?

Set otlpEndpoint to your collector's OTLP/HTTP base URL, such as http://localhost:4318, and the mod POSTs each trace batch to /v1/traces. Without it, the trace files in ~/.claude/agent-profiler can be sent by hand. Span names follow the GenAI conventions, like chat <model> and execute_tool <tool>.

Does it measure the model's inference time?

No. It reports what the client can observe. Time to first token mixes network, queueing and prefill, and stream times are waits seen at the client, not time the model spent computing.

Does it work in VS Code or with claude -p?

It still records, exports and answers /profile there, but the pane and status entry only draw in the terminal and the Desktop Code tab.

More like this

Deck in Claude Desktop

A cockpit for Claude Code: plan bars and subagent strips, context, usage limits with reset countdowns and burn rates, spend, the model route and a pet. Six bar styles, three collapsed looks. CLI and Desktop.

[-] ▄▄▄▀▀▀▀▀▄▄▄▄ ▀▀ ▀ ▀ ▄▀ ▀▄ ▀▀▀▀ ▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀▀ ▄▄▀▀ ▀▀▀ ▀▀▀▄ Lv 5 ▀▀▀▀▀▀ ▀▀▀ ▀ ●●●●○ ▀ ▀▀ ♥♥♥♥♡

A pixel Pokémon that lives at the right edge of the band above the prompt

Opus 4.8 │ main │ app │ ▓▓░░░░░░░░ 44k/200k │ $0.41

Catppuccin Frappé-themed status line with model, git branch and dirty flag, folder, a block context bar, and session cost.

Opus 4.8 high ✦ │ ctx 22% │ app (main) │ PR #1287 ● │ $0.41 · 10m +128 -34 Session ● ● ● ● ● ● ● ● ○ ○ ○ 74% left Resets in 2h 6m Weekly ● ● ● ● ● ● ● ● ● ● ○ 93% left Resets in 2d 0h Fable ● ● ● ● ● ● ● ● ● ○ ○ 85% left Resets in 2d 0h ◐ Read:index.ts ✓ Read×1 ✓ Bash×1 ✓ Edit×1 ✓ Grep×1 ◐ code-reviewer Review the change for regressions

A header with model, context and burn rate per hour, then live tool and agent activity parsed from the session transcript.

Opus 4.8 │ ✍️ 22% │ app (main) │ ● high current ●●○○○○○○○○ 26% ⟳ 6:59pm weekly ○○○○○○○○○○ 7% ⟳ aug 1, 5:52pm

Model, context, directory and branch up top; five-hour and weekly quota as dot bars with reset times underneath. Flags --dangerously-skip-permissions with a lightning bolt. By Kamran Ahmed of roadmap.sh.

Opus 4.8 | app@main | 44k/200k (22%) | effort: high | 5h 26% @18:59 | 7d 7% @Sat Aug 1, 17:52

Model, directory and branch with diff counts, context tokens, reasoning effort, and five-hour and seven-day limits from Claude Code's own rate-limit data, with the usage API as fallback. Checks for new versions of itself once a day.