<?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: Arie Radle</title>
    <description>The latest articles on DEV Community by Arie Radle (@arie_radle).</description>
    <link>https://dev.to/arie_radle</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%2F3829509%2F921d8c11-3c13-43b0-bd61-4e3d99285ac6.png</url>
      <title>DEV Community: Arie Radle</title>
      <link>https://dev.to/arie_radle</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/arie_radle"/>
    <language>en</language>
    <item>
      <title>How a runaway AI agent cost me $47 while I slept (and how I fixed it)</title>
      <dc:creator>Arie Radle</dc:creator>
      <pubDate>Tue, 17 Mar 2026 13:50:00 +0000</pubDate>
      <link>https://dev.to/arie_radle/how-a-runaway-ai-agent-cost-me-47-while-i-slept-and-how-i-fixed-it-2cl6</link>
      <guid>https://dev.to/arie_radle/how-a-runaway-ai-agent-cost-me-47-while-i-slept-and-how-i-fixed-it-2cl6</guid>
      <description>&lt;p&gt;Have you ever woken up to a massive API bill because your AI agent got stuck in a loop? I have.&lt;/p&gt;

&lt;p&gt;Recently, I spent &lt;strong&gt;$47&lt;/strong&gt; debugging a LangGraph retry loop. The agent kept failing, LangGraph kept retrying, and OpenAI kept charging me—all while I was fast asleep. &lt;/p&gt;

&lt;p&gt;I realized we need better guardrails for AI agents. So, I built &lt;a href="https://arieradle.github.io/shekel/latest/" rel="noopener noreferrer"&gt;Shekel&lt;/a&gt; so you don't have to learn that expensive lesson yourself.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Shekel? 🪙
&lt;/h3&gt;

&lt;p&gt;Shekel is a zero-config, open-source Python library for LLM budget enforcement and cost tracking. It works with LangGraph, CrewAI, AutoGen, or any framework that calls OpenAI, Anthropic, or LiteLLM.&lt;/p&gt;

&lt;p&gt;The best part? It takes exactly &lt;strong&gt;one line of code&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  How it works
&lt;/h3&gt;

&lt;p&gt;You wrap your agent execution in a budget context manager. If your agent hits the max USD spend, it stops the execution by raising a &lt;code&gt;BudgetExceededError&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;shekel&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;budget&lt;/span&gt;

&lt;span class="c1"&gt;# Enforce a hard cap of $1.00
&lt;/span&gt;&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;budget&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_usd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;1.00&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="nf"&gt;run_my_agent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;# raises BudgetExceededError if spend exceeds $1.00
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Don't want to change your code? You can enforce it right from the CLI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;shekel run agent.py &lt;span class="nt"&gt;--budget&lt;/span&gt; 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Cool Features 🚀
&lt;/h3&gt;

&lt;p&gt;Beyond basic hard caps, I built Shekel to handle real-world agentic workflows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Smart Fallback:&lt;/strong&gt; Automatically switch to cheaper models (like &lt;code&gt;gpt-4o-mini&lt;/code&gt;) instead of crashing when you hit 80% of your budget.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Nested Budgets:&lt;/strong&gt; Track multi-stage workflows hierarchically (e.g., $2 for research, $5 for analysis).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tool Budgets:&lt;/strong&gt; Cap the number of tool calls before they bankrupt you.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;OpenTelemetry &amp;amp; Langfuse:&lt;/strong&gt; Export cost, utilization, and spend rates directly to your observability backend.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Try it out!
&lt;/h3&gt;

&lt;p&gt;You can install it via pip:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;shekel
&lt;span class="c"&gt;# or [anthropic], [litellm], [all]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check out the &lt;a href="https://github.com/arieradle/shekel" rel="noopener noreferrer"&gt;GitHub repository&lt;/a&gt; (I'd love a star if you find it useful!) or read the full &lt;a href="https://arieradle.github.io/shekel/latest/" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I'd love to hear your thoughts:&lt;/strong&gt; What's your worst "accidental cloud bill" story? Let me know in the comments! 👇&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>llm</category>
      <category>opensource</category>
      <category>ai</category>
    </item>
  </channel>
</rss>
