By **Benni Alencar* — Chief AI Systems Architect at Benni OS. Canonical article & interactive benchmarks at benni-os.net.*
Why Soft Prompt Caps Fail Under Retry Spirals
Telling an autonomous coding agent "be concise and stay within budget" inside CLAUDE.md fails the moment a test suite enters an infinite fix-fail loop. Each retry re-sends the growing conversation history, turning a $2 task into a $500+ API bill overnight.
Benni-OS/claude-code-finops solves this outside the prompt layer with a zero-dependency Python gate bound to PreToolUse and PostToolUse.
How the FinOps Circuit Breaker Works
-
Real-Time Token & USD Accounting:
PostToolUselogs model usage (claude-opus-4,claude-sonnet-4,claude-haiku-4) into an append-only SHA-256 chained ledger (.claude/finops/finops_ledger.jsonl). -
Hard Dollar Ceiling: Before any tool executes,
PreToolUsechecks cumulative spend against--cap-usd. Once reached, exit code2blocks execution deterministically. -
Identical-Call Loop Detection: Each tool call is hashed into a signature. If the agent repeats the exact same failing call
Ntimes consecutively, the breaker halts the spiral immediately.
git clone https://github.com/Benni-OS/claude-code-finops.git
cd claude-code-finops
pip install -e .
python -m unittest discover -s tests -p "test_*.py" -v
Production Shortcut: Need pre-built enterprise security rules alongside FinOps caps? Grab the Sovereign Policy & Red-Team Pro Pack ($49) or book a 48h team security & FinOps audit via bennialencar@benni-os.net.
Launch the Benni Master OS v10 Sandbox
Verify 38 canonical skills, 8 deterministic packs, and Reality Lock invariants live in your browser, or contact bennialencar@gmail.com for B2B pilots.
Frequently Asked Questions
Does claude-code-finops require external databases or cloud proxies?
No. It runs on pure Python standard library with an append-only SHA-256 chained JSONL ledger in under 1 millisecond.
Can teams combine claude-code-finops with security guardrails?
Yes. You can pair it with Benni-OS/claude-code-sovereign or drop in the Sovereign Policy & Red-Team Pro Pack for OWASP LLM and infrastructure protection.
Frequently Asked Questions
Does claude-code-finops require external databases or cloud proxies?
No. It runs on pure Python standard library with an append-only SHA-256 chained JSONL ledger in under 1 millisecond.
Can teams combine claude-code-finops with security guardrails?
Yes. You can pair it with Benni-OS/claude-code-sovereign or drop in the Sovereign Policy & Red-Team Pro Pack for OWASP LLM and infrastructure protection.
Production Packs, B2B Pilots & Open-Source Lab Support
All core tooling in the Benni-OS Claude Code suite remains 100% open source (MIT). To fund ongoing GPU benchmarks and keep these tools free for the community, we offer:
- Live Reality Lock Sandbox (Free): Test deterministic verification invariants across 8 engineering packs at benni-master-os.bennialencar.workers.dev.
- Sovereign Policy & Red-Team Pro Pack ($49): Drop-in PreToolUse guardrails & OWASP LLM probes at bennie6.gumroad.com/l/monxqo.
-
Production Hardening & Custom Domain Packs (B2B): Enterprise policy packs, CI/CD Reality Lock gates, and 30-minute pilot reviews via
bennialencar@benni-os.net(Architecture Portfolio & Services). -
Sponsor the Open-Source Research Lab: Found this architecture useful in production? Support reproducible benchmarks and new MIT releases via PayPal (
alencaroyale@gmail.com) or star/follow on GitHub Benni-OS & BenniAlencar.
Top comments (0)