Two Pricing Bugs, One Very Useful Fix: Accurate Cost Tracking for Hermes
- hermes
- cost-tracking
- token-logger
- pricing
- observability
I track what Hermes Agent costs by matching its log files against a live pricing cache. On 2026-10-04 the log held 970 calls. The total came to $0.2527.
The real total was $0.5852, so I was missing 57% of my own cost. Worth saying plainly: I caught this a few weeks into building the plugin, not after a year of bad numbers. The bugs were small, both were found by the same kind of check, and fixing them is most of what makes the plugin worth running today.
They also both had the same property, which is the actual lesson. Neither threw an error. Both gave me numbers that looked real.
Looking at all those zeros
When 915 out of 970 calls show $0, most of them are probably correct. Some models are free. Some run on my own computer. A tool that says $0 for a free model is working the way it should.
So before I changed anything, I sorted the zeros by provider and model:
| Provider | Model | Zero rows | Verdict |
|---|---|---|---|
custom:openrouter |
stealth/space-bunny-alpha |
410/410 | Genuinely free |
openrouter |
stealth/space-bunny-alpha |
225/225 | Genuinely free |
lmstudio |
frognano-4b-2609@q4_k_s |
220/220 | Local inference |
custom:openrouter |
mistralai/mistral-large-2512 |
60/60 | Fixable - $0.50/M in, $1.50/M out |
| All | - | 855 / 915 | Correct at zero |
855 of those zeros were right. 60 were a bug. Sorting by provider is what separated them, and it took about a minute.
Here's the part that pointed straight at the fix. The price I needed for those 60 rows was already sitting in the cache. I called the lookup function by hand with ("custom:openrouter", "mistralai/mistral-large-2512") and it gave me a price right away: $0.50/M. The lookup worked, and the data was current.
That narrowed it to the gap between two steps: "the cache has the price" and "the row in the CSV gets the price." Each of the next two bugs turned out to sit exactly there.
Bug one: the prefix it never stripped
Hermes can send a provider through a custom gateway. When you do that, the config saves the provider name as custom:<name>. So a call that should show up as OpenRouter gets logged as custom:openrouter.
The pricing cache uses plain provider names. When the tool looked for custom:openrouter, there was no key with that name. It returned nothing, and the code read that nothing as "no price for this one" and wrote $0.
The fix is to cut off the prefix and try again:
if provider.startswith("custom:"):
provider = provider.split(":", 1)[1]
This one mattered more than the dollar amount suggests, because it was breaking cost tracking on live calls, not just on the old logs I was fixing. Every routed call was hitting $0 at the moment it ran.
It was also the more interesting one to track down. The plugin reported everything healthy throughout. _find_rate worked perfectly when called with the right name. What was missing was a check that the name the logger passed in matched the name the cache had saved, and one small assertion covers it now.
Bug two: it couldn't see today's file
The job that adds prices looked for *.csv.gz files in the log folder.
The logger writes a plain .csv file for the current day, and only compresses that file later when it archives the day. So the file the job was looking for did not exist yet. It showed up the next day, by which point the job had already moved on.
Same-day rows were not occasionally missed. They were unreachable, every day, until the file rolled over.
# before - matches only the archived form
files = sorted(log_dir.glob("*.csv.gz"))
# after - matches both
files = sorted(log_dir.glob("*.csv*.gz")) + sorted(log_dir.glob("*.csv"))
Saving the results needed care too. Writing a plain .csv back as gzipped means the nightly archiver will not find the file it expects, so the new code keeps whichever format it read.
What the fix was worth
On 2026-10-04, 60 rows went from $0 to real prices. The day total went from $0.2527 to $0.5852.
The better way to read that is not "my costs doubled." It is "the old number was too low." Anyone who saw the old number would have thought that was a cheap day.
The same problem behind both
Both bugs worked the same way. The lookup returned nothing, and nothing looked the same as a real answer. The plugin could not tell "this provider has no price" apart from "I used the wrong name," so it called both of them zero.
That is the part I would keep even if the numbers were perfect. A cost tool that drops to zero when it gets confused is worse than no cost tool, because a zero still looks like data. If your cost suddenly drops and you did not change what you ran, check whether it dropped to exactly zero. A real drop goes to a smaller number. Zeros are where failed lookups hide.
The counter that would have caught both on the first run is a row count with no price, split out by reason. Today the plugin says "220 rows have no matching rate in cache" as one number, and all 220 are local models that genuinely have no rate. Had that number been 280, I would have seen it immediately. It is on the list.
Where the plugin stands
hermes-model-pricing v1.2.0 is where this landed. The two fixes above are the small part. The larger part is how much better the coverage got:
| Provider | Source | Models cached | Status |
|---|---|---|---|
| OpenRouter | /api/v1/models |
466 | Live pricing |
| Nous Portal | /v1/models |
410 | New in v1.2.0, no API key |
| NVIDIA NIM | /api/v1/models |
81 | IDs only, no rates yet |
| Together AI | /api/v1/models |
23 | Live pricing |
| Fireworks | docs HTML | 16 | Live pricing |
| Cohere | Static table | 5 | Fallback rates |
| Mistral | Static table | 4 | Fallback rates |
| MiniMax | Static table | 3 | Fallback rates |
| DeepSeek | docs scrape | 2 | Live pricing |
Roughly 1,010 models across ten providers, none of which needs an API key.
The Nous Portal is the one worth calling out. It needed no key, needed no scraping, and returned clean per-token costs including separate cache-read and cache-write rates. It carries first-party prices for Anthropic, OpenAI, DeepSeek, Qwen and GLM, often below the same model's OpenRouter rate, plus :batch and -latest aliases the other sources do not list. Adding one clean source was worth more than the several HTML scrapers it sits next to.
Three other fixes shipped alongside. Scaled prices no longer land as float noise, so 0.0000002 × 1e6 writes 0.2 instead of 0.19999999999999998. The provider list existed in three divergent copies, one of which was missing four providers from /models; there is now a single PROVIDERS tuple with the slash-command hints derived from it. And the Groq scraper and DeepSeek promo sections, which had both gone quietly stale, are now a single Known Gaps table with an impact column instead of a note about a promo that expired in May.
The README keeps that gaps table honest rather than omitting it. cache_write_cost is captured but not yet used in the cost math, so runs leaning hard on cache writes read a little low. Groq figures are unverified since their pricing page changed. NVIDIA NIM returns model names with no prices attached, so anything routed through it still records $0, which is the same failure shape as bug one from a different cause. Each one names what to trust and what not to, which is more useful than a clean-looking table that quietly rounds to zero.