惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Apple Machine Learning Research
Apple Machine Learning Research
M
MIT News - Artificial intelligence
罗磊的独立博客
博客园 - 【当耐特】
A
About on SuperTechFans
Last Week in AI
Last Week in AI
雷峰网
雷峰网
IT之家
IT之家
aimingoo的专栏
aimingoo的专栏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园_首页
博客园 - 叶小钗
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - Franky
J
Java Code Geeks
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
D
Docker
Engineering at Meta
Engineering at Meta
B
Blog RSS Feed
The Cloudflare Blog
大猫的无限游戏
大猫的无限游戏
阮一峰的网络日志
阮一峰的网络日志
S
SegmentFault 最新的问题
Recent Announcements
Recent Announcements

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
I built a kill switch for runaway AI agents — Cost Firewa...
sun evan · 2026-05-13 · via DEV Community

sun evan

The 3 AM incident

A few months ago one of my AI agents got stuck in a retry loop overnight and quietly burned through a month of credits. The provider dashboard told me about it the next morning. The support ticket got a polite "usage is final."

Provider dashboards are bills. I needed a brake.

What's actually missing in the stack

After looking at what exists, the gap was clear:

  • AI gateways (LiteLLM, Portkey) — great at routing, not designed to stop you.
  • Observability (Helicone, Langfuse) — great at explaining, after the fact.
  • Provider dashboards — billing history, not real-time control.

Nothing was sitting between "the agent is making a call" and "the agent has already burned $500."

Cost Firewall

Cost Firewall is a local plugin for the OpenClaw gateway. It watches call metadata in real time and trips on four signals:

Failure mode Default threshold Action
Retry loop 3 consecutive failures from same source Trip + cooldown
Token storm 100K tokens / 60s Global block
Call flood 30 calls / 60s Global block
Daily budget cap Your configured ceiling Block until next day
Manual panic openclaw firewall stop Pause every AI call

Sources are tracked independently — one noisy agent doesn't take everyone else down.

Two-mode workflow

This is the part I think matters more than the rules themselves:

openclaw firewall mode observe     # record only, do not block
openclaw firewall log --last 20    # see what would have been blocked
openclaw firewall mode protect     # flip the switch

Enter fullscreen mode Exit fullscreen mode

Run observe for a day. The log alone is usually eye-opening — you'll find retry loops you didn't know existed and prompts using more tokens than you assumed. Then tune thresholds to your traffic, not someone else's blog post, and flip to protect.

Privacy posture

Question Answer
Does it need an account? No
Does it phone home? No
Does it store prompt text by default? No
Where do events live? Local JSONL on your gateway
Can I audit it? Yes, MIT TypeScript

The default is storePromptText: false. Runtime cost control belongs on the machine running the agent.

One-line install

curl -fsSL https://raw.githubusercontent.com/mapick-ai/cost-firewall/v0.2.12/install.sh | bash
openclaw firewall mode observe
openclaw firewall log --last 20

Enter fullscreen mode Exit fullscreen mode

Then a local dashboard at http://localhost:18789/mapick/dashboard.

Where it doesn't fit

I want to be explicit: it's not a gateway, not an observability platform, not a billing system. The shortest positioning I can give you:

Gateways route. Dashboards explain. Cost Firewall brakes.

Use it alongside LiteLLM / Helicone / your provider dashboard. It's the brake pedal that was missing between them.

Repo: https://github.com/mapick-ai/cost-firewall

⭐ if this saves you a billing screenshot. Issues and PRs welcome.