<?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: Varad Khoriya</title>
    <description>The latest articles on DEV Community by Varad Khoriya (@vrd1710).</description>
    <link>https://dev.to/vrd1710</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3951978%2Feb6602c7-026f-44d9-9d3d-8d2124b9b675.jpg</url>
      <title>DEV Community: Varad Khoriya</title>
      <link>https://dev.to/vrd1710</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vrd1710"/>
    <language>en</language>
    <item>
      <title>How to Prevent OpenClaw, Hermes Agent, and NanoClaw from Burning Your API Budgets</title>
      <dc:creator>Varad Khoriya</dc:creator>
      <pubDate>Tue, 07 Jul 2026 13:23:43 +0000</pubDate>
      <link>https://dev.to/vrd1710/how-to-prevent-openclaw-hermes-agent-and-nanoclaw-from-burning-your-api-budgets-2p2b</link>
      <guid>https://dev.to/vrd1710/how-to-prevent-openclaw-hermes-agent-and-nanoclaw-from-burning-your-api-budgets-2p2b</guid>
      <description>&lt;p&gt;As of mid-2026, the landscape of AI agents has shifted. Developers are no longer just building simple scripts using raw libraries. Instead, the community has standardized around powerful, pre-built autonomous agents like &lt;strong&gt;OpenClaw&lt;/strong&gt; (formerly Moltbot/CLAWDIS), &lt;strong&gt;Hermes Agent&lt;/strong&gt; (by Nous Research), &lt;strong&gt;NanoClaw&lt;/strong&gt;, and NVIDIA's &lt;strong&gt;NemoClaw&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;While these frameworks provide incredible out-of-the-box autonomy, from writing code to managing local files, their persistent loops can easily run wild. A single logic bug or tool failure can cause a persistent Hermes Agent or OpenClaw deployment to execute thousands of parallel LLM calls, draining API budgets in minutes.&lt;/p&gt;

&lt;p&gt;In this guide, you will learn how to add &lt;strong&gt;Runtime Agent Governance&lt;/strong&gt; to your pre-built agent stack without modifying their core code.&lt;/p&gt;




&lt;h2&gt;
  
  
  Understanding the Mid-2026 Agent Security Stack
&lt;/h2&gt;

&lt;p&gt;To protect your host infrastructure and OpenAI/Anthropic keys, you must understand what vulnerabilities exist across these frameworks:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Agent Framework&lt;/th&gt;
&lt;th&gt;Main Use Case&lt;/th&gt;
&lt;th&gt;Primary Vulnerability&lt;/th&gt;
&lt;th&gt;Security Strategy&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;OpenClaw&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Local-first personal assistant&lt;/td&gt;
&lt;td&gt;Infinite tool-execution loops&lt;/td&gt;
&lt;td&gt;Intercept and throttle LLM traffic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Hermes Agent&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Persistent skill-building&lt;/td&gt;
&lt;td&gt;Recursive sub-agent spin-ups&lt;/td&gt;
&lt;td&gt;Session budget limits&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;NanoClaw&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Sandboxed minimal assistant&lt;/td&gt;
&lt;td&gt;Memory drift &amp;amp; budget leakage&lt;/td&gt;
&lt;td&gt;Out-of-process circuit breakers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;NemoClaw&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;NVIDIA OpenShell enterprise stack&lt;/td&gt;
&lt;td&gt;Upstream provider overdraw&lt;/td&gt;
&lt;td&gt;Fail-closed network gateway&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  The Solution: Out-of-Process Runtime Governance
&lt;/h2&gt;

&lt;p&gt;Instead of writing custom guardrails in Python or Node.js inside each agent's runtime, the standard approach is to use a network proxy. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Loopers&lt;/strong&gt; is a lightweight, open-source agent firewall written in Go. By routing your agent's API calls through Loopers, you can enforce OPA/Rego policies, track real-time budgets in Redis, and terminate connections instantly if a loop is detected.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step-by-Step Integration Guide
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Run the Loopers Proxy
&lt;/h3&gt;

&lt;p&gt;First, start the Loopers proxy on your network. The simplest way is via Docker Compose:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# docker-compose.yml&lt;/span&gt;
&lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;3.8'&lt;/span&gt;
&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;redis&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;redis:alpine&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;6379:6379"&lt;/span&gt;
  &lt;span class="na"&gt;loopers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ghcr.io/cursed-me/loopers:latest&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;8080:8080"&lt;/span&gt; &lt;span class="c1"&gt;# Proxy Endpoint&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;REDIS_ADDR=redis:6379&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;SERVER_PORT=8080&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Associate Agent Identity with Your Loopers Key
&lt;/h3&gt;

&lt;p&gt;Loopers keeps your agent's structural identity (like agent name, owner, and environment tags) completely isolated from the request payload. This metadata is bound to the Loopers API key when you register it in the proxy's keyring:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Register a new API key for OpenClaw with governance tags&lt;/span&gt;
loopers key create &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--name&lt;/span&gt; &lt;span class="s2"&gt;"openclaw-local"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--provider&lt;/span&gt; &lt;span class="s2"&gt;"openai"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--agent-name&lt;/span&gt; &lt;span class="s2"&gt;"claw-assistant"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--owner&lt;/span&gt; &lt;span class="s2"&gt;"engineering"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--tags&lt;/span&gt; &lt;span class="s2"&gt;"environment=development"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Route OpenClaw to the Governance Gateway
&lt;/h3&gt;

&lt;p&gt;OpenClaw relies on environment variables to target LLM providers. To redirect its traffic through Loopers, modify your &lt;code&gt;.env&lt;/code&gt; configuration file to use the proxy endpoint and your Loopers API key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# OpenClaw .env configuration
OPENAI_API_KEY=your_loopers_api_key

# Redirect the endpoint to the Loopers proxy
OPENAI_API_BASE=http://localhost:8080/v1

# Enable custom request headers for session tracking
LOOPERS_SESSION_ID=openclaw-session-123
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Route Hermes Agent (Nous Research)
&lt;/h3&gt;

&lt;p&gt;Hermes Agent maintains persistent memory and spawns sub-agents. You can govern its budget and session limits by configuring its base URL and injecting the required session headers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"agent"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"hermes-coder"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"provider"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"openai"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"openai"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"apiKey"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"your_loopers_api_key"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"baseURL"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"http://localhost:8080/v1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"defaultHeaders"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"X-Loopers-Session-ID"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"hermes-persistent-session-987"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"X-Loopers-Session-Budget"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"5.00"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. Apply Sandboxed Limits for NanoClaw and NemoClaw
&lt;/h3&gt;

&lt;p&gt;For sandboxed systems like NanoClaw and NVIDIA's NemoClaw (running inside NVIDIA OpenShell), configure the network namespace to block all direct outbound traffic to public LLM endpoints. &lt;/p&gt;

&lt;p&gt;Force the container to route traffic strictly through the Loopers gateway IP. This ensures a fail-closed posture: if the Loopers container stops, the agent cannot bypass security to make calls directly.&lt;/p&gt;




&lt;h2&gt;
  
  
  Enforcing a $2.00 Spending Limit (OPA/Rego Policy)
&lt;/h2&gt;

&lt;p&gt;Create an Open Policy Agent policy at &lt;code&gt;/etc/loopers/policies/limit.rego&lt;/code&gt;. Loopers will compile this locally and evaluate it on the critical path in less than a millisecond:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rego"&gt;&lt;code&gt;&lt;span class="ow"&gt;package&lt;/span&gt; &lt;span class="n"&gt;loopers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;policy&lt;/span&gt;

&lt;span class="ow"&gt;default&lt;/span&gt; &lt;span class="n"&gt;allow&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;

&lt;span class="c1"&gt;# Allow by default if no deny rules match&lt;/span&gt;
&lt;span class="n"&gt;allow&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;deny&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;# Deny requests if the current session spend exceeds $2.00&lt;/span&gt;
&lt;span class="n"&gt;deny&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;spend&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;2.00&lt;/span&gt;
    &lt;span class="n"&gt;msg&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;sprintf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Agent session budget exceeded. Limit is $2.00, current spend is $%f"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;spend&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If OpenClaw or Hermes Agent tries to query the LLM after reaching the limit, Loopers blocks the request and returns a &lt;code&gt;429 Too Many Requests&lt;/code&gt; response, preventing any further billing.&lt;/p&gt;




&lt;h2&gt;
  
  
  Frequently Asked Questions (FAQ)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is the difference between OpenClaw and NanoClaw?
&lt;/h3&gt;

&lt;p&gt;OpenClaw is a feature-rich, local-first assistant that integrates with messaging platforms and local tools. NanoClaw is a minimal, security-first fork designed to run agents inside strict sandboxes (like Apple containers or Docker) to protect the host filesystem.&lt;/p&gt;

&lt;h3&gt;
  
  
  How does Loopers detect loops in Hermes Agent?
&lt;/h3&gt;

&lt;p&gt;Loopers uses a lightweight bi-gram Jaccard similarity algorithm in Redis. If a Hermes Agent sends functionally identical prompts repeatedly (even with slight mutations or retries), Loopers detects the high-similarity pattern and trips the circuit breaker to drop the connection.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does routing traffic through a proxy add latency?
&lt;/h3&gt;

&lt;p&gt;Loopers is written in Go and uses optimized Redis Lua scripts for session checking. The local proxy overhead is sub-millisecond, which is negligible compared to the 1,000ms+ network and generation latency of LLM APIs.&lt;/p&gt;




&lt;h2&gt;
  
  
  Resources &amp;amp; Open-Source Links
&lt;/h2&gt;

&lt;p&gt;To get started with Loopers or read the source code:&lt;/p&gt;

&lt;p&gt;{&lt;a href="https://github.com/CURSED-ME/loopers-oss" rel="noopener noreferrer"&gt;github CURSED-ME/loopers-oss&lt;/a&gt;}&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Are you running persistent agents locally? How do you prevent budget overruns in your stack? Share your architecture in the comments below!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>openclaw</category>
      <category>devops</category>
      <category>go</category>
    </item>
    <item>
      <title>How to Stop LangChain Agents from Bankrupting Your API Budget</title>
      <dc:creator>Varad Khoriya</dc:creator>
      <pubDate>Mon, 29 Jun 2026 18:48:30 +0000</pubDate>
      <link>https://dev.to/vrd1710/how-to-stop-langchain-agents-from-bankrupting-your-api-budget-cmo</link>
      <guid>https://dev.to/vrd1710/how-to-stop-langchain-agents-from-bankrupting-your-api-budget-cmo</guid>
      <description>&lt;p&gt;In November 2025, an engineering team deployed a market research pipeline using four LangChain agents. Due to a logic failure, the "Analyzer" and "Verifier" agents got stuck in a recursive ping-pong loop. Because every individual API call was perfectly valid, the system appeared healthy on their dashboards.&lt;/p&gt;

&lt;p&gt;11 days later, they discovered a &lt;strong&gt;$47,000 API bill&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This is the hidden cost of building autonomous AI: &lt;strong&gt;infinite hallucination loops&lt;/strong&gt;. When an agent encounters an error or fails to reach a termination condition, it will ruthlessly retry, burning through tokens in milliseconds.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Built-in Controls Fail
&lt;/h2&gt;

&lt;p&gt;If you build with LangChain or LangGraph, you are likely relying on two things for cost control:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;max_iterations&lt;/code&gt;: An application-layer limit.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LangSmith&lt;/strong&gt;: An observability dashboard.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The problem with &lt;code&gt;max_iterations&lt;/code&gt; is that it requires every developer to perfectly hardcode it into every agent. Furthermore, iterations do not equal cost, a single iteration with massive context bloat can still cost a fortune.&lt;/p&gt;

&lt;p&gt;The problem with LangSmith (and all observability tools) is that they act as a witness, not a circuit breaker. By the time your dashboard alerts you that a spike occurred, the money is already gone.&lt;/p&gt;

&lt;p&gt;To safely deploy agents to production, you need &lt;strong&gt;Agent Runtime Governance&lt;/strong&gt;, a network-layer firewall that physically drops the HTTP request the exact millisecond a budget hits zero.&lt;/p&gt;

&lt;p&gt;Enter &lt;strong&gt;Loopers&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Loopers?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/CURSED-ME/loopers-oss" rel="noopener noreferrer"&gt;Loopers&lt;/a&gt; is an open-source, baremetal reverse proxy for AI agents. It sits on your critical path between LangChain and your LLM provider (OpenAI, Anthropic, etc.).&lt;/p&gt;

&lt;p&gt;It uses atomic Redis Lua scripts to reserve budget before the request is sent to the provider. If the agent exceeds its budget, Loopers fails closed and instantly severs the connection, guaranteeing zero budget leakage.&lt;/p&gt;

&lt;p&gt;Here is how to implement Loopers into your LangChain workflow in less than 5 minutes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Spin up the Loopers Firewall&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Loopers is incredibly lightweight (~40MB RAM) and runs via Docker. You can spin it up locally to test it out.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Clone the repository&lt;/span&gt;
git clone https://github.com/CURSED-ME/loopers-oss.git
&lt;span class="nb"&gt;cd &lt;/span&gt;loopers-oss

&lt;span class="c"&gt;# Start the proxy and Redis backend&lt;/span&gt;
docker-compose up &lt;span class="nt"&gt;-d&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Create a Proxy Key and Budget&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Instead of giving your agents your raw OpenAI key, you give them a Loopers Proxy Key (&lt;code&gt;lp-xxx&lt;/code&gt;). Loopers holds your real API key safely and injects it downstream.&lt;/p&gt;

&lt;p&gt;Generate an API proxy key for OpenAI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker-compose &lt;span class="nb"&gt;exec &lt;/span&gt;loopers /app/loopers keys create &lt;span class="nt"&gt;--name&lt;/span&gt; langchain-agent &lt;span class="nt"&gt;--provider&lt;/span&gt; openai
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;(Save the generated lp-xxx key and its hash).&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now, set a strict budget. Let's cap this agent at &lt;strong&gt;$2.00 per hour&lt;/strong&gt; and &lt;strong&gt;$10.00 per day&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker-compose &lt;span class="nb"&gt;exec &lt;/span&gt;loopers /app/loopers budget &lt;span class="nb"&gt;set&lt;/span&gt; &amp;lt;KEY_HASH&amp;gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--hourly&lt;/span&gt; 2.00 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--daily&lt;/span&gt; 10.00

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: LangChain Integration&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You have two ways to route your LangChain agents through Loopers:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Option A: Zero-SDK Integration (Generic)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you don't want to install any extra packages, you can use the standard LangChain &lt;code&gt;ChatOpenAI&lt;/code&gt; client by simply overriding the &lt;code&gt;base_url&lt;/code&gt; and passing headers using &lt;code&gt;default_headers&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;langchain_openai&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;ChatOpenAI&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain.agents&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;create_tool_calling_agent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;AgentExecutor&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;

&lt;span class="c1"&gt;# Initialize the LLM to route through the Loopers Proxy
&lt;/span&gt;&lt;span class="n"&gt;llm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ChatOpenAI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gpt-4o&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;base_url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;http://localhost:8080/openai/v1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# Route to Loopers
&lt;/span&gt;    &lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;lp-xxx&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;                           &lt;span class="c1"&gt;# Your Loopers Proxy Key
&lt;/span&gt;    &lt;span class="n"&gt;default_headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;X-Loopers-Provider-Key&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;OPENAI_API_KEY&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="c1"&gt;# Upstream key
&lt;/span&gt;        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;X-Loopers-Session-ID&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;market-research-task-123&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;         &lt;span class="c1"&gt;# For session tracking
&lt;/span&gt;    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Option B: Native SDK Wrapper (ChatLoopers)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For cleaner code, you can use the official &lt;code&gt;loopers-client&lt;/code&gt; Python SDK which exports a drop-in &lt;code&gt;ChatLoopers&lt;/code&gt; class. This automatically handles endpoints, auth, and wraps session constraints (budget, maximum steps) into Python arguments.&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;loopers-client
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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;loopers_client.integrations.langchain&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;ChatLoopers&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain.agents&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;create_tool_calling_agent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;AgentExecutor&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;

&lt;span class="c1"&gt;# Use ChatLoopers subclass directly
&lt;/span&gt;&lt;span class="n"&gt;llm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ChatLoopers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gpt-4o&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;loopers_url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;http://localhost:8080&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;loopers_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;lp-xxx&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;provider_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;OPENAI_API_KEY&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;session_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;market-research-task-123&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;session_budget&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;5.00&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;# Limits this specific run to $5.00
&lt;/span&gt;    &lt;span class="n"&gt;max_steps&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;          &lt;span class="c1"&gt;# Hard step-limit ceiling for the agent
&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Hooking it to your Agent
&lt;/h2&gt;

&lt;p&gt;Once initialized, pass your &lt;code&gt;llm&lt;/code&gt;(either Option A or B) into your standard LangChain executor:&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="c1"&gt;# Create and run your standard agent
&lt;/span&gt;&lt;span class="n"&gt;agent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;create_tool_calling_agent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;llm&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tools&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;agent_executor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;AgentExecutor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;agent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tools&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;tools&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Run the agent
&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;agent_executor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;invoke&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;input&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Analyze the latest market data.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How It Works in Production
&lt;/h2&gt;

&lt;p&gt;When &lt;code&gt;agent_executor.invoke()&lt;/code&gt; runs, LangChain attempts to communicate with OpenAI.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The HTTP request hits the Loopers proxy on &lt;code&gt;:8080&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Loopers executes an atomic Lua script in Redis to check if the session (&lt;code&gt;market-research-task-123&lt;/code&gt;) or the proxy key has exceeded the $2.00/hr budget.&lt;/li&gt;
&lt;li&gt;If it is under budget, the request is forwarded to OpenAI in ~1-2ms.&lt;/li&gt;
&lt;li&gt;If the budget is zero, Loopers instantly drops a steel door, returning an &lt;code&gt;HTTP 429 Too Many Requests&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;LangChain will catch the 429 error and halt the agent loop entirely, preventing any further financial loss.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Agent frameworks like LangChain are incredibly powerful, but relying on application-layer configurations like &lt;code&gt;max_iterations&lt;/code&gt; leaves your infrastructure vulnerable to human error and logic bugs.&lt;/p&gt;

&lt;p&gt;By shifting cost controls down to the network layer with a fail-closed firewall like Loopers, you can give your developers the freedom to build autonomous agents without terrifying your FinOps and Security teams.&lt;/p&gt;

&lt;p&gt;Check out the open-source project and give it a star on GitHub: &lt;a href="https://github.com/CURSED-ME/loopers-oss" rel="noopener noreferrer"&gt;github.com/CURSED-ME/loopers-oss&lt;/a&gt;&lt;/p&gt;

</description>
      <category>langchain</category>
      <category>ai</category>
      <category>programming</category>
      <category>architecture</category>
    </item>
    <item>
      <title>I got a $100 AI bill. Then I found the $80,000 ones. So I built a kill switch.(2026)</title>
      <dc:creator>Varad Khoriya</dc:creator>
      <pubDate>Tue, 26 May 2026 13:47:37 +0000</pubDate>
      <link>https://dev.to/vrd1710/i-got-a-100-ai-bill-then-i-found-the-80000-ones-so-i-built-a-kill-switch2026-4b7e</link>
      <guid>https://dev.to/vrd1710/i-got-a-100-ai-bill-then-i-found-the-80000-ones-so-i-built-a-kill-switch2026-4b7e</guid>
      <description>&lt;p&gt;A few weeks ago I woke up to a $100 charge from my AI provider.&lt;/p&gt;

&lt;p&gt;For a lot of people that's nothing. For me, a solo dev who obsessively keeps infrastructure costs near zero, it genuinely stung. But that wasn't even the part that got me.&lt;/p&gt;

&lt;p&gt;The part that got me was what I found when I went looking for answers.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Actual Problem
&lt;/h2&gt;

&lt;p&gt;Reddit threads. Developer forums. People waking up to $10,000. $30,000. $80,000 bills.&lt;/p&gt;

&lt;p&gt;Three root causes, over and over:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Leaked API keys&lt;/strong&gt; scraped from public GitHub repos&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Autonomous agents&lt;/strong&gt; stuck in retry loops, burning tokens all night&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Provider "budget alerts"&lt;/strong&gt; that notify you after the money is already gone&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That last one is what really broke my brain. The alerts are just dashboards with email attachments. They don't stop anything. You still get the bill.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Thing I Built
&lt;/h2&gt;

&lt;p&gt;I built &lt;a href="https://www.tryloopers.com/" rel="noopener noreferrer"&gt;Loopers&lt;/a&gt;- a reverse proxy that sits between your application and your LLM provider and enforces a hard dollar cap.&lt;/p&gt;

&lt;p&gt;Not a soft alert. &lt;strong&gt;A kill switch.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Your app talks to Loopers instead of OpenAI directly
curl http://localhost:8080/openai/v1/chat/completions \
  -H "Authorization: Bearer lp-your-key" \
  -H "X-Loopers-Provider-Key: sk-your-openai-key" \
  -d '{"model": "gpt-4o-mini", "messages": [...]}'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If your budget is hit, the request dies right there. The provider is never called. No tokens burned. No bill.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Interesting Engineering Bit
&lt;/h2&gt;

&lt;p&gt;The hard part isn't blocking pre-call requests. That's easy. The hard part is streaming.&lt;/p&gt;

&lt;p&gt;With SSE streaming, the provider is already sending you tokens by the time you realize cost is climbing. So Loopers intercepts the stream in real-time, counts tokens chunk-by-chunk, and severs the connection the moment cost crosses the reservation.&lt;/p&gt;

&lt;p&gt;And when a client disconnects mid-generation (dropped connection, timeout, whatever), Loopers captures the exact token count generated up to that millisecond and refunds the remainder of the reservation back to Redis. No phantom charges.&lt;/p&gt;

&lt;p&gt;The budget enforcement itself runs through Redis Lua scripts- single atomic transaction, no TOCTOU race conditions, even under heavy concurrent load.&lt;/p&gt;

&lt;h2&gt;
  
  
  What It Supports
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;6 providers:&lt;/strong&gt; OpenAI, Anthropic, Gemini, AWS Bedrock, Azure OpenAI, Mistral&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;5 budget windows:&lt;/strong&gt; per-minute, hourly, daily, weekly, monthly - first limit hit wins&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Session budgets:&lt;/strong&gt; cap an entire agent run across N steps&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fail-closed:&lt;/strong&gt; if Redis goes down, all requests are blocked. Your wallet is safe.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MIT-licensed&lt;/strong&gt;, self-hosted, Docker Compose&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I'm Still Figuring Out
&lt;/h2&gt;

&lt;p&gt;The concurrent Lua atomicity holds up in tests (100 goroutines, same key), but I'd genuinely love a second pair of eyes on the scripts from anyone who's done serious Redis work.&lt;/p&gt;

&lt;p&gt;And the streaming reconciliation pattern, I'm curious if others have solved mid-stream token accounting differently.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try It / Rip It Apart
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;go run github.com/loopers-oss/loopers/cmd/loopers init
docker-compose up -d

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;→ &lt;a href="//github.com/CURSED-ME/loopers-oss"&gt;github.com/CURSED-ME/loopers-oss&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is my first major Go project. I'd love brutal, honest feedback on the architecture, the code, the README clarity, anything. Drop it in the comments.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The core is fully MIT. I'm building a managed cloud version to fund continued OSS work but nothing is held back from the community repo.&lt;/em&gt;&lt;/p&gt;

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