See what your agent did and what it cost.
Put costcatch in front of the command that runs your agent / project. See every LLM call it makes, what each call cost, and what went wrong.
- works with
- Python, Node
- providers
- 10, auto-detected
- models priced
- 5,831 current prices
- code changes
- none
- account
- none
- your data
- stays local
costcatch init██████╗ ██████╗ ███████╗████████╗ ██████╗ █████╗ ████████╗ ██████╗██╗ ██╗ ██╔════╝██╔═══██╗██╔════╝╚══██╔══╝██╔════╝██╔══██╗╚══██╔══╝██╔════╝██║ ██║ ██║ ██║ ██║███████╗ ██║ ██║ ███████║ ██║ ██║ ███████║ ██║ ██║ ██║╚════██║ ██║ ██║ ██╔══██║ ██║ ██║ ██╔══██║ ╚██████╗╚██████╔╝███████║ ██║ ╚██████╗██║ ██║ ██║ ╚██████╗██║ ██║ ╚═════╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ┌────────────────────────────────┬────── v0.2.0 ───────────────────────────────────────┐ │ │ │ │ About │ Commands │ │ Zero-instrumentation LLM │ run trace a script (default) │ │ agent tracer & cost tracker. │ estimate estimate prompt token cost │ │ Like `time`, for AI agents. │ show inspect conversation content │ │ │ diff compare two saved traces │ │ Features │ stats aggregated analytics │ │ · live trace in the terminal │ replay re-display a saved trace │ │ · per-call cost tracking │ watch run, always saved │ │ · prompt cost estimation │ clean prune old saved traces │ │ · auto-diff between runs │ init setup & fetch pricing │ │ · CI assertion gates │ │ │ · secret & PII redaction │ Quick Start │ │ │ $ costcatch python3 agent.py │ │ │ $ costcatch node agent.mjs │ │ │ │ └────────────────────────────────┴─────────────────────────────────────────────────────┘ - fetching latest model pricing… ┌──────────────────────────────────────────────────────────────────────────────────────────────┐ │ costcatch init │ │ │ │ + created .costcatch/ (~/oncall-agent/.costcatch) │ │ + added .costcatch/ to .gitignore │ │ + fetched latest pricing (5,831 models) │ │ │ │ ready · run `costcatch --help` to see all commands │ └──────────────────────────────────────────────────────────────────────────────────────────────┘
Most agent bugs don't crash. They cost you.
Your agent can finish and still waste money. costcatch checks every run for 15 kinds of problems and names the step.
Failed calls
Rate limits, server errors and dropped connections, with the provider's own message.
Tool loops
The same tool, called with the same arguments, three times or more.
Oversized tool results
One big result, paid for again in every call after it.
Cut-off answers
The model hit its token limit, so the answer is incomplete.
Retries
The same prompt sent again, often by your SDK, without telling you.
Lost tool results
Your program stopped before a tool's result got back to the model.
Works with the agent you already have.
costcatch reads the calls your agent sends over the network, below any SDK or framework. Nothing to import, wrap or configure.
Run it
costcatch python agent.pyPut costcatch in front of the command you already use. Your program, its flags and its output stay the same.
It watches the calls
A small hook inside your program copies each LLM request and response as it passes. It never changes them.
You get the trace
Every call is priced and checked for problems. You see it live while the agent runs, and in full when it ends.
- providers
- OpenAIAnthropicGeminiAzure OpenAIVertex AIOpenRouterGroqMistralCohereOllamaany OpenAI-compatible API
- libraries
- OpenAI SDKAnthropic SDKLangChainLiteLLMCrewAIrequestshttpxfetch
Find out why. Then prove the fix.
Save a run with --save. Then read what the model saw, compare two runs, or add them all up.
costcatch --save python research_agent.py┌──────────────────────────────────────────────────────────────────────────────────────────────┐ │ costcatch claude-sonnet-4-20250514 · 18.0s $0.08 │ │ │ │ + Step 1 2.1s 537 tok in → 96 tok out $0.00305 │ │ ├─ > read_file(path="logs/checkout.log") → ~7.2k tok │ │ └─ × get_ticket(id="INC-2041") │ │ failed: TicketAPIError: ticket INC-2041 not found │ │ │ │ + Step 2 3.3s 6,061 tok in → 38 tok out $0.02 │ │ └─ × get_ticket(id="INC-2041") │ │ failed: TicketAPIError: ticket INC-2041 not found │ │ ∆ context grew 11.3× (537 → 6,061 input tok) │ │ │ │ × Step 3 286ms HTTP 429 │ │ └─ rate_limit_error Number of request tokens has exceeded your per-minute rate limit │ │ │ │ + Step 4 3.0s 6,135 tok in → 41 tok out $0.02 │ │ →→ retry of step 3 │ │ └─ × get_ticket(id="INC-2041") │ │ failed: TicketAPIError: ticket INC-2041 not found │ │ │ │ ∆ Step 5 4.7s 6,210 tok in → 300 tok out $0.02 █████ │ │ ∆ output cut off (max_tokens): the answer is incomplete │ │ │ │ + Step 6 2.3s 6,373 tok in → 74 tok out $0.02 │ │ └─ > submit(summary="Payment worker ran out of DB connectio…) → no result │ │ │ │ ── summary │ │ 6 LLM calls · 5 tool calls · 18.0s · $0.08 │ │ × 1 failed LLM call · 3 failed tool calls │ │ 15.7s in LLM calls · 2.3s between calls (your code and tools) │ │ 1 repeated prompt │ │ 25k tok in → 549 tok out │ │ at 1 run/day = $2.53/mo · at 100 runs/day = $252.55/mo · at 1000 runs/day = $2,525.49/mo │ │ │ │ ── warnings │ │ ● Step 3 failed: HTTP 429 rate_limit_error: Number of request tokens has exceeded your per-… │ │ ● get_ticket() was called 3 times with the same arguments (steps 1, 2 and 4); all 3 failed:… │ │ ● Context grew 12× across calls (537 → 6,373 tokens) │ │ ● Step 6 asked for submit(); the program exited with code 1 before sending its result back … │ │ ● Step 5 was cut off (max_tokens): the answer is incomplete │ │ ● Step 1: read_file() returned ~7.2k tokens, 100% of step 2's prompt, sent 5 times │ │ ● Step 4 retried step 3 (which failed), same prompt re-sent │ │ ● Context grew 11.3× between steps 1 and 2 (537 → 6,061) │ │ run 2026-11-18T09-09-15 │ └──────────────────────────────────────────────────────────────────────────────────────────────┘ + Trace saved: ~/oncall-agent/.costcatch/2026-11-18T09-09-15-research_agent.json
Fail the build when your agent gets worse.
Run your agent's test under costcatch. The job fails when a run costs too much, makes too many calls, or hits errors.
- name: Agent test
run: npx costcatch --max-cost 0.05 --max-errors 0 python tests/agent_test.py| flag | fails when | checked |
|---|---|---|
--max-cost <usd> | the run cost more than this | at the end |
--max-calls <n> | it made more LLM calls than this | at the end |
--max-errors <n> | failed calls and failed tools add up to more than this | at the end |
--budget <usd> | spend passes this, so the program is stopped | while it runs |
costcatch --max-cost 0.05 --max-errors 0 python research_agent.py┌──────────────────────────────────────────────────────────────────────────────────────────────┐ │ × CI GATE: cost $0.08 exceeds --max-cost $0.05 │ └──────────────────────────────────────────────────────────────────────────────────────────────┘ ┌──────────────────────────────────────────────────────────────────────────────────────────────┐ │ × CI GATE: 4 errors (1 failed LLM call · 3 failed tool calls) exceeds --max-errors 0 │ └──────────────────────────────────────────────────────────────────────────────────────────────┘
Stop a runaway agent
--budget stopped this run after 4 of its 6 calls. The last two were never sent, so they were never billed.
costcatch --budget 0.03 python research_agent.py┌──────────────────────────────────────────────────────────────────────────────────────────────┐ │ × BUDGET: run stopped, spend passed --budget $0.03 │ └──────────────────────────────────────────────────────────────────────────────────────────────┘
--max-cost fails instead of passing.