<?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: Jeevesh Chaurasiya</title>
    <description>The latest articles on DEV Community by Jeevesh Chaurasiya (@jeevesh_chaurasiya_738cb2).</description>
    <link>https://dev.to/jeevesh_chaurasiya_738cb2</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%2F4190683%2F0d9105a0-8899-4695-b4a0-b80c22ba2901.png</url>
      <title>DEV Community: Jeevesh Chaurasiya</title>
      <link>https://dev.to/jeevesh_chaurasiya_738cb2</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jeevesh_chaurasiya_738cb2"/>
    <language>en</language>
    <item>
      <title>BurnSwitch: Stopping a Runaway AWS Bill With Switch, Two AI Agents and One Human Tap</title>
      <dc:creator>Jeevesh Chaurasiya</dc:creator>
      <pubDate>Sat, 07 Nov 2026 06:50:12 +0000</pubDate>
      <link>https://dev.to/jeevesh_chaurasiya_738cb2/burnswitch-stopping-a-runaway-aws-bill-with-switch-two-ai-agents-and-one-human-tap-2j24</link>
      <guid>https://dev.to/jeevesh_chaurasiya_738cb2/burnswitch-stopping-a-runaway-aws-bill-with-switch-two-ai-agents-and-one-human-tap-2j24</guid>
      <description>&lt;p&gt;&lt;em&gt;A Switch room, bridged to Telegram, where an AI watchdog spots a Lambda/SQS retry storm, Claude Code finds and fixes the bug, and nothing changes in AWS until the on-call human taps &lt;strong&gt;Allow once&lt;/strong&gt; on their phone.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/dIdHmdBiKkk" width="710" height="399"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;One bad deploy can quietly burn money all night, and nobody notices until the bill arrives.&lt;/p&gt;

&lt;p&gt;Here's the classic case. A new client starts sending orders in a slightly different shape. The Lambda function that processes them throws an error. There is no dead-letter queue and no partial batch reporting, so SQS retries the whole batch, again and again. The good orders in that batch fail along with the bad one, and they get retried too. Invocations climb, errors climb, and the bill climbs with them.&lt;/p&gt;

&lt;p&gt;Fixing it takes four different jobs: spot the burn, find the cause, pause the worker without losing orders, then ship a patch and recover in the right order. Today that usually means one tired human at 2 a.m. copying alerts between a dashboard, a chat app and a terminal.&lt;/p&gt;

&lt;p&gt;The obvious shortcut is to hand the whole thing to an autonomous AI agent. But then nobody signs off on the commands that change production. That felt like the wrong trade.&lt;/p&gt;

&lt;h2&gt;
  
  
  In simple words
&lt;/h2&gt;

&lt;p&gt;Imagine a kitchen tap left running in an empty house. The water bill grows every minute.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;smoke alarm for water&lt;/strong&gt; (our watchdog) notices the meter spinning too fast and calls the plumber.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;plumber&lt;/strong&gt; (Claude Code) finds the broken pipe and explains exactly what they want to do: "turn off the main valve", "replace this pipe", "turn the water back on".&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;homeowner&lt;/strong&gt; (the on-call human) says yes or no to each step, from their phone. The plumber can't touch the valve without that yes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;BurnSwitch is that, for AWS. The "yes" is the switch.&lt;/p&gt;

&lt;h3&gt;
  
  
  A few words explained
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Lambda:&lt;/strong&gt; a small piece of code AWS runs for you whenever there's work. You pay per run and per second of running.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SQS:&lt;/strong&gt; a queue. Orders wait in it until the Lambda picks them up.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Retry storm:&lt;/strong&gt; when failing messages are retried endlessly, so you pay over and over for work that never succeeds.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dead-letter queue (DLQ):&lt;/strong&gt; a side queue where messages go after failing too many times, so they stop being retried.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Switch:&lt;/strong&gt; a platform where humans and AI agents share a "room", like a group chat, with approvals built in. Our room is bridged to a Telegram group.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;Everything happens in one Switch room, with four participants:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Participant&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;@burn-watchdog&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Our custom agent. Prices the Lambda's spend every 15 s, raises one alert, and keeps the ledger&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;@claude-code&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Reproduces the bug, writes the patch and tests, and proposes each command&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;The human&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The on-call engineer. Approves or declines every live change from Telegram&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;@finops-auditor&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Joins at the end and writes the post-mortem from the ledger&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The switch is the human's &lt;strong&gt;Allow once&lt;/strong&gt; tap. Every live command (pause, deploy, reconfigure, resume, move messages) gets its own approval card. Nothing reaches AWS without one.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it works, step by step
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Watch the money.&lt;/strong&gt; Every 15 seconds the watchdog reads Lambda invocations, errors, duration and queue stats, and turns them into dollars per hour using prices from a config file (never hardcoded).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Open one incident.&lt;/strong&gt; When spend is at least 1.5× the healthy baseline, errors are at least 5% and messages have been received 3+ times, for two samples in a row, the watchdog opens an incident.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hand off once.&lt;/strong&gt; It sends exactly one alert, addressed to @claude-code. After that the agents only talk to the human, so they never ping-pong.&lt;/li&gt;
&lt;/ol&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Diagnose.&lt;/strong&gt; Claude Code reproduces the failure, names the cause and the commit that introduced it, writes a patch with tests, and proposes the first command: pause the worker.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Flip the switch.&lt;/strong&gt; The human types &lt;code&gt;@claude-code run 3a&lt;/code&gt; in Telegram. Claude Code asks for approval, Switch shows an Allow / Deny card, the human taps &lt;strong&gt;Allow once&lt;/strong&gt;, and only then does the command run.&lt;/li&gt;
&lt;/ol&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Recover in a fixed order.&lt;/strong&gt; The same loop repeats for each step: deploy the patch, turn on partial batch failures, attach the dead-letter queue, resume, and finally move the good orders back from the DLQ.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trust, but verify.&lt;/strong&gt; The watchdog doesn't take anyone's word for it. It compares the infrastructure on every sample, traces each change to the command that made it, pairs it with the human's request, and counts every order: sent = processed + still queued + in the DLQ.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write it down.&lt;/strong&gt; The ledger (&lt;code&gt;cost-ledger.md&lt;/code&gt;, a room document) records every change. The auditor joins last, reads it, and writes the post-mortem.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That's the whole idea: the agents do the work, the human holds the switch, and the watchdog keeps everyone honest.&lt;/p&gt;

&lt;h2&gt;
  
  
  The recovery order
&lt;/h2&gt;

&lt;p&gt;Order matters here, and getting it wrong loses orders:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step&lt;/th&gt;
&lt;th&gt;Change&lt;/th&gt;
&lt;th&gt;Why&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;3a&lt;/td&gt;
&lt;td&gt;Reserved concurrency 0&lt;/td&gt;
&lt;td&gt;Stops the burn at once; every message stays on the queue&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4b&lt;/td&gt;
&lt;td&gt;Deploy the patch&lt;/td&gt;
&lt;td&gt;Validates input and reports only the bad orders as failed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4c&lt;/td&gt;
&lt;td&gt;Turn on ReportBatchItemFailures&lt;/td&gt;
&lt;td&gt;A bad order fails alone; the rest of its batch succeeds&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4d&lt;/td&gt;
&lt;td&gt;Redrive policy: orders-dlq, max 3 receives&lt;/td&gt;
&lt;td&gt;Failing messages stop after 3 tries&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4e&lt;/td&gt;
&lt;td&gt;Run a safety check, then resume&lt;/td&gt;
&lt;td&gt;Resuming is refused until 4c and 4d are both in place&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4f&lt;/td&gt;
&lt;td&gt;Move the DLQ back to the main queue&lt;/td&gt;
&lt;td&gt;Brings back the good orders that resuming dead-lettered&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Containment is just "pause". Nothing in the project ever purges a queue or deletes a message.&lt;/p&gt;

&lt;h2&gt;
  
  
  How we use Switch
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Rooms with a Telegram bridge:&lt;/strong&gt; the whole incident lives in one room, so the human can handle it from a phone.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A custom agent:&lt;/strong&gt; @burn-watchdog speaks the Switch agent protocol (WebSocket events plus HTTP operations), reconnects with backoff, and follows Switch when the local server moves ports.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Targeted messages:&lt;/strong&gt; exactly one alert per incident, sent only to @claude-code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Console agents:&lt;/strong&gt; Claude Code runs in the &lt;code&gt;scenario/&lt;/code&gt; folder with permission rules that make every live command ask, every time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Approval requests:&lt;/strong&gt; each of those prompts becomes an Allow / Deny card in Telegram. This is the switch.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Room documents:&lt;/strong&gt; the ledger and the runbook live in the room, where every agent can read them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Room instructions and commands:&lt;/strong&gt; shared rules for all agents ("never purge", "one command per approval"), plus &lt;code&gt;!reset&lt;/code&gt; and &lt;code&gt;!invite-agent&lt;/code&gt; for clean runs and a late-joining auditor.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The switch is enforced in four layers, not just one: the room instructions, Claude Code's own permission rules (raw &lt;code&gt;aws&lt;/code&gt;, purge and delete are denied outright), Switch's approval cards, and our helper scripts, which refuse unsafe commands even if asked.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building on Switch: what I wish I'd known on day one
&lt;/h2&gt;

&lt;p&gt;If you're starting with Switch, these are the things that cost me the most time. Hopefully they save you some.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Run a local server first
&lt;/h3&gt;

&lt;p&gt;Install &lt;strong&gt;Switch Console&lt;/strong&gt; and &lt;strong&gt;Docker&lt;/strong&gt;, then choose &lt;strong&gt;Run a server on this computer&lt;/strong&gt;. The first start downloads several GB, so do it before you need it. A local server comes with its own messaging app, so you can build and test without any company workspace.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Connecting Telegram, in the right order
&lt;/h3&gt;

&lt;p&gt;The order matters here, and getting it wrong produces confusing errors:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a bot with &lt;strong&gt;&lt;a class="mentioned-user" href="https://dev.to/botfather"&gt;@botfather&lt;/a&gt;&lt;/strong&gt; and save the token somewhere safe. Never paste it into a chat or a room.&lt;/li&gt;
&lt;li&gt;In BotFather, turn &lt;strong&gt;Group Privacy off&lt;/strong&gt; &lt;em&gt;before&lt;/em&gt; adding the bot to any group. Otherwise the bot only sees messages that mention it.&lt;/li&gt;
&lt;li&gt;Connect Telegram in Switch Console with the token and the bot's username.&lt;/li&gt;
&lt;li&gt;Create the Telegram group yourself (bots can't), add the bot, and &lt;strong&gt;send a message in the group&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Only then link your Telegram account in Console, by searching your own @username.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;My mistake: I tried to link my account straight after connecting and got &lt;strong&gt;"Bridge is not running"&lt;/strong&gt;. Switch can only find people who have already posted where the bot can see, so posting first, then linking, fixed it. A quick sanity check for your token: &lt;code&gt;curl -s "https://api.telegram.org/bot$TOKEN/getMe"&lt;/code&gt; should return &lt;code&gt;"ok":true&lt;/code&gt;, and &lt;code&gt;"can_read_all_group_messages":true&lt;/code&gt; confirms Group Privacy is off.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Registering a custom agent
&lt;/h3&gt;

&lt;p&gt;A custom agent needs a &lt;strong&gt;registration key&lt;/strong&gt;, created on the Gateway's API Keys page. Two things to know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Create the key while signed in as yourself.&lt;/strong&gt; The person who creates the key owns the agent. If you use the deployment's bootstrap key instead, the agent belongs to a separate account, and it won't be allowed to address your other agents.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The agent's API key is shown once.&lt;/strong&gt; Save it straight into &lt;code&gt;.env&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To let one of your agents hand work to another, set the receiving agent's addressing to &lt;code&gt;owner_and_owner_agents&lt;/code&gt;. By default, an agent answers only its owner.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. The agent protocol in practice
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Events come over a WebSocket; actions are HTTP calls.&lt;/strong&gt; Older SSE clients are deprecated, so build on the WebSocket.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You receive every message in your rooms.&lt;/strong&gt; Act only when &lt;code&gt;payload.addressed&lt;/code&gt; is true, or your agent will reply to everything.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The bridge URL isn't the Gateway URL.&lt;/strong&gt; Check you have the right one with &lt;code&gt;GET /health&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Plan for disconnects.&lt;/strong&gt; Answer pings, reconnect with backoff, and keep outgoing messages in an outbox until Switch accepts them.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's how @burn-watchdog connects and handles events:&lt;/p&gt;

&lt;p&gt;And here's the single targeted alert it sends to @claude-code:&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Making approvals actually block
&lt;/h3&gt;

&lt;p&gt;The approval card comes from &lt;strong&gt;Claude Code's own permission rules&lt;/strong&gt;. In &lt;code&gt;scenario/.claude/settings.json&lt;/code&gt;, every mutating command is an &lt;code&gt;ask&lt;/code&gt; rule, and dangerous ones are &lt;code&gt;deny&lt;/code&gt; rules. Switch turns each &lt;code&gt;ask&lt;/code&gt; prompt into an Allow / Deny card in the room. Two tips:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Approve with &lt;strong&gt;Allow once&lt;/strong&gt;, not "Allow for this session", for anything that touches production.&lt;/li&gt;
&lt;li&gt;Back the rules up with helper scripts that refuse unsafe commands themselves. That way, safety doesn't depend on a single layer.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  6. Late-joining agents
&lt;/h3&gt;

&lt;p&gt;When an agent joins a room, Switch gives it the room's &lt;strong&gt;instructions and the list of room documents&lt;/strong&gt;. The message history isn't included automatically: the agent reads it with &lt;code&gt;read_context&lt;/code&gt;. That's why our auditor can arrive at the very end, read the ledger and the thread, and write an accurate post-mortem without anyone re-explaining anything.&lt;/p&gt;

&lt;h2&gt;
  
  
  How did it go?
&lt;/h2&gt;

&lt;p&gt;These numbers are from one recorded run on LocalStack:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Alert in about 1 minute.&lt;/strong&gt; The burn peaked at 12.4× the healthy baseline.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Contained in 3 min 06 s&lt;/strong&gt;, measured from the alert to the pause command. Resolved in 6 min 30 s.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;6 live changes, 6 approved&lt;/strong&gt;, each one traced to its command and to the human's request.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No orders lost.&lt;/strong&gt; 1,198 sent = 955 processed + 0 queued + 243 in the DLQ, and every one of those 243 is a malformed order.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost avoided (estimate): $0.84.&lt;/strong&gt; That's (peak − baseline) × 8 hours, assuming the storm would otherwise run until someone checked the bill in the morning.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The dollar figure is small because the demo traffic is small. It's an estimate built on a stated assumption, not a measurement, and the ledger says so.&lt;/p&gt;

&lt;h2&gt;
  
  
  What fought back
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Agents can't see who tapped Allow.&lt;/strong&gt; Switch stores who answered each approval card, but as far as we could find, no agent operation returns it. So the watchdog pairs each change with two things it &lt;em&gt;can&lt;/em&gt; see: the human's "run …" message (up to 2 minutes before the command) and Claude Code's "Approved by …" line. The auditor is told to say this openly rather than claim more than we know.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resuming sent the good orders to the DLQ.&lt;/strong&gt; This one surprised us. Once a redrive policy is attached (step 4d), SQS moves any message whose receive count is already above the limit to the DLQ on its next receive, whatever the code does with it. The good orders stuck in the storm had receive counts of 10–120, so the moment we resumed (step 4e), they all went straight to the DLQ. The fix was a sixth step: move the DLQ back with &lt;code&gt;start-message-move-task&lt;/code&gt;, which gives every message a fresh receive count. Good orders then succeed, and the malformed ones fail three more times and return.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Changes showed up before their own log line.&lt;/strong&gt; The helper script writes its change log &lt;em&gt;after&lt;/em&gt; the AWS command returns, so the watchdog sometimes saw a change before it knew who made it, and labelled it "source unknown". We added a retry: an unknown change is checked again for up to 2 minutes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The alert went to the wrong room.&lt;/strong&gt; We accidentally created a second Telegram group with a similar name, and a substring match picked the old room. The reset script now prefers an exact name match.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LocalStack only reports half the metrics.&lt;/strong&gt; It emits Invocations and Errors but no duration, which we need to price GB-seconds. The watchdog reads Lambda's &lt;code&gt;REPORT&lt;/code&gt; log lines instead. On real AWS, a CloudWatch adapter does the same job.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limitations
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;One Lambda function and one incident at a time.&lt;/li&gt;
&lt;li&gt;Our recorded runs used LocalStack. The real-AWS path is built and guarded (it needs a typed account ID and has a teardown script), but we haven't recorded it.&lt;/li&gt;
&lt;li&gt;The approval pairing above is inferred from messages, not read from Switch.&lt;/li&gt;
&lt;li&gt;Telegram can't open room documents, so the full ledger is read with &lt;code&gt;npm run ledger:show&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Who this is for
&lt;/h2&gt;

&lt;p&gt;Anyone who runs event-driven workloads on AWS and wants AI help during incidents without giving up control. You don't need to trust the agents blindly: every change asks first, and every change is checked afterwards.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we learned
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Put the human at the switch, not in the loop.&lt;/strong&gt; The agents do the typing; the human makes one decision per change, from a phone.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Watch cost, not just errors.&lt;/strong&gt; A dollars-per-hour number makes "is this bad?" obvious to everyone in the room.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Verify, don't trust.&lt;/strong&gt; Diffing the real infrastructure caught things neither agent mentioned.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The recovery order is the hard part.&lt;/strong&gt; Pausing is easy. Coming back without losing orders took six careful steps.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Say what you can't measure.&lt;/strong&gt; The ledger and the post-mortem both state their own assumptions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What's next
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A safer deploy script.&lt;/strong&gt; Our auditor agent suggested this one itself: refuse to deploy unless the queue has its redrive policy and the event source mapping has ReportBatchItemFailures. With both in place, the original bug would have failed only the malformed orders, with no retry storm.&lt;/li&gt;
&lt;li&gt;A guard so a patch can't ship without its tests passing.&lt;/li&gt;
&lt;li&gt;A recorded run on real AWS.&lt;/li&gt;
&lt;li&gt;More than one function and more failure types, such as timeouts and throttling.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Code:&lt;/strong&gt; &lt;a href="https://github.com/Jeevesh2605/BurnSwitch" rel="noopener noreferrer"&gt;github.com/Jeevesh2605/BurnSwitch&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Demo video:&lt;/strong&gt; &lt;a href="https://youtu.be/dIdHmdBiKkk" rel="noopener noreferrer"&gt;youtu.be/dIdHmdBiKkk&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Built for the &lt;strong&gt;Flip the Switch&lt;/strong&gt; hackathon (Track 01). #HowISwitch&lt;/p&gt;

</description>
      <category>aws</category>
      <category>ai</category>
      <category>serverless</category>
      <category>hackathon</category>
    </item>
    <item>
      <title>RingBreaker: An AI Agent That Breaks UPI Mule Rings on FalkorDB</title>
      <dc:creator>Jeevesh Chaurasiya</dc:creator>
      <pubDate>Sun, 18 Oct 2026 04:49:13 +0000</pubDate>
      <link>https://dev.to/jeevesh_chaurasiya_738cb2/ringbreaker-an-ai-agent-that-breaks-upi-mule-rings-on-falkordb-3d30</link>
      <guid>https://dev.to/jeevesh_chaurasiya_738cb2/ringbreaker-an-ai-agent-that-breaks-upi-mule-rings-on-falkordb-3d30</guid>
      <description>&lt;p&gt;RingBreaker is an AI agent that investigates UPI mule rings inside a FalkorDB graph, freezes the ring only after a human approves, and then proves with one more graph query that no money path is left.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Live demo:&lt;/strong&gt; &lt;a href="https://ringbreaker-5o88.onrender.com" rel="noopener noreferrer"&gt;ringbreaker-5o88.onrender.com&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code:&lt;/strong&gt; &lt;a href="https://github.com/Jeevesh2605/ringbreaker" rel="noopener noreferrer"&gt;github.com/Jeevesh2605/ringbreaker&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Built for:&lt;/strong&gt; Graph Hacks: Context for AI Agents (FalkorDB), Track 01: Agents That Act on Connected Data. Solo, built Oct 15 to 18, 2026.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The loop in one line:&lt;/strong&gt; investigate → verdict → human approval → freeze → verify ("13 open routes, then 0").&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;A scam victim pays a "KYC update" fee over UPI. Within hours the money has hopped through four accounts and is gone.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Each hop looks harmless.&lt;/strong&gt; A Rs 8,000 transfer between two accounts is normal on its own.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The pattern lives in the connections.&lt;/strong&gt; Brand-new accounts, minimal KYC, shared phones and devices, money fanning in and out within minutes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tables hide it.&lt;/strong&gt; Following money four hops deep in SQL means four self-joins, and the query has to know the shape in advance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Most fraud demos stop at "flagged".&lt;/strong&gt; Nobody acts on the alert, and nobody checks that the action worked.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  In simple words
&lt;/h2&gt;

&lt;p&gt;Think of a bucket brigade passing stolen water down a line of people. You could question each person on their own, and each one would only say "I passed a bucket."&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;RingBreaker looks at the whole line at once: who passed to whom, who stands on the same spot (a shared phone or device), and where the water ends up.&lt;/li&gt;
&lt;li&gt;It then asks a person: "Remove these five from the line?"&lt;/li&gt;
&lt;li&gt;After they say yes, it checks again that no bucket can still reach the end. That last check is the point of the project.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The stack
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;FalkorDB:&lt;/strong&gt; the only datastore. Accounts, transactions, devices, alerts, verdicts and the audit trail all live in one graph. Docker locally, FalkorDB Cloud in production.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Node.js + Express:&lt;/strong&gt; the API, the agent loop and the tools, using the official &lt;code&gt;falkordb&lt;/code&gt; client.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Groq (&lt;code&gt;groq-sdk&lt;/code&gt;) with function calling:&lt;/strong&gt; &lt;code&gt;openai/gpt-oss-120b&lt;/code&gt; as the main model, &lt;code&gt;qwen/qwen3.8-27b&lt;/code&gt; as a fallback when the daily quota runs out.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;React + Vite + &lt;code&gt;react-force-graph-2d&lt;/code&gt;:&lt;/strong&gt; the three-pane dashboard and the live graph canvas.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Server-Sent Events:&lt;/strong&gt; each tool call streams to the browser as it happens.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Render:&lt;/strong&gt; one Docker image serves the API and the built UI on a single URL.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftmjfvahj3dm9eg6d1zpg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftmjfvahj3dm9eg6d1zpg.png" alt=" " width="800" height="311"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The agent reaches FalkorDB only through read-only tools; the single write path runs from the API after a person approves.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How it actually works, step by step
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;You click an alert, for example a victim complaint: "paid ~25,000 for a fake KYC update; money moved on within hours."&lt;/li&gt;
&lt;li&gt;The API starts the agent and streams every step over SSE. The agent picks graph tools (&lt;code&gt;get_alert&lt;/code&gt;, &lt;code&gt;money_trail&lt;/code&gt;, &lt;code&gt;fan_stats&lt;/code&gt;, &lt;code&gt;shared_identity&lt;/code&gt;, &lt;code&gt;expand_ring&lt;/code&gt; and others). Each one runs a parameterized Cypher query.&lt;/li&gt;
&lt;li&gt;The canvas lights up the exact nodes and edges each query touched. A "Show Cypher" toggle reveals the query behind every step.&lt;/li&gt;
&lt;li&gt;The agent submits a structured JSON verdict: &lt;code&gt;ring_confirmed&lt;/code&gt;, &lt;code&gt;suspicious&lt;/code&gt; or &lt;code&gt;benign&lt;/code&gt;, ring members with roles (victim, layer, collector, cashout), evidence citing graph facts, and recommended freezes.&lt;/li&gt;
&lt;li&gt;The server validates the verdict and saves it as a &lt;code&gt;Case&lt;/code&gt; node in the graph.&lt;/li&gt;
&lt;li&gt;You review the evidence, untick anything you disagree with, type your name and press &lt;strong&gt;Approve freeze&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;The server freezes the approved accounts, writes an audit edge for each, re-runs the verify query and shows the result, for example &lt;strong&gt;13 open routes → 0&lt;/strong&gt;. The alert then moves to &lt;strong&gt;Closed&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The agent proposes; a person decides; the graph proves it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5xip1l82raxw3q5ded2u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5xip1l82raxw3q5ded2u.png" alt=" " width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The dashboard: alert queue with live status on the left, the graph canvas in the middle, the agent trace on the right, and the four-stage tracker in the header.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fl4angp1ynb6duozdeco9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fl4angp1ynb6duozdeco9.png" alt=" " width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Mid-investigation on ALT002 (Ring B, the device farm). Every account, device and phone the agent touched is on the canvas, with its latest step glowing. The trace shows each tool call, its arguments and timing, and the switch to the fallback model when the daily quota ran out.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The graph and the agent's tools
&lt;/h2&gt;

&lt;p&gt;One FalkorDB graph, &lt;code&gt;ring&lt;/code&gt;, with 7,847 nodes and 25,962 edges, all synthetic and generated from a seeded random generator so every demo is reproducible.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Nodes:&lt;/strong&gt; &lt;code&gt;Account&lt;/code&gt; (1,911), &lt;code&gt;VPA&lt;/code&gt;, &lt;code&gt;Device&lt;/code&gt;, &lt;code&gt;Phone&lt;/code&gt;, &lt;code&gt;Alert&lt;/code&gt; (7), plus &lt;code&gt;Case&lt;/code&gt; nodes written at run time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Edges:&lt;/strong&gt; &lt;code&gt;SENT&lt;/code&gt; (20,007, one per transaction, with &lt;code&gt;amount&lt;/code&gt; and &lt;code&gt;ts&lt;/code&gt;), &lt;code&gt;USES_DEVICE&lt;/code&gt;, &lt;code&gt;LINKED_PHONE&lt;/code&gt;, &lt;code&gt;HAS_VPA&lt;/code&gt;, &lt;code&gt;ABOUT&lt;/code&gt;, and the audit edges &lt;code&gt;INCLUDES {role}&lt;/code&gt; and &lt;code&gt;ACTION {type, ts, approved_by}&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Transactions are edges, not nodes.&lt;/strong&gt; A trail of N transfers is an N-hop path, so &lt;code&gt;-[:SENT*1..4]-&amp;gt;&lt;/code&gt; answers "where did the money go?" in one query.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Planted scenarios:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Ring A, a layering chain: 4 victims → 3 first-layer mules → 2 second-layer mules → 1 collector → 1 cash-out, with amounts split into chunks minutes apart.&lt;/li&gt;
&lt;li&gt;Ring B, a device farm: 6 accounts on 2 devices and 1 phone, each collecting small payments from many senders, then sweeping to one account.&lt;/li&gt;
&lt;li&gt;Ring C, a decoy: 3 accounts on a shared device but with no money link. The right answer is "suspicious, monitor", not a freeze.&lt;/li&gt;
&lt;li&gt;Benign look-alikes: a busy merchant with high fan-in, and a family sharing one phone. Neither may be flagged.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tools the model can call (read-only):&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;What it asks the graph&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;money_trail&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Follow money forward or backward up to N hops, with &lt;code&gt;all(r IN relationships(p) WHERE r.ts &amp;gt;= $since)&lt;/code&gt; on every edge&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;shared_identity&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Who else uses this device or phone: `(a)-[:USES_DEVICE\&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;{% raw %}&lt;code&gt;fan_stats&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;In/out degree, totals and pass-through ratio&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;expand_ring&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Grow a candidate ring along money and identity links at once (&lt;code&gt;UNION ALL&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;account_profile&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Age, KYC level, and how many accounts share each device or phone&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;get_alert&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The alert and its target account&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;run_readonly_cypher&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;A guarded free-form fallback for anything else&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Every tool starts from an indexed lookup&lt;/strong&gt; (&lt;code&gt;Account.id&lt;/code&gt;, &lt;code&gt;Device.id&lt;/code&gt;, &lt;code&gt;Phone.number&lt;/code&gt;, &lt;code&gt;VPA.handle&lt;/code&gt;, &lt;code&gt;Alert.id&lt;/code&gt;, &lt;code&gt;Case.id&lt;/code&gt;). Queries take 5 to 30 ms locally and 230 to 470 ms from Render to FalkorDB Cloud.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Every tool call emits a trace event:&lt;/strong&gt; tool, arguments, the exact Cypher, a one-line summary, and the node and edge IDs it touched. The canvas highlights from those IDs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Act, then prove it
&lt;/h2&gt;

&lt;p&gt;Flagging is half the job. RingBreaker acts on the verdict and then checks its own work.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The model cannot freeze anything.&lt;/strong&gt; Action tools (&lt;code&gt;create_case&lt;/code&gt;, &lt;code&gt;freeze_account&lt;/code&gt;, &lt;code&gt;verify_cutoff&lt;/code&gt;, &lt;code&gt;close_case&lt;/code&gt;, &lt;code&gt;generate_report&lt;/code&gt;) are never offered to the LLM. Only the approval API calls them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The approval gate is one Cypher statement.&lt;/strong&gt; It freezes an account only if the case proposed it and it is still active, and writes the audit edge in the same query:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cypher"&gt;&lt;code&gt;&lt;span class="k"&gt;MATCH&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="py"&gt;c:&lt;/span&gt;&lt;span class="k"&gt;Case&lt;/span&gt; &lt;span class="ss"&gt;{&lt;/span&gt;&lt;span class="py"&gt;id:&lt;/span&gt; &lt;span class="n"&gt;$case_id&lt;/span&gt;&lt;span class="ss"&gt;}),&lt;/span&gt; &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="py"&gt;a:&lt;/span&gt;&lt;span class="n"&gt;Account&lt;/span&gt; &lt;span class="ss"&gt;{&lt;/span&gt;&lt;span class="py"&gt;id:&lt;/span&gt; &lt;span class="n"&gt;$account_id&lt;/span&gt;&lt;span class="ss"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;$account_id&lt;/span&gt; &lt;span class="ow"&gt;IN&lt;/span&gt; &lt;span class="n"&gt;c.proposed_freezes&lt;/span&gt; &lt;span class="ow"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;a.status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'active'&lt;/span&gt;
&lt;span class="k"&gt;SET&lt;/span&gt; &lt;span class="n"&gt;a.status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'frozen'&lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="ss"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;:ACTION&lt;/span&gt; &lt;span class="ss"&gt;{&lt;/span&gt;&lt;span class="py"&gt;type:&lt;/span&gt; &lt;span class="s1"&gt;'freeze'&lt;/span&gt;&lt;span class="ss"&gt;,&lt;/span&gt; &lt;span class="py"&gt;ts:&lt;/span&gt; &lt;span class="n"&gt;$now&lt;/span&gt;&lt;span class="ss"&gt;,&lt;/span&gt; &lt;span class="py"&gt;approved_by:&lt;/span&gt; &lt;span class="n"&gt;$approved_by&lt;/span&gt;&lt;span class="ss"&gt;,&lt;/span&gt; &lt;span class="py"&gt;reason:&lt;/span&gt; &lt;span class="n"&gt;$reason&lt;/span&gt;&lt;span class="ss"&gt;}]&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Verify counts open money routes&lt;/strong&gt; into the ring's end account that avoid every frozen account:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cypher"&gt;&lt;code&gt;&lt;span class="k"&gt;MATCH&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="py"&gt;src:&lt;/span&gt;&lt;span class="n"&gt;Account&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="ss"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;:SENT&lt;/span&gt;&lt;span class="ss"&gt;]&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="py"&gt;m:&lt;/span&gt;&lt;span class="n"&gt;Account&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="ss"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;:SENT&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="o"&gt;..&lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="ss"&gt;]&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="py"&gt;t:&lt;/span&gt;&lt;span class="n"&gt;Account&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;m.id&lt;/span&gt; &lt;span class="ow"&gt;IN&lt;/span&gt; &lt;span class="n"&gt;$ring&lt;/span&gt; &lt;span class="ow"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;t.id&lt;/span&gt; &lt;span class="ow"&gt;IN&lt;/span&gt; &lt;span class="n"&gt;$terminals&lt;/span&gt; &lt;span class="ow"&gt;AND&lt;/span&gt; &lt;span class="ow"&gt;NOT&lt;/span&gt; &lt;span class="n"&gt;src.id&lt;/span&gt; &lt;span class="ow"&gt;IN&lt;/span&gt; &lt;span class="n"&gt;$ring&lt;/span&gt;
  &lt;span class="ow"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;none&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="ow"&gt;IN&lt;/span&gt; &lt;span class="nf"&gt;nodes&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;n.status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'frozen'&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;RETURN&lt;/span&gt; &lt;span class="nf"&gt;count&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="k"&gt;DISTINCT&lt;/span&gt; &lt;span class="ss"&gt;[&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="ow"&gt;IN&lt;/span&gt; &lt;span class="nf"&gt;nodes&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;n.id&lt;/span&gt;&lt;span class="ss"&gt;])&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;routes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;It counts distinct routes, not raw paths.&lt;/strong&gt; Each transaction is its own edge, so split payments multiply paths: Ring A has 1,488 raw paths but 13 distinct routes. After the freeze: 0.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A leak check stops the proof from fooling itself.&lt;/strong&gt; It counts ring money that already reached an active account the case never named. The cut-off counts as verified only when routes and leaks are both 0.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Alerts close themselves from graph state.&lt;/strong&gt; Each alert shows Open, Awaiting approval, Closed, Needs review, Monitoring or Dismissed, derived from its latest case.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A report is generated from graph data only:&lt;/strong&gt; accounts and roles, the agent's evidence, every approved action with approver and time, and the live verify result.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Safety: an agent that writes Cypher on untrusted data
&lt;/h2&gt;

&lt;p&gt;The agent reads text it cannot trust and writes queries, so safety lives in code, not in the prompt.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Reads physically cannot write.&lt;/strong&gt; Every read tool runs as &lt;code&gt;GRAPH.RO_QUERY&lt;/code&gt;, so FalkorDB itself refuses any write. A test bypasses our own guard and confirms the database still blocks it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Free-form Cypher passes a guard&lt;/strong&gt; (&lt;code&gt;guard.js&lt;/code&gt;): it rejects &lt;code&gt;CREATE&lt;/code&gt;, &lt;code&gt;MERGE&lt;/code&gt;, &lt;code&gt;DELETE&lt;/code&gt;, &lt;code&gt;SET&lt;/code&gt;, &lt;code&gt;REMOVE&lt;/code&gt;, &lt;code&gt;DROP&lt;/code&gt;, &lt;code&gt;CALL&lt;/code&gt;, &lt;code&gt;LOAD&lt;/code&gt;, &lt;code&gt;FOREACH&lt;/code&gt; and multiple statements, enforces a &lt;code&gt;LIMIT&lt;/code&gt; of at most 100, and runs with a server-side timeout.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Every query is parameterized.&lt;/strong&gt; Values arrive as &lt;code&gt;$parameters&lt;/code&gt;, never spliced into query text, including the seed script.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Verdicts are grounded.&lt;/strong&gt; The validator rejects ring members no tool returned, freezes on victims or non-members, and any freeze on a verdict weaker than &lt;code&gt;ring_confirmed&lt;/code&gt;. An invalid verdict gets one retry.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Graph text is data.&lt;/strong&gt; Holder names, UPI handles and alert text are marked untrusted in the system prompt. Even a successful prompt injection could not freeze anything: the model has no action tools.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hard limits per run:&lt;/strong&gt; 10 model steps, a 10-minute timeout, a 120K-token cap, and one investigation at a time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Public demo hygiene:&lt;/strong&gt; investigations and approvals need a demo passcode, resetting the graph needs an admin secret, both compared in constant time. No secrets in the repo.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Built to run on a free tier
&lt;/h2&gt;

&lt;p&gt;The whole project runs on Groq's free tier: about 8K tokens per minute and 200K tokens per day, per model. The agent loop is designed around that.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Compact tool results.&lt;/strong&gt; Tools return summaries and distinct transactions, not hundreds of near-duplicate paths.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Context trimming.&lt;/strong&gt; Once the prompt passes about 5.5K tokens, older tool results shrink to their one-line summaries.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Model fallback mid-run.&lt;/strong&gt; When the main model's daily quota runs out, the loop switches to the fallback model and continues from the same step. The trace shows the switch.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Self-adjusting requests.&lt;/strong&gt; If a model rejects a request as too large (Qwen allows 7K input and 1K output tokens per minute), the loop trims the context or lowers the output cap and redoes the step.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Malformed tool calls are retried with a hint&lt;/strong&gt; to send shorter arguments, so a truncated verdict does not fail the same way twice.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The report is a template, not LLM prose.&lt;/strong&gt; It costs zero tokens and can only contain facts that are in the graph.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost of one investigation:&lt;/strong&gt; roughly 18K to 35K tokens and 1 to 5 minutes, almost all of it waiting on rate limits. The graph queries are a rounding error.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What fought back
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The proof could fool itself.&lt;/strong&gt; In the final test the agent stopped at the collector and missed the cash-out account, which still held Rs 65,202. Verify still said "11 routes → 0". The route count only looks at paths through the case's own members, so freezing everything proposed always gives 0. The fix: a leak check that asks whether ring money already sits in an active account the case never named. That run now reads "Routes cut, but money leaked" instead of a false pass.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;One transaction, one edge, hundreds of paths.&lt;/strong&gt; Split payments multiply paths fast: 1,488 raw paths for 13 real routes. Counting distinct sequences of account IDs (&lt;code&gt;count(DISTINCT [n IN nodes(p) | n.id])&lt;/code&gt;) made the number something a reviewer can read.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Some things cannot be Cypher parameters.&lt;/strong&gt; Edge direction, variable-length bounds and labels cannot be &lt;code&gt;$params&lt;/code&gt;. &lt;code&gt;money_trail&lt;/code&gt; pre-builds one query per (direction, hops) pair from constants, so user input never becomes query text.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Epoch milliseconds vs date strings.&lt;/strong&gt; The agent compared &lt;code&gt;ts&lt;/code&gt; to &lt;code&gt;'2026-10-07'&lt;/code&gt; in free-form Cypher and got empty results. The tool description now says times are epoch ms.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Free-tier walls.&lt;/strong&gt; A daily quota that runs out mid-investigation, a fallback model with 1K output tokens per minute, and verdicts cut off mid-word (&lt;code&gt;tool_use_failed&lt;/code&gt;). Each became a handled case in the loop, with a test that replays the real error.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prompting is not free.&lt;/strong&gt; Telling the agent to also trace forward from the collector raised Ring A recall from 0.57 to 0.71. A stricter "run both trails" rule made it loop until the step cap, so it was dropped. Every prompt change was measured, not assumed.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;&lt;code&gt;npm run eval&lt;/code&gt; runs the agent on all 7 alerts and scores it against a ground-truth file. &lt;strong&gt;7 of 7 verdicts correct, 0 unsafe freezes&lt;/strong&gt;: no victim, merchant or family account was ever recommended for freezing.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Alert&lt;/th&gt;
&lt;th&gt;Scenario&lt;/th&gt;
&lt;th&gt;Expected&lt;/th&gt;
&lt;th&gt;Got&lt;/th&gt;
&lt;th&gt;Freeze precision / recall&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;ALT001&lt;/td&gt;
&lt;td&gt;Ring A complaint&lt;/td&gt;
&lt;td&gt;ring_confirmed&lt;/td&gt;
&lt;td&gt;ring_confirmed&lt;/td&gt;
&lt;td&gt;1.00 / 0.71&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ALT002&lt;/td&gt;
&lt;td&gt;Ring B complaint&lt;/td&gt;
&lt;td&gt;ring_confirmed&lt;/td&gt;
&lt;td&gt;ring_confirmed&lt;/td&gt;
&lt;td&gt;1.00 / 1.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ALT003&lt;/td&gt;
&lt;td&gt;Ring B fan-in&lt;/td&gt;
&lt;td&gt;ring_confirmed&lt;/td&gt;
&lt;td&gt;ring_confirmed&lt;/td&gt;
&lt;td&gt;1.00 / 1.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ALT004&lt;/td&gt;
&lt;td&gt;Ring C decoy&lt;/td&gt;
&lt;td&gt;suspicious&lt;/td&gt;
&lt;td&gt;suspicious, no freeze&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ALT005&lt;/td&gt;
&lt;td&gt;Merchant&lt;/td&gt;
&lt;td&gt;benign&lt;/td&gt;
&lt;td&gt;benign&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ALT006&lt;/td&gt;
&lt;td&gt;Family&lt;/td&gt;
&lt;td&gt;benign&lt;/td&gt;
&lt;td&gt;benign&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ALT007&lt;/td&gt;
&lt;td&gt;Noise&lt;/td&gt;
&lt;td&gt;benign&lt;/td&gt;
&lt;td&gt;benign&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Live run on the deployed site:&lt;/strong&gt; Ring A's complaint named all 8 accounts (the victim plus all 7 mules, including the cash-out); after approval, verify went from 13 open routes to 0 with no leak, and the alert closed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;53 automated tests:&lt;/strong&gt; the Cypher guard, the read-only backstop, the approval gate, verify and the leak check, the passcode, verdict validation, and every free-tier failure mode, replayed with a fake LLM client so they cost no tokens.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The dashboard:&lt;/strong&gt; an alert queue with live status, the graph canvas with role-colored rings and a step-by-step HUD, the agent trace with each step's Cypher, the verdict card with a confidence meter and run stats, and a before/after proof card.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9nm3wl7xbz22hdo7b3p1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9nm3wl7xbz22hdo7b3p1.png" alt=" " width="800" height="438"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The live demo after approval: Ring A frozen (red) with roles on the canvas, each proposed freeze and its reason, and the proof card: 13 open routes before the freeze, 0 after, no leak.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Who this is for
&lt;/h2&gt;

&lt;p&gt;Fraud and risk teams at banks, payment apps and UPI providers who already get alerts but spend hours tracing each one by hand. It is also a pattern for anyone building agents that act on data: let the model read and recommend, keep writes behind a human and a single audited query, and end every action with a query that proves it worked.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Graphs make the question short.&lt;/strong&gt; "Where did this money go, four hops out, after Tuesday?" is one Cypher pattern, not four joins.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Put safety in the database, not the prompt.&lt;/strong&gt; &lt;code&gt;GRAPH.RO_QUERY&lt;/code&gt; is a stronger guarantee than any instruction to "only read".&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Verify the verifier.&lt;/strong&gt; A proof that only checks the agent's own case can pass while money sits in an account the agent missed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Give the model less, not more.&lt;/strong&gt; Compact tool results, one-line summaries and a short required checklist beat long instructions on a small token budget.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Measure every prompt change.&lt;/strong&gt; A rule that sounded better made the agent worse; only the eval showed it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What's next
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Upstream leak detection:&lt;/strong&gt; flag a missed mule that feeds money into the ring, not only one that receives from it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Streaming ingestion:&lt;/strong&gt; real-time transaction feeds into FalkorDB, so investigations start the moment a pattern appears.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real integrations:&lt;/strong&gt; bank and UPI freeze APIs behind the same approval gate.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;Needs Node.js 22.9+, Docker and a free Groq API key.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/Jeevesh2605/ringbreaker &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd &lt;/span&gt;ringbreaker
&lt;span class="nb"&gt;cp&lt;/span&gt; .env.example .env               &lt;span class="c"&gt;# add GROQ_API_KEY&lt;/span&gt;
docker compose up &lt;span class="nt"&gt;-d&lt;/span&gt;               &lt;span class="c"&gt;# FalkorDB on :6379, Browser on http://localhost:3000&lt;/span&gt;
&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;server &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; npm &lt;span class="nb"&gt;install&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;web &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; npm &lt;span class="nb"&gt;install&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
npm run generate &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; npm run seed   &lt;span class="c"&gt;# seeded synthetic graph into FalkorDB&lt;/span&gt;
&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;server &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; npm start&lt;span class="o"&gt;)&lt;/span&gt;           &lt;span class="c"&gt;# API on http://localhost:8080&lt;/span&gt;
&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;web &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; npm run dev&lt;span class="o"&gt;)&lt;/span&gt;            &lt;span class="c"&gt;# UI on http://localhost:5173&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open the UI, click ALT001, approve the freeze, and watch the open routes drop to 0.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disclosures:&lt;/strong&gt; all data is synthetic; no real people, accounts or UPI handles. Built with help from an AI coding assistant; I reviewed the code and can explain every part of the architecture and its safety model.&lt;/p&gt;

&lt;p&gt;Built for &lt;strong&gt;Graph Hacks: Context for AI Agents&lt;/strong&gt; by FalkorDB, Track 01. &lt;strong&gt;Live demo:&lt;/strong&gt; &lt;a href="https://ringbreaker-5o88.onrender.com" rel="noopener noreferrer"&gt;ringbreaker-5o88.onrender.com&lt;/a&gt; · &lt;strong&gt;Code:&lt;/strong&gt; &lt;a href="https://github.com/Jeevesh2605/ringbreaker" rel="noopener noreferrer"&gt;github.com/Jeevesh2605/ringbreaker&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>database</category>
      <category>falkordb</category>
      <category>wemakedevs</category>
    </item>
  </channel>
</rss>
