Someone left Claude Code running overnight and woke up to a $6,000 bill. The thread under that story was full of people saying "me too". A multi-agent system once looped for eleven days and burned $47,000 before anyone noticed.
Here is the uncomfortable part: none of those agents crashed. They looped. An agent that is stuck does not throw an exception. It calls the model again, and again, and every call costs money. The provider dashboards that could have warned someone lag by days. Nothing was watching in real time, and nothing could say no.
So I built Agentic Ledger: a flight recorder for AI agents. This week it shipped two releases, and I want to walk through what they do and how.
The shape of the thing
Agentic Ledger is a transparent proxy. Your agent's LLM calls pass through it on the way to the provider, and the ledger records every one: the prompt, the reply, the tokens, the price, the latency, the tool calls. Zero code changes; you point a base URL at it.
pip install agentic-ledger
agenticledger start
export ANTHROPIC_BASE_URL=http://localhost:8000
That is the whole onboarding. It is local-first: the proxy, the database, and the dashboard all run on your machine, and your prompts never leave it. Your API keys pass through untouched; the ledger never stores them.
Because it sits on the wire, it can do things an SDK-based observability tool structurally cannot: it can refuse a call. More on that below.
0.10 "Everywhere, live"
The first release this week was about coverage and durability.
Every wire. The same capture now works across OpenAI, Anthropic, Azure OpenAI, local models (LM Studio, Ollama), gateways (OpenRouter, LiteLLM), and, the flagship, direct AWS Bedrock. Bedrock was the hard one: calls are SigV4-signed and streams arrive as AWS's binary event-stream format, not SSE. The ledger holds its own AWS credentials (standard chain only, never in config files), strips the caller's identity headers, re-signs each request itself, and decodes the binary stream to reconstruct tokens and cost. Claude Code in Bedrock mode and boto3 agents get recorded, priced, and kill-switched without knowing the ledger exists.
Loops that survive restarts. The ledger recognizes loops on its own: fresh-context iterations that share a system prompt get grouped into a "run" with a live tile, iteration bars, and a kill switch. In earlier versions, that recognition lived in memory, so a proxy restart orphaned every auto-detected loop, and worse, a stopped run's wall no longer matched the loop it was hung on. That state now lives in the database. Block a run, restart the proxy, and the next iteration still lands on the same tile, still refused.
Watch it live. Open any run and there is a feed called "Calls, as they happen". Every call lands there the moment the proxy captures it: time, iteration, model, tokens, latency, cost, and a verdict. Blocked calls are amber (refused on purpose), broken ones are red, and "ok" means exactly HTTP 200.
Name a loop with one word. For loops you run deliberately:
agenticledger run nightly-digest -- python agent.py
Your command runs unchanged. Its calls land on a tile named nightly-digest, and tomorrow's launch counts as iteration 2 of the same run. Add --project acme and the whole thing files itself.
0.11 "The bill, before the bill"
The second release goes after the $6,000 story directly.
A run's detail now reads its money live: spent so far, burning per hour, and a projection ("at this pace: $212 by 8:00 AM"). That projection is the thing provider dashboards cannot give you, because they are days behind and the ledger is zero seconds behind.
And then the part I care about most: the cost ceiling. Give any run a dollar amount, while it runs, from the dashboard:
- The moment the run's spend reaches the ceiling, the proxy refuses the next call. HTTP 402, amber in the feed, zero dollars.
- The agent keeps knocking; the knocks cost nothing. Raise or clear the ceiling and calls flow again.
- The ceiling lives in the database, so restarts cannot shake it, and it guards auto-detected loops the same as named ones.
- A webhook fires at 80% so you hear about it before the wall.
This only works because the ledger is inline. A dashboard can show you a runaway loop. Only something standing between the agent and the model can say no to it.
ReAct vs Ralph, settled by numbers
A side effect of recording everything: arguments about agent architecture become measurements. The compare view takes any two runs, a ReAct-style agent (one long conversation, tools in a thread) against a Ralph-style loop (fresh context every iteration), and puts them side by side: cost delta, token delta, wall-clock delta, flags raised, and a diff of exactly what each run was told.
In my demo pair, the Ralph loop cost 41% more and burned three times the output tokens (fresh context is not free), but finished in half the wall-clock with zero flags, while the ReAct agent got caught re-running the same failing test three times by the stuck-loop detector. "Did the new prompt help" is a number now, not a feeling.
There is a 4-minute video of all of this. [Link.]
When things go wrong on your machine
One more thing this week taught me: I broke my own dev setup repeatedly (a stale install in the wrong Python shadowing the real one on PATH, wheels compiled for the wrong architecture, a service quietly serving old code). Every one of those diagnoses became a product:
agenticledger doctor
It prints every install on your PATH and who shadows whom, probes each one with a real import (wrong-architecture wheels surface with their actual error), checks what the background service is serving, and ends each finding with the exact command that fixes it. My machine's worst day wrote its spec.
Try it, and help if you want to
pip install agentic-ledger
agenticledger start
The repo is open: github.com/ShekharBhardwaj/AgenticLedger. If it is useful, a star genuinely helps a small project get found.
If you want to contribute, there are good first issues waiting: pricing packs for new models, a docs page on loop flags, a small frontend task, and my favorite: send me a transcript of a stuck loop my detector misses. Every transcript makes the flag smarter for everyone.
Your agents are going to run overnight. Put them on the record.
Top comments (0)