<?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: uuu</title>
    <description>The latest articles on DEV Community by uuu (@ut181749ut).</description>
    <link>https://dev.to/ut181749ut</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%2F4233192%2Fe3ecc6cb-ecf7-48eb-a6c5-8b26bf0a3941.png</url>
      <title>DEV Community: uuu</title>
      <link>https://dev.to/ut181749ut</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ut181749ut"/>
    <language>en</language>
    <item>
      <title>How to put a hard daily spending cap on Claude Code</title>
      <dc:creator>uuu</dc:creator>
      <pubDate>Thu, 19 Nov 2026 10:59:00 +0000</pubDate>
      <link>https://dev.to/ut181749ut/how-to-put-a-hard-daily-spending-cap-on-claude-code-3ihk</link>
      <guid>https://dev.to/ut181749ut/how-to-put-a-hard-daily-spending-cap-on-claude-code-3ihk</guid>
      <description>&lt;p&gt;If you run Claude Code (or any agent) with an API key, there's nothing on your machine that stops it from spending. A loop at 2am will happily keep going until you wake up.&lt;/p&gt;

&lt;p&gt;Here's how I cap it per day, so the worst case is "it stopped at $7" instead of "check the invoice".&lt;/p&gt;

&lt;h2&gt;
  
  
  What the providers give you
&lt;/h2&gt;

&lt;p&gt;Worth setting these first, they're free:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Anthropic Console&lt;/strong&gt;: a monthly spend limit per workspace. It's monthly, not daily, and it can take a bit to kick in, so people have gone past it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;OpenAI&lt;/strong&gt;: hard spend limits per organization or project. Same idea, also not instant.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Turn off auto-reload&lt;/strong&gt; on any account an agent can reach.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The gap is that these are monthly and per workspace. One bad night can use the whole month, and every agent on that workspace shares the same pool.&lt;/p&gt;

&lt;h2&gt;
  
  
  A daily cap per agent
&lt;/h2&gt;

&lt;p&gt;The trick is to never give the agent the real key. The agent talks to a small proxy with its own key, the proxy holds the real one and checks the budget before every call.&lt;/p&gt;

&lt;p&gt;I use &lt;a href="https://github.com/ut181749ut/saifuban" rel="noopener noreferrer"&gt;Saifuban&lt;/a&gt; for this (I made it, it's open source).&lt;/p&gt;

&lt;h3&gt;
  
  
  In Claude Code it's two lines
&lt;/h3&gt;

&lt;p&gt;Send these one at a time inside Claude Code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;/plugin install saifuban --marketplace ut181749ut/saifuban
/saifuban:setup
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It finds the key you already have (&lt;code&gt;ANTHROPIC_API_KEY&lt;/code&gt; etc.), asks if it's ok to cap it at $7 a day, and writes the base URL and agent key into &lt;code&gt;~/.claude/settings.json&lt;/code&gt;. New sessions go through the proxy from then on.&lt;/p&gt;

&lt;h3&gt;
  
  
  Or from a terminal
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx saifuban
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(&lt;code&gt;npx.cmd saifuban&lt;/code&gt; on Windows PowerShell.) Same thing, and it prints the two lines if you'd rather set them yourself:&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="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ANTHROPIC_BASE_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"https://saifuban.saifuban-app.workers.dev/proxy/anthropic"&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;ANTHROPIC_AUTH_TOKEN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"sbk_..."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Claude Code works the same, you just get today's remaining budget in the status line.&lt;/p&gt;

&lt;h3&gt;
  
  
  When it stops
&lt;/h3&gt;

&lt;p&gt;Claude Code shows a warning at 75% and 95% of the day's budget. Once it's used up, the next call gets refused with something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Saifuban] Daily budget reached: this call could cost up to $0.31 and $0.08 is left. Resets at 2026-11-20 00:00
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and Claude Code stops instead of looping (it's a 429 with &lt;code&gt;x-should-retry: false&lt;/code&gt;, so it doesn't retry). You also get a phone notification with a "+$3 today" button if you actually want it to keep going.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;/saifuban:off&lt;/code&gt; puts your settings back.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why "before the call" matters
&lt;/h2&gt;

&lt;p&gt;My first version counted cost after each call finished. That breaks as soon as you have parallel calls or retries: ten calls can all start while you're still under the limit, and you only find out after they finish.&lt;/p&gt;

&lt;p&gt;So now the proxy reserves the most a call could cost before sending it (input size + &lt;code&gt;max_tokens&lt;/code&gt; × the model's price), and settles to the real number when it ends. Reservations count against the budget, so parallel calls can't all slip through. If a request doesn't set &lt;code&gt;max_tokens&lt;/code&gt;, the proxy sets one so the model can't write past what was reserved.&lt;/p&gt;

&lt;p&gt;Other stuff I had to handle (a lot of it came from people poking holes on Reddit):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a stream that gets cut is stopped upstream too, and billed from what actually streamed, rounded up&lt;/li&gt;
&lt;li&gt;an SDK retry of the same call kills the orphaned original instead of reserving twice&lt;/li&gt;
&lt;li&gt;if the orphan doesn't stop within a few seconds, it's settled at its hold so the retry isn't stuck, then corrected later&lt;/li&gt;
&lt;li&gt;if a call ends up costing more than was reserved, the overrun is recorded and shown&lt;/li&gt;
&lt;li&gt;web searches are counted (they're billed per search, not per token)&lt;/li&gt;
&lt;li&gt;responses that take several minutes still stream to the end&lt;/li&gt;
&lt;li&gt;near the end of the day, if what's left can't cover the requested &lt;code&gt;max_tokens&lt;/code&gt; but can cover a few thousand tokens, the proxy lowers &lt;code&gt;max_tokens&lt;/code&gt; instead of refusing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I wrote up the test for the tricky cases (parallel calls under a small cap, delayed + retried + cancelled callback) &lt;a href="https://github.com/ut181749ut/saifuban/blob/main/tests/reserve-settle-release.md" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  If you don't want to send your key to my server
&lt;/h2&gt;

&lt;p&gt;It's all open source and runs on the Supabase + Cloudflare free tiers. Steps are in &lt;a href="https://github.com/ut181749ut/saifuban/blob/main/SELF_HOST.md" rel="noopener noreferrer"&gt;SELF_HOST.md&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Other tools
&lt;/h2&gt;

&lt;p&gt;Same setup works for the OpenAI SDK, LangChain, CrewAI and the Vercel AI SDK. You swap the base URL and the key. Examples are in the &lt;a href="https://github.com/ut181749ut/saifuban#use-it-from-your-agent-framework" rel="noopener noreferrer"&gt;README&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you only take one thing from this: give agents a key that has a daily limit, not your real key.&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>ai</category>
      <category>llm</category>
      <category>devops</category>
    </item>
    <item>
      <title>Break the cap: I published a live AI agent key with a $0.65/day budget</title>
      <dc:creator>uuu</dc:creator>
      <pubDate>Tue, 17 Nov 2026 10:24:02 +0000</pubDate>
      <link>https://dev.to/ut181749ut/break-the-cap-i-published-a-live-ai-agent-key-with-a-065day-budget-86b</link>
      <guid>https://dev.to/ut181749ut/break-the-cap-i-published-a-live-ai-agent-key-with-a-065day-budget-86b</guid>
      <description>&lt;p&gt;A spending cap for AI agents is only worth something if it holds when the agent misbehaves: when it loops, fires requests in parallel, retries everything, and gets creative with the input.&lt;/p&gt;

&lt;p&gt;So I published a live key for one. Try to break it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ut181749ut.github.io/saifuban/challenge.html?src=devto" rel="noopener noreferrer"&gt;https://ut181749ut.github.io/saifuban/challenge.html?src=devto&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The setup
&lt;/h2&gt;

&lt;p&gt;Saifuban is a spending guard for AI agents. Before an agent pays for anything, it asks Saifuban. Small amounts are approved automatically, anything bigger goes to your phone, and API calls can go through a proxy that stops at a daily, weekly or monthly budget.&lt;/p&gt;

&lt;p&gt;The challenge agent has:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a daily budget of ¥100 (about $0.65)&lt;/li&gt;
&lt;li&gt;a per-payment limit of ¥100&lt;/li&gt;
&lt;li&gt;auto-approval for anything up to ¥100&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That last part matters. There's no human in the loop to reject anything. If Saifuban gets the math or the timing wrong, the money goes through.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You win if the total approved amount for one day goes over ¥100.&lt;/strong&gt; Parallel requests, retries, odd currencies, strange merchant names, idempotency tricks: anything through the public API or MCP endpoint counts. No real money moves. The page shows a live counter of what's been approved today.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I tried first
&lt;/h2&gt;

&lt;p&gt;The obvious attack is a race. Fire a lot of requests at once and hope several pass the budget check before any of them is recorded.&lt;/p&gt;

&lt;p&gt;I sent 30 payment requests at the same time, mixing ¥60 requests with $0.40 and $0.45 ones and giving each a different merchant name.&lt;/p&gt;

&lt;p&gt;One was approved. The other 29 were rejected with "over daily budget".&lt;/p&gt;

&lt;p&gt;The reason is boring on purpose. Each request locks that agent's row in the database before it reads the budget, so requests for the same agent are processed one at a time. There's no gap between "check the budget" and "record the spend" for a parallel request to slip through.&lt;/p&gt;

&lt;h2&gt;
  
  
  The hole I did find
&lt;/h2&gt;

&lt;p&gt;Rounding.&lt;/p&gt;

&lt;p&gt;Amounts are stored in whole yen, and I was rounding to the nearest yen. So a request for ¥99.2 was stored as ¥99, and a following request for ¥0.3 was stored as ¥1. Both were approved, for a total of "¥100", while the agent had actually been allowed ¥99.5 against a budget it believed was respected. Worse, a single ¥100.4 request was approved as ¥100.&lt;/p&gt;

&lt;p&gt;It wouldn't have won the challenge, since the counter uses the stored amounts. But in real use, the agent could pay slightly more than it was approved for, and a cap that's "off by less than one yen" is still not a hard cap.&lt;/p&gt;

&lt;p&gt;Amounts are now always rounded up. ¥99.2 becomes ¥100, so the ¥0.3 that follows is rejected, and ¥100.4 becomes ¥101 and is rejected by the per-payment limit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two more things I added before posting this
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;A request rate limit.&lt;/strong&gt; Each agent can make at most 30 payment requests a minute. Without it, the challenge would just be an invitation to fill my database. Extra requests get a &lt;code&gt;429&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A concurrency limit on the API proxy.&lt;/strong&gt; This one came from reading about a $78k runaway agent bill, where hundreds of calls were already in flight when the budget was reached, and the cap couldn't stop them. Now each agent can have only a few API calls in flight at once (4 by default). Extra calls get a &lt;code&gt;429&lt;/code&gt;, which the official OpenAI and Anthropic SDKs already retry with backoff. A loop can't outrun the budget check.&lt;/p&gt;

&lt;h2&gt;
  
  
  The honest limit
&lt;/h2&gt;

&lt;p&gt;Saifuban can only stop what goes through it. If an agent has a raw card number and pays without asking, no approval layer will catch that. The hard guarantees are where Saifuban sits in the path: API spend through the proxy, where the agent never has the real key, and payments where the merchant checks Saifuban's single-use payment token.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;Key, curl example and MCP URL are on the challenge page. If you break it, open an issue on GitHub with how, and you'll be credited in the README. Failed attempts are interesting too.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Challenge: &lt;a href="https://ut181749ut.github.io/saifuban/challenge.html?src=devto" rel="noopener noreferrer"&gt;https://ut181749ut.github.io/saifuban/challenge.html?src=devto&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Source: &lt;a href="https://github.com/ut181749ut/saifuban" rel="noopener noreferrer"&gt;https://github.com/ut181749ut/saifuban&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>security</category>
      <category>agents</category>
      <category>mcp</category>
    </item>
    <item>
      <title>A hard daily cap on your AI agents’ API spend</title>
      <dc:creator>uuu</dc:creator>
      <pubDate>Sun, 08 Nov 2026 12:54:12 +0000</pubDate>
      <link>https://dev.to/ut181749ut/a-hard-daily-cap-on-your-ai-agents-api-spend-50g8</link>
      <guid>https://dev.to/ut181749ut/a-hard-daily-cap-on-your-ai-agents-api-spend-50g8</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwderozv8y7l5mjawb90b.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwderozv8y7l5mjawb90b.gif" alt="Demo: an agent loops overnight and the proxy stops its API calls at the daily budget" width="600" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Every so often someone posts about leaving an agent running overnight and waking up to a surprising API bill. An agent stuck in a loop will keep calling the API until something stops it.&lt;/p&gt;

&lt;p&gt;I didn't want that to happen to me, so I added a daily API budget to Saifuban, the spending guard for agents I've been building.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ut181749ut.github.io/saifuban/?src=devto" rel="noopener noreferrer"&gt;https://ut181749ut.github.io/saifuban/?src=devto&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;You store your provider API key in Saifuban and get a proxy key (&lt;code&gt;sbk_...&lt;/code&gt;) back. The agent only ever sees the proxy key.&lt;/p&gt;

&lt;p&gt;Requests go through Saifuban to the real API. Saifuban records the cost from the usage each response reports, and once the agent's spend for the day reaches its budget, it stops forwarding requests and returns an error instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;403 [Saifuban] Over daily budget ($10.00)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The budget resets the next day.&lt;/p&gt;

&lt;h2&gt;
  
  
  Supported providers
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;OpenAI&lt;/li&gt;
&lt;li&gt;Anthropic&lt;/li&gt;
&lt;li&gt;Google (Gemini)&lt;/li&gt;
&lt;li&gt;OpenRouter&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;OpenRouter reports the actual cost, so that's the most accurate. For the other three, the cost is calculated from token counts and the price table. Streaming responses are metered too.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Open the site, press Start, and create an agent&lt;/li&gt;
&lt;li&gt;In Settings, store the API key for the provider you use&lt;/li&gt;
&lt;li&gt;Put the proxy base URL and the proxy key into your agent's config&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For Claude Code, that's two environment variables:&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="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;ANTHROPIC_BASE_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"https://zrphnuvrsldcycxtdftv.supabase.co/functions/v1/saifuban-proxy/anthropic"&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;ANTHROPIC_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"sbk_..."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Tools built on the OpenAI SDK work the same way with &lt;code&gt;OPENAI_BASE_URL&lt;/code&gt; and &lt;code&gt;OPENAI_API_KEY&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Budgets are per agent, so a research agent can get $1/day and a coding agent $10/day.&lt;/p&gt;

&lt;h2&gt;
  
  
  Things to know
&lt;/h2&gt;

&lt;p&gt;The budget check happens before each request. Requests that are already in flight when the budget is reached still go through, so the day can end slightly over budget, by at most those requests.&lt;/p&gt;

&lt;p&gt;You are also handing your real API key to a third party. It's kept in an encrypted vault, only the last few characters are ever shown, and prompts and responses are not stored. If that still bothers you, create a separate key with its own spending limit on the provider side and store that one.&lt;/p&gt;

&lt;h2&gt;
  
  
  It also handles other payments
&lt;/h2&gt;

&lt;p&gt;The original idea behind Saifuban is that agents ask before spending money. Small amounts are approved automatically, and anything above your limit goes to your phone as a notification you can approve or reject. This part works with Claude, ChatGPT and Muse, and with Muse you just send the URL in a chat message to connect. With the API cap on top, most of the ways an agent can spend money are covered.&lt;/p&gt;

&lt;p&gt;It's free, there's no email signup, and amounts can be shown in USD or JPY.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update (Nov 9):&lt;/strong&gt; You can now connect from Claude without copying a key. Add &lt;code&gt;https://zrphnuvrsldcycxtdftv.supabase.co/functions/v1/saifuban-mcp&lt;/code&gt; as a custom connector and press Allow on the Saifuban page that opens. Budgets can also be weekly and monthly now, not just daily, and the API proxy stops at whichever limit comes first.&lt;/p&gt;

&lt;p&gt;If something's missing for your setup, I'd like to hear about it in the comments or on GitHub.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/ut181749ut/saifuban" rel="noopener noreferrer"&gt;https://github.com/ut181749ut/saifuban&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>claude</category>
      <category>openai</category>
    </item>
    <item>
      <title>I built a spending guard for AI agents that asks my phone before they pay</title>
      <dc:creator>uuu</dc:creator>
      <pubDate>Sun, 08 Nov 2026 06:23:32 +0000</pubDate>
      <link>https://dev.to/ut181749ut/i-built-a-spending-guard-for-ai-agents-that-asks-my-phone-before-they-pay-3nlb</link>
      <guid>https://dev.to/ut181749ut/i-built-a-spending-guard-for-ai-agents-that-asks-my-phone-before-they-pay-3nlb</guid>
      <description>&lt;p&gt;I've been letting AI agents do more on their own, and at some point I realized that if one decided to buy something or upgrade a plan, nothing would stop it. So I built &lt;strong&gt;Saifuban&lt;/strong&gt; ("wallet keeper" in Japanese).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ut181749ut.github.io/saifuban/" rel="noopener noreferrer"&gt;https://ut181749ut.github.io/saifuban/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frh1hlfp53k19y8952yvp.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frh1hlfp53k19y8952yvp.gif" alt="Demo: the AI tries to pay on its own and I reject it from my phone" width="600" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What it does
&lt;/h2&gt;

&lt;p&gt;Before spending money, the agent asks Saifuban whether the payment is OK. Saifuban answers using rules you set:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Small amounts under your threshold are approved right away.&lt;/li&gt;
&lt;li&gt;Anything larger sends a push notification to your phone. You tap Approve or Reject.&lt;/li&gt;
&lt;li&gt;Payments over the daily budget or the per-payment limit are refused, as are merchants you haven't allowed.&lt;/li&gt;
&lt;li&gt;A kill switch stops everything at once.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Rules are per agent, so a research agent can have $5/day while a coding agent gets more. Saifuban never handles card details or moves money. It only decides whether a payment is allowed.&lt;/p&gt;

&lt;h2&gt;
  
  
  How you connect it
&lt;/h2&gt;

&lt;p&gt;It's a remote MCP server, so any client that supports remote MCP can use it with one URL: Claude (custom connector), ChatGPT (developer mode), Muse (just send the URL in a chat message, no settings screen), Cursor, VS Code and so on. Open the site, pick a budget, and paste the URL it gives you. Then ask your agent "check my remaining budget with Saifuban" to confirm it's connected.&lt;/p&gt;

&lt;p&gt;The agent sees three tools:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;request_payment&lt;/code&gt;: ask whether a payment (merchant, amount, currency, reason) is allowed. It waits up to 45 seconds for you to approve on your phone.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;check_payment_status&lt;/code&gt;: check a pending request later.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;get_budget&lt;/code&gt;: how much is left today.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Amounts can be in yen or dollars, and the UI has an English mode.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two things I had to get right
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Pending requests count against the budget.&lt;/strong&gt; If they didn't, an agent could fire off ten pending requests, and approving them all would blow straight past the daily limit. So a pending request reserves its amount until it's decided or expires (24 hours).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Asking is voluntary.&lt;/strong&gt; Someone on Reddit pointed out that a prompt-injected agent could simply skip the check. That's true. So every approved request now returns a single-use &lt;code&gt;payment_token&lt;/code&gt; that is scoped to the approved merchant and amount, expires in 24 hours, and dies if the agent is stopped. Whatever actually moves the money calls &lt;code&gt;/redeem&lt;/code&gt; before paying:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-X&lt;/span&gt; POST https://zrphnuvrsldcycxtdftv.supabase.co/functions/v1/saifuban/redeem &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"content-type: application/json"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s1"&gt;'{"token":"sbt_...","merchant":"OpenAI","amount":12.5,"currency":"USD"}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A second redeem returns &lt;code&gt;already_used&lt;/code&gt;, a different merchant returns &lt;code&gt;merchant_mismatch&lt;/code&gt;, and a bigger amount returns &lt;code&gt;amount_exceeds_approval&lt;/code&gt;. To be clear, this only becomes hard enforcement when the payment side checks the token. Today that means your own payment code, not third-party checkout.&lt;/p&gt;

&lt;p&gt;API spend is the one place it's already enforced: if you store your OpenAI, Anthropic or OpenRouter key in Saifuban, the agent only ever gets a proxy key, and requests stop when the budget runs out.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stack
&lt;/h2&gt;

&lt;p&gt;Supabase Edge Functions and Postgres. All the rules are checked inside one database function, with a row lock per agent so concurrent requests can't race the budget. The site is a plain-JS PWA on GitHub Pages, and notifications use Web Push with approve/reject buttons right in the notification.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;It's free and early. I'd love to hear what limits would make you comfortable letting an agent spend, and whether you'd verify tokens on the merchant side.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Site: &lt;a href="https://ut181749ut.github.io/saifuban/" rel="noopener noreferrer"&gt;https://ut181749ut.github.io/saifuban/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Repo and issues: &lt;a href="https://github.com/ut181749ut/saifuban" rel="noopener noreferrer"&gt;https://github.com/ut181749ut/saifuban&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Saifuban can now put a hard daily cap on your agents’ API spend. More here: &lt;a href="https://dev.to/ut181749ut/a-hard-daily-cap-on-your-ai-agents-api-spend-50g8"&gt;https://dev.to/ut181749ut/a-hard-daily-cap-on-your-ai-agents-api-spend-50g8&lt;/a&gt;&lt;/p&gt;

</description>
      <category>mcp</category>
      <category>ai</category>
      <category>agents</category>
      <category>security</category>
    </item>
  </channel>
</rss>
