<?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: Gerson Tolentino Andrade</title>
    <description>The latest articles on DEV Community by Gerson Tolentino Andrade (@gersontolentinoa).</description>
    <link>https://dev.to/gersontolentinoa</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%2F4057060%2Fb465b0e2-a0d1-48f2-8f07-87e1d977af1e.jpg</url>
      <title>DEV Community: Gerson Tolentino Andrade</title>
      <link>https://dev.to/gersontolentinoa</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gersontolentinoa"/>
    <language>en</language>
    <item>
      <title>Your AI agent failed at step 3 of 5. Now what?</title>
      <dc:creator>Gerson Tolentino Andrade</dc:creator>
      <pubDate>Fri, 31 Jul 2026 18:29:07 +0000</pubDate>
      <link>https://dev.to/gersontolentinoa/your-ai-agent-failed-at-step-3-of-5-now-what-4f5g</link>
      <guid>https://dev.to/gersontolentinoa/your-ai-agent-failed-at-step-3-of-5-now-what-4f5g</guid>
      <description>&lt;p&gt;AI agents stopped just &lt;em&gt;talking&lt;/em&gt;. They now &lt;em&gt;do things&lt;/em&gt; — through tools: create a database user, send an email, charge a card, drop a table. That's the whole point of the &lt;a href="https://modelcontextprotocol.io" rel="noopener noreferrer"&gt;Model Context Protocol (MCP)&lt;/a&gt;: a universal way to hand real tools to an AI.&lt;/p&gt;

&lt;p&gt;It's powerful. It's also a little terrifying.&lt;/p&gt;

&lt;p&gt;In July 2025, an AI coding agent famously &lt;strong&gt;deleted a company's production database&lt;/strong&gt;. Name-based confusion — &lt;code&gt;prod&lt;/code&gt; vs &lt;code&gt;staging&lt;/code&gt; — is exactly the kind of mistake a fast, confident, tool-wielding agent makes. And here's the uncomfortable part: in a multi-step task, when step 4 fails, steps 1–3 are &lt;strong&gt;already committed&lt;/strong&gt; in real systems. There's no &lt;code&gt;Ctrl+Z&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Orchestrators (Temporal, Restate, LangGraph) solve this &lt;strong&gt;inside your own workflow code&lt;/strong&gt;. But there was no &lt;strong&gt;declarative, protocol-level&lt;/strong&gt; way for an MCP server to say: &lt;em&gt;"this tool is mutating, and its inverse is that other tool, with these parameters."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So I built one. It's called &lt;strong&gt;ChronoMCP&lt;/strong&gt;, it's MIT-licensed, and it's a single &lt;code&gt;npm install&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The idea: a transparent guard between the agent and the world
&lt;/h2&gt;

&lt;p&gt;ChronoMCP is a proxy that sits between &lt;strong&gt;any&lt;/strong&gt; MCP client and &lt;strong&gt;any&lt;/strong&gt; MCP server. Point your client at it and everything passes through unchanged — until a tool call is risky. Then it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Classifies&lt;/strong&gt; every call as &lt;code&gt;read&lt;/code&gt; / &lt;code&gt;mutating&lt;/code&gt; / &lt;code&gt;destructive&lt;/code&gt; (conservative by default: unknown = treated as mutating).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Shows a human-readable impact diff&lt;/strong&gt; before anything runs — and flags PRODUCTION and irreversible actions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gates mutations on human approval&lt;/strong&gt; (terminal prompt, policy, or a remote control plane like Slack).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rolls back on failure&lt;/strong&gt; with a LIFO saga — deterministically.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hash-chains an audit log&lt;/strong&gt; anyone can verify.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The heart of it: declarative, honest compensation
&lt;/h2&gt;

&lt;p&gt;A server declares, per tool, &lt;em&gt;how to undo it&lt;/em&gt; — via an open extension, &lt;code&gt;mcp-compensate&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json-doc"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"create_record"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"_meta"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"dev.chronomcp/compensate"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"reversibility"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"compensable"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;          &lt;/span&gt;&lt;span class="c1"&gt;// "readonly" | "compensable" | "irreversible"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"compensation"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"toolName"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"delete_record"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"parameterMapping"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"$.output.structuredContent.id"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;// static path only&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now guard the server and turn on saga mode:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; chronomcp
chronomcp guard &lt;span class="nt"&gt;--mode&lt;/span&gt; gate &lt;span class="nt"&gt;--saga&lt;/span&gt; &lt;span class="nt"&gt;--&lt;/span&gt; node examples/server-demo/server.mjs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the agent runs &lt;code&gt;create_record&lt;/code&gt; (OK) then &lt;code&gt;charge_payment&lt;/code&gt; (fails), ChronoMCP walks the completed steps &lt;strong&gt;backwards&lt;/strong&gt; and compensates them &lt;strong&gt;before&lt;/strong&gt; the agent even sees the error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;! ChronoMCP: 'charge_payment' failed — starting rollback of 1 step(s)…
  ✓ create_record: compensated (via delete_record)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Two design decisions I'd defend to the death
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;No LLM in the rollback path.&lt;/strong&gt; The compensating tool and its parameters are &lt;em&gt;static declarations&lt;/em&gt;. Why? Because the moment of "undo" is exactly where a prompt-injected agent would love to improvise ("while you're at it, delete this too"). A deterministic rollback can't be talked into anything.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Compensation ≠ undo, and we say so.&lt;/strong&gt; A sent email cannot be un-sent; a settled payment isn't reversed by a refund. ChronoMCP never &lt;em&gt;pretends&lt;/em&gt;. Irreversible steps are declared and flagged &lt;strong&gt;before&lt;/strong&gt; you approve — not as a surprise after a failure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;│ [DANGER] db-mcp → drop_table
│   table: customers_prod        ← a human catches this in one second
│ reversible: NO — IRREVERSIBLE effect declared by the server
Approve? [y/N]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That honesty is the feature, not a limitation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why "protocol-level" matters
&lt;/h2&gt;

&lt;p&gt;Because it works with &lt;strong&gt;any&lt;/strong&gt; MCP server without rewriting your agent, and it's transparent — clients that ignore the metadata keep working. It's the seatbelt you add &lt;em&gt;in front of&lt;/em&gt; whatever you already built, not a framework you rebuild on top of. (I wrote a full, honest &lt;a href="https://chronomcp.dev/compare/" rel="noopener noreferrer"&gt;comparison vs. orchestrators&lt;/a&gt; — they're usually complementary.)&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/chronomcp/chronomcp" rel="noopener noreferrer"&gt;https://github.com/chronomcp/chronomcp&lt;/a&gt; (spec + zero-dependency CLI + demo server, 70 tests)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;npm:&lt;/strong&gt; &lt;code&gt;npm install -g chronomcp&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Site + guide:&lt;/strong&gt; &lt;a href="https://chronomcp.dev" rel="noopener noreferrer"&gt;https://chronomcp.dev&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;code&gt;mcp-compensate&lt;/code&gt; spec is a community draft headed for the MCP SEP process. If you author MCP servers, &lt;strong&gt;I'd genuinely love the harsh feedback&lt;/strong&gt; — especially if this vocabulary doesn't fit your tools. Open an issue and let me know where it breaks.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>opensource</category>
      <category>showdev</category>
      <category>typescript</category>
    </item>
  </channel>
</rss>
