<?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: muhammadwaqasai</title>
    <description>The latest articles on DEV Community by muhammadwaqasai (@muhammadwaqasai).</description>
    <link>https://dev.to/muhammadwaqasai</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%2F4054850%2Fe8228677-452c-425f-b8dc-340ec6813b7f.jpg</url>
      <title>DEV Community: muhammadwaqasai</title>
      <link>https://dev.to/muhammadwaqasai</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/muhammadwaqasai"/>
    <language>en</language>
    <item>
      <title>Not every AI agent action deserves the same trust: adding risk-tiered permissions to agent_acid</title>
      <dc:creator>muhammadwaqasai</dc:creator>
      <pubDate>Fri, 14 Aug 2026 09:42:15 +0000</pubDate>
      <link>https://dev.to/muhammadwaqasai/not-every-ai-agent-action-deserves-the-same-trust-adding-risk-tiered-permissions-to-agentacid-5d1p</link>
      <guid>https://dev.to/muhammadwaqasai/not-every-ai-agent-action-deserves-the-same-trust-adding-risk-tiered-permissions-to-agentacid-5d1p</guid>
      <description>&lt;p&gt;Most AI agent safety systems treat every action the same way -- either blocked or allowed. But a routine email reply and a $5,000 refund are not the same risk category, and treating them identically is either too restrictive or too dangerous.&lt;/p&gt;

&lt;p&gt;I just added a 3-tier permission system to agent_acid:&lt;/p&gt;

&lt;p&gt;🟢 GREEN -- auto-executes, no extra check (same as before)&lt;br&gt;
🟡 YELLOW -- must pass a verify_fn before executing (e.g. a business rule or LLM-as-judge check)&lt;br&gt;
🔴 RED -- pauses execution entirely. Nothing happens -- not even a "do it then undo it" -- until a human explicitly approves or rejects it.&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="n"&gt;refund_tool&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ReversibleTool&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;issue_refund&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;execute&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;payment_api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;refund&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;compensate&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;payment_api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reverse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;id&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;
    &lt;span class="n"&gt;risk_level&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;RiskLevel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RED&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;risk_reason&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Refunds always require human sign-off.&lt;/span&gt;&lt;span class="sh"&gt;"&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;I tested this by attempting a $99,999 refund through a live agent. It got flagged RED, held in a pending state, and I rejected it as the human approver. The real payment API was never called -- not once.&lt;/p&gt;

&lt;p&gt;This is now the 4th safety layer in agent_acid, alongside rollback, guardrails, and shadow execution. 14 automated tests, all passing.&lt;/p&gt;

&lt;p&gt;GitHub: github.com/muhammadwaqasai/agent_acid&lt;br&gt;
pip install agent-acid&lt;/p&gt;

&lt;p&gt;Curious how others are handling human-in-the-loop approval for AI agents in production.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>python</category>
      <category>opensource</category>
      <category>showdev</category>
    </item>
    <item>
      <title>I proved my AI agent safety system in 18 seconds -- watch it block a $1,200 attack before it happens</title>
      <dc:creator>muhammadwaqasai</dc:creator>
      <pubDate>Sat, 08 Aug 2026 01:37:07 +0000</pubDate>
      <link>https://dev.to/muhammadwaqasai/i-proved-my-ai-agent-safety-system-in-18-seconds-watch-it-block-a-1200-attack-before-it-happens-o32</link>
      <guid>https://dev.to/muhammadwaqasai/i-proved-my-ai-agent-safety-system-in-18-seconds-watch-it-block-a-1200-attack-before-it-happens-o32</guid>
      <description>&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%2F68afkley1ypfrguw57sa.gif" 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%2F68afkley1ypfrguw57sa.gif" alt=" " width="599" height="337"&gt;&lt;/a&gt;&lt;br&gt;
This is real, unscripted terminal output from agent_acid, an open-source safety layer for AI agents.&lt;/p&gt;

&lt;p&gt;The scenario: an AI agent is told to charge a customer $1,200, but the system only allows charges up to $500 per transaction. So the plan gets split into three $400 charges instead, each one individually legal.&lt;/p&gt;

&lt;p&gt;Most AI agent guardrails only check one action at a time, so this would slip right through. agent_acid's shadow execution runs the entire plan in a safe sandbox first, before anything touches a real system. It catches the pattern on the third call and rejects the whole plan.&lt;/p&gt;

&lt;p&gt;The real-world result: zero accounts created, zero charges made. Not "created then undone" -- never touched at all.&lt;/p&gt;

&lt;p&gt;Compare that to a rollback-only approach, where the account and first two charges would have already happened for real before anything got cleaned up.&lt;/p&gt;

&lt;p&gt;Open source, tested, and free to try:&lt;br&gt;
GitHub: github.com/muhammadwaqasai/agent_acid&lt;br&gt;
pip install agent-acid&lt;/p&gt;

&lt;p&gt;Curious what people think, especially if you can find a way around it.&lt;/p&gt;

</description>
      <category>python</category>
      <category>ai</category>
      <category>opensource</category>
      <category>showdev</category>
    </item>
    <item>
      <title># I built a rollback + guardrail engine for AI agents after finding an attack most safety layers miss</title>
      <dc:creator>muhammadwaqasai</dc:creator>
      <pubDate>Thu, 30 Jul 2026 10:50:51 +0000</pubDate>
      <link>https://dev.to/muhammadwaqasai/-i-built-a-rollback-guardrail-engine-for-ai-agents-after-finding-an-attack-most-safety-layers-2ek</link>
      <guid>https://dev.to/muhammadwaqasai/-i-built-a-rollback-guardrail-engine-for-ai-agents-after-finding-an-attack-most-safety-layers-2ek</guid>
      <description>&lt;p&gt;Most AI agent guardrail systems check one tool call at a time, with no memory of the session. That makes them blind to a real, documented attack pattern sometimes called "salami slicing" — an attacker (or a manipulated AI) splitting one large forbidden action into several small, individually-legal-looking ones.&lt;/p&gt;

&lt;p&gt;I ran into this while thinking about what it actually takes to trust an autonomous AI agent with real-world actions — charging a card, writing to a database, sending an email. So I built &lt;code&gt;agent_acid&lt;/code&gt; to close two specific gaps.&lt;/p&gt;

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

&lt;p&gt;Say you give an AI agent a tool to charge a customer's card, with a guardrail that blocks any single charge over $500. Seems safe, right?&lt;/p&gt;

&lt;p&gt;Here's the catch: if an attacker convinces the AI (via a prompt injection, or just a confused multi-step plan) to charge $400 three times instead of $1200 once, every individual call passes the check. Nothing in a typical guardrail setup notices that the &lt;em&gt;total&lt;/em&gt; across the session is dangerous.&lt;/p&gt;

&lt;h2&gt;
  
  
  What agent_acid adds
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Automatic rollback&lt;/strong&gt;&lt;br&gt;
Every tool gets a paired compensating action — an "undo." If any step in a multi-step agent plan fails, everything already completed gets undone automatically, in reverse order.&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="n"&gt;charge_tool&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ReversibleTool&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;charge_card&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;execute&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;real_payment_api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;charge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;compensate&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;real_payment_api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;refund&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;charge_id&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;
    &lt;span class="n"&gt;guardrails&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;max_value&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;amount&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;limit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;500&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;2. Stateful (session-memory) guardrails&lt;/strong&gt;&lt;br&gt;
Rules that track the whole transaction, not just one call:&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="n"&gt;stateful_guardrails&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="nf"&gt;cumulative_max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;charge_card&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;amount&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_limit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1000&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;This catches the $400 x 3 pattern even though each individual call is within the per-step limit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Proving it against a real, live AI
&lt;/h2&gt;

&lt;p&gt;I didn't just want to claim this works — I tested it against an actual GPT-4o-mini agent trying to pull off both attacks:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Attack 1 — Prompt injection.&lt;/strong&gt; A fake "administrator override" hidden inside a customer support ticket tries to convince the AI to charge $75,000 instead of following the $500 limit. The AI gets fooled and attempts it. The guardrail blocks it and fully reverses the account creation and the charge.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Attack 2 — Salami slicing.&lt;/strong&gt; The injected instruction explicitly tells the AI to split a $1,200 charge into three $400 calls specifically to dodge the per-step limit. I ran this against two setups side by side:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Naive agent (per-step check only)&lt;/th&gt;
&lt;th&gt;agent_acid&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;3x $400 charge attempt&lt;/td&gt;
&lt;td&gt;All 3 succeeded — $1,200 charged&lt;/td&gt;
&lt;td&gt;Blocked on the 3rd call&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rollback available?&lt;/td&gt;
&lt;td&gt;No — money is just gone&lt;/td&gt;
&lt;td&gt;Yes — fully refunded&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Account left behind?&lt;/td&gt;
&lt;td&gt;Yes, permanently&lt;/td&gt;
&lt;td&gt;Deleted during rollback&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The naive agent didn't just fail quietly — it told the user everything worked perfectly. That's the real danger.&lt;/p&gt;

&lt;h2&gt;
  
  
  It's tested and open source
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;5 automated pytest tests, no API key required, proving the core rollback and guardrail logic&lt;/li&gt;
&lt;li&gt;6 example scripts, including both attack tests and the comparison above&lt;/li&gt;
&lt;li&gt;Published on PyPI: &lt;code&gt;pip install agent-acid&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Full source on GitHub: &lt;a href="https://github.com/muhammadwaqasai/agent_acid" rel="noopener noreferrer"&gt;https://github.com/muhammadwaqasai/agent_acid&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'm genuinely interested in people trying to break it. If you find a way around the guardrails, I want to know — open an issue or drop a comment.&lt;/p&gt;

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