cd /news/ai-agents/my-hermes-agent-spent-3-before-i-not… · home topics ai-agents article
[ARTICLE · art-13864] src=dev.to pub= topic=ai-agents verified=true sentiment=· neutral

My Hermes agent spent $3 before I noticed. Now it can't.

A developer accidentally spent $3 on a Hermes research agent running across 50 literature review tasks after forgetting to check the bill until the next morning, with the agent retrying failed web searches at a cost each time. The fix is `agent-cost-guard`, a Python library that tracks costs as they accumulate and stops execution when a user-defined limit is hit. The tool also supports warning callbacks at configurable thresholds and per-label cost breakdowns for logging or blocking modes.

read1 min publishedMay 25, 2026

This is a submission for the Hermes Agent Challenge.

I ran a Hermes research agent across 50 literature review tasks and forgot to check the bill until the next morning. Three dollars gone. The agent had retried a bunch of failed web searches and each retry cost money.

The fix is obvious in hindsight: track cost as you go and stop when you hit the limit. That's agent-cost-guard

.

from agent_cost_guard import CostGuard

guard = CostGuard(limit_usd=1.00)

response = client.messages.create(model="claude-sonnet-4-5", ...)
cost = calculate_cost(response.usage)
guard.add(cost, label="research_turn")  # raises CostLimitExceeded if over $1
python
def on_warn(w):
    log.warning(f"Cost at {w.pct_used:.0%} — ${w.total_usd:.4f} of ${w.limit_usd:.4f}")

guard = CostGuard(
    limit_usd=1.00,
    warn_at=[0.5, 0.8],
    on_warn=on_warn,
)

The callback fires once per threshold and never again unless you call guard.reset()

.

guard.add(0.05, label="web_search")
guard.add(0.12, label="llm_synthesis")
guard.add(0.03, label="web_search")

s = guard.summary()
print(s.by_label)

Now you know where the money went.

guard = CostGuard(limit_usd=0.50, stop_on_limit=False)
guard.add(1.00)  # no exception
print(guard.ok)         # False
print(guard.remaining_usd)  # -0.50

Useful for logging-only mode when you want to measure but not block.

guard.check()  # raises CostLimitExceeded if total > limit

Call it at checkpoints rather than after every single add.

s = guard.summary()
print(str(s))
python
from agent_cost_guard import make_cost_guard

guard = make_cost_guard(limit_usd=1.00, on_warn=on_warn)

Standard library only: dataclasses

, time

. Nothing else.

pip install agent-cost-guard
── more in #ai-agents 4 stories · sorted by recency
── more on @hermes 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/my-hermes-agent-spen…] indexed:0 read:1min 2026-05-25 ·