~projectsagent-cost-lens
meter

Agent Cost Lens

Think of it as: Cost analytics for AI agent workflows

Know what every AI agent run actually costs.

Tracks tokens, retries, latency, and estimated cost across agents, models, providers, and repos. Surfaces expensive runs and retry waste.

stableMITlocal-onlyno telemetry
quickstart · agent-cost-lens
1# install (binary is `agent-cost`)
2npm install -g @agentopssec/agent-cost-lens
3
4# today's spend
5agent-cost today
6
7# break it down
8agent-cost by-model
9agent-cost by-repo
10agent-cost expensive-runs
11
12# set a daily budget
13agent-cost budget set 50
01

Why this exists

AI coding cost is spread across multiple tools, providers, repos, models, retries, and failed runs. By the time finance asks, it's hard to explain.

Agent Cost Lens collects local cost records (or estimates them when exact usage is missing) and rolls them up by repo, model, provider, day, and developer. Catch expensive runs and retry waste before they become a quarterly problem.

  • How much did agent runs cost today?
  • Which repo is the most expensive?
  • Which model or provider is driving spend?
  • How much cost came from retries?
  • Which runs failed after spending tokens?
  • Which tasks should use a cheaper model?
02

Quickstart

One command. No account. No telemetry.

quickstart · agent-cost-lens
1# install (binary is `agent-cost`)
2npm install -g @agentopssec/agent-cost-lens
3
4# today's spend
5agent-cost today
6
7# break it down
8agent-cost by-model
9agent-cost by-repo
10agent-cost expensive-runs
11
12# set a daily budget
13agent-cost budget set 50
03

Today's report

A real summary from the last 24 hours of agent activity.

summary · today
Total cost$18.42
Most expensive repodashboard-app
Most expensive modelClaude Sonnet
Highest waste34% retries
Most expensive run$2.14 · run_412
Budget$50/day · 36% used
cost by agent
codex$9.20
claude code$6.10
cursor agent$2.40
aider$0.70
04

Cost record shape

One record per run. Imported from Agent Flight Recorder when available.

records/run_001.json
1{ "runId": "run_001", "agent": "codex",
2 "repo": "dashboard-app",
3 "provider": "openai", "model": "gpt-5.2",
4 "inputTokens": 18400, "outputTokens": 2400,
5 "toolCallCount": 12, "latencyMs": 252000,
6 "retryCount": 2, "estimatedCost": 0.42,
7 "taskLabel": "fix failing tests" }
05

CLI reference

today / week / monthTime-window summaries.
by-modelCost grouped by model.
by-providerCost grouped by provider.
by-repoCost grouped by repo.
expensive-runsTop runs by cost.
budget set <amount>Set a budget threshold.
export --csvCSV export for reporting.
explain <run_id>Explain how a cost estimate was calculated.