<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: sun evan</title>
    <description>The latest articles on DEV Community by sun evan (@sun_evan_49aa6e9c40815761).</description>
    <link>https://dev.to/sun_evan_49aa6e9c40815761</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3928248%2F180471fd-6dc6-4c6c-8c80-56fb053e1f01.png</url>
      <title>DEV Community: sun evan</title>
      <link>https://dev.to/sun_evan_49aa6e9c40815761</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sun_evan_49aa6e9c40815761"/>
    <language>en</language>
    <item>
      <title>I built a kill switch for runaway AI agents — Cost Firewall is MIT</title>
      <dc:creator>sun evan</dc:creator>
      <pubDate>Wed, 13 May 2026 02:06:50 +0000</pubDate>
      <link>https://dev.to/sun_evan_49aa6e9c40815761/i-built-a-kill-switch-for-runaway-ai-agents-cost-firewall-is-mit-2h8a</link>
      <guid>https://dev.to/sun_evan_49aa6e9c40815761/i-built-a-kill-switch-for-runaway-ai-agents-cost-firewall-is-mit-2h8a</guid>
      <description>&lt;h2&gt;
  
  
  The 3 AM incident
&lt;/h2&gt;

&lt;p&gt;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."&lt;/p&gt;

&lt;p&gt;Provider dashboards are bills. I needed a brake.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's actually missing in the stack
&lt;/h2&gt;

&lt;p&gt;After looking at what exists, the gap was clear:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;AI gateways&lt;/strong&gt; (LiteLLM, Portkey) — great at routing, not designed to stop you.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Observability&lt;/strong&gt; (Helicone, Langfuse) — great at explaining, after the fact.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Provider dashboards&lt;/strong&gt; — billing history, not real-time control.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Nothing was sitting between "the agent is making a call" and "the agent has already burned $500."&lt;/p&gt;

&lt;h2&gt;
  
  
  Cost Firewall
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/mapick-ai/cost-firewall" rel="noopener noreferrer"&gt;Cost Firewall&lt;/a&gt; is a local plugin for the OpenClaw gateway. It watches call metadata in real time and trips on four signals:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Failure mode&lt;/th&gt;
&lt;th&gt;Default threshold&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Retry loop&lt;/td&gt;
&lt;td&gt;3 consecutive failures from same source&lt;/td&gt;
&lt;td&gt;Trip + cooldown&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Token storm&lt;/td&gt;
&lt;td&gt;100K tokens / 60s&lt;/td&gt;
&lt;td&gt;Global block&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Call flood&lt;/td&gt;
&lt;td&gt;30 calls / 60s&lt;/td&gt;
&lt;td&gt;Global block&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Daily budget cap&lt;/td&gt;
&lt;td&gt;Your configured ceiling&lt;/td&gt;
&lt;td&gt;Block until next day&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Manual panic&lt;/td&gt;
&lt;td&gt;&lt;code&gt;openclaw firewall stop&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Pause every AI call&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Sources are tracked independently — one noisy agent doesn't take everyone else down.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two-mode workflow
&lt;/h2&gt;

&lt;p&gt;This is the part I think matters more than the rules themselves:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;openclaw firewall mode observe     &lt;span class="c"&gt;# record only, do not block&lt;/span&gt;
openclaw firewall log &lt;span class="nt"&gt;--last&lt;/span&gt; 20    &lt;span class="c"&gt;# see what would have been blocked&lt;/span&gt;
openclaw firewall mode protect     &lt;span class="c"&gt;# flip the switch&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;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 &lt;em&gt;your&lt;/em&gt; traffic, not someone else's blog post, and flip to protect.&lt;/p&gt;

&lt;h2&gt;
  
  
  Privacy posture
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Question&lt;/th&gt;
&lt;th&gt;Answer&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Does it need an account?&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Does it phone home?&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Does it store prompt text by default?&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Where do events live?&lt;/td&gt;
&lt;td&gt;Local JSONL on your gateway&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Can I audit it?&lt;/td&gt;
&lt;td&gt;Yes, MIT TypeScript&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The default is &lt;code&gt;storePromptText: false&lt;/code&gt;. Runtime cost control belongs on the machine running the agent.&lt;/p&gt;

&lt;h2&gt;
  
  
  One-line install
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://raw.githubusercontent.com/mapick-ai/cost-firewall/v0.2.12/install.sh | bash
openclaw firewall mode observe
openclaw firewall log &lt;span class="nt"&gt;--last&lt;/span&gt; 20
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then a local dashboard at &lt;code&gt;http://localhost:18789/mapick/dashboard&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where it doesn't fit
&lt;/h2&gt;

&lt;p&gt;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:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Gateways route. Dashboards explain. Cost Firewall brakes.&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;p&gt;Repo: &lt;a href="https://github.com/mapick-ai/cost-firewall" rel="noopener noreferrer"&gt;https://github.com/mapick-ai/cost-firewall&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;⭐ if this saves you a billing screenshot. Issues and PRs welcome.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>opensource</category>
      <category>agents</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
