01
overview
KNOW YOUR COST - for python and node agents

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.

DemoDocsGitHub
works with
Python, Node
providers
10, auto-detected
models priced
5,831 current prices
code changes
none
account
none
your data
stays local
captured outputfirst runexit 0
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                                           │
└──────────────────────────────────────────────────────────────────────────────────────────────┘
02
what it finds

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.

Step 3 failed: HTTP 429 rate_limit_error: Number of request tokens has exceeded your per-minute rate limit

Tool loops

The same tool, called with the same arguments, three times or more.

get_ticket() was called 3 times with the same arguments (steps 1, 2 and 4); all 3 failed: TicketAPIError: ticket INC-2041 not found

Oversized tool results

One big result, paid for again in every call after it.

Step 1: read_file() returned ~7.2k tokens, 100% of step 2's prompt, sent 5 times

Cut-off answers

The model hit its token limit, so the answer is incomplete.

Step 5 was cut off (max_tokens): the answer is incomplete

Retries

The same prompt sent again, often by your SDK, without telling you.

Step 4 retried step 3 (which failed), same prompt re-sent

Lost tool results

Your program stopped before a tool's result got back to the model.

Step 6 asked for submit(); the program exited with code 1 before sending its result back to the model

All 15 checks, and what each one means ↗

03
how it works

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.

01

Run it

costcatch python agent.py

Put costcatch in front of the command you already use. Your program, its flags and its output stay the same.

02

It watches the calls

A small hook inside your program copies each LLM request and response as it passes. It never changes them.

03

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
If costcatch fails, your agent doesn't. It only watches, so a problem inside costcatch means a missing trace, never a broken run. It never reads request headers, where your API keys live.

How interception works·Security·Limitations

04
commands

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.

~/oncall-agentcostcatch v0.2.0
Six calls and eight warnings, for $0.08. At 1,000 runs a day, this agent would cost $2,525 a month.
captured outputexit 1
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
05
ci

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.

.github/workflows/agent.ymlone step
- name: Agent test
  run: npx costcatch --max-cost 0.05 --max-errors 0 python tests/agent_test.py
flagfails whenchecked
--max-cost <usd>the run cost more than thisat the end
--max-calls <n>it made more LLM calls than thisat the end
--max-errors <n>failed calls and failed tools add up to more than thisat the end
--budget <usd>spend passes this, so the program is stoppedwhile it runs
captured outputlast linesexit 1
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.

captured outputlast linesexit 1
costcatch --budget 0.03 python research_agent.py
┌──────────────────────────────────────────────────────────────────────────────────────────────┐
│ × BUDGET: run stopped, spend passed --budget $0.03                                           │
└──────────────────────────────────────────────────────────────────────────────────────────────┘
A gate that can't be checked fails. If a model has no known price, --max-cost fails instead of passing.

More on CI, JSON output and exit codes ↗

get started
costcatch.

Install it once, then put it in front of any agent.

DocsGitHub
no code changesno accountnothing leaves your machineMIT licensed