<?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: Adebowale Jolaosho</title>
    <description>The latest articles on DEV Community by Adebowale Jolaosho (@billionaire664).</description>
    <link>https://dev.to/billionaire664</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%2F3973577%2Fa1768f30-42f1-4525-9ec6-7b089d0e89a5.jpeg</url>
      <title>DEV Community: Adebowale Jolaosho</title>
      <link>https://dev.to/billionaire664</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/billionaire664"/>
    <language>en</language>
    <item>
      <title>How I added hard spending limits to AI agents (and why logging isn't enough)</title>
      <dc:creator>Adebowale Jolaosho</dc:creator>
      <pubDate>Mon, 08 Jun 2026 23:15:49 +0000</pubDate>
      <link>https://dev.to/billionaire664/how-i-added-hard-spending-limits-to-ai-agents-and-why-logging-isnt-enough-4jle</link>
      <guid>https://dev.to/billionaire664/how-i-added-hard-spending-limits-to-ai-agents-and-why-logging-isnt-enough-4jle</guid>
      <description>&lt;p&gt;If you've built an AI agent that calls paid APIs, you've probably &lt;br&gt;
thought about cost control. Most solutions stop at logging — you &lt;br&gt;
can see what the agent spent after the fact, but nothing actually &lt;br&gt;
stops it mid-run.&lt;/p&gt;

&lt;p&gt;I wanted something harder: a policy that blocks the agent before &lt;br&gt;
the charge fires, not after.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem with callbacks and middleware
&lt;/h2&gt;

&lt;p&gt;LangChain callbacks, OpenAI traces, CrewAI logs — they're all &lt;br&gt;
observability tools. If an agent loops 200 times overnight, the &lt;br&gt;
log shows 200 entries in the morning. The money is already gone.&lt;/p&gt;

&lt;p&gt;Even interrupt-based approaches like HumanInTheLoopMiddleware &lt;br&gt;
require you to know upfront which tools are risky. In practice, &lt;br&gt;
agents acquire new tools over time and the interrupt list drifts.&lt;/p&gt;

&lt;h2&gt;
  
  
  The pattern that actually works
&lt;/h2&gt;

&lt;p&gt;Treat budget as a tool the agent calls before any paid operation:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
python
@function_tool
def check_spend(amount: float, category: str = None) -&amp;gt; str:
    """
    Check whether a planned spend is within budget.
    Returns 'approved' or 'denied: &amp;lt;reason&amp;gt;'.
    Never proceed after 'denied'.
    """
    # call your policy engine here
    ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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