Skip to content

Time and token breakdown by task, agent and tool #295

Open

Description

@blitzcrieg1

A user on Reddit asked for a breakdown of time and token usage by task, agent and tool, ideally live while a task runs, so a slow or expensive tool stands out. They had found two such cases by hand:

  • A headless browser that started fresh for every test, while a browser that stayed open on the page being worked on was far faster. Moving to it cut most of the time and tokens for the rest of their project.
  • A site visit where the agent started at the home page and walked every page taking screenshots. Pointing it straight at the right page, and telling it which CSS selectors held the value, cut the cost sharply.

Both were found only because they stopped and asked the agent to measure. A sensor that already records every tool call could show this all the time.

What exists today

  • Time: every tool call is recorded with a start and an end (PreToolUse and PostToolUse for Claude Code, and the equivalents for the other agents), so per-call duration is in the data. Nothing computes or shows it yet: the session tree lists calls but doesn't sum time.
  • Tokens: not recorded. Claude Code's OpenTelemetry export sends per-request data in its api_request events, and agentmetry otel already receives that export (Ingest Claude Code OpenTelemetry as a third capture tier #56), but it deliberately drops api_request today (KNOWN_UNMAPPED in core/audit/otel_ingest.py).

Proposal

  • Duration per tool call, from the start and end events, stored or derived at query time.
  • Map Claude Code api_request events to a canonical cost/usage record: tokens and duration per model request, with no prompt or response content. That keeps the default of structure, not content.
  • A breakdown view in the local dashboard and as a CLI or JSON output: per session, per agent, per tool, sorted slowest and costliest first, live during a session.

Caveats to keep honest

  • Tokens are counted per model request, not per tool. A tool's cost mostly arrives as input tokens on the next request, once its output is fed back in. "Tokens by tool" is an attribution estimate, and the view must say so. Time per tool is exact.
  • Token data is Claude Code only for now, and only when its OpenTelemetry export is enabled. Other agents would show time without tokens.
  • Showing this inside the Claude Code extension isn't something an outside tool can do. The live view belongs in Agentmetry's own dashboard.
  • No change to the frozen detection files. This is reporting, not detection.

Open question for users

Would a per-session breakdown in the dashboard have caught your slow or expensive tool, or do you need it per project or across a team?

Related: #45 (tool responses aren't recorded, so the trail can't see how much data moved), #56.

🤖 Generated with Claude Code

Activity

  1. added
    enhancement
    on Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions