ai newsSo., 1. Nov.
EilmeldungClaude Code's Safety Telemetry Event Lived Six Days. Audit Your Agents With Git

Undo for AI agents: a draft spec for taking back what an agent already did

A sales agent is tidying up the Q4 pipeline. It marks deal D-881 as Won in the CRM, books a kickoff meeting with the customer, and emails their buyer a welcome note. An hour later you notice it picked the wrong deal. The customer hasn't signed. To clean up, you open three systems, work out what cha

dev.toSonntag 02:50 · 01.11.3 Min. Lesezeit
Bild: dev.to

A sales agent is tidying up the Q4 pipeline. It marks deal D-881 as Won in the CRM, books a kickoff meeting with the customer, and emails their buyer a welcome note. An hour later you notice it picked the wrong deal. The customer hasn't signed.

To clean up, you open three systems, work out what changed, put back the deal stage (unless a colleague has edited it since), cancel the meeting (which tells the attendees), and accept that the email has gone.

In my last post I described HATP, a draft protocol that makes multi-step agent actions all-or-nothing before they happen: plan, prepare, get a human's signed approval, then commit. Your comments on that post shaped most of v0.2, so thank you.

But most agents don't plan. They call one tool at a time, and you find out afterwards. So for v0.3 I've drafted the other half: the Journal, undo for agents. Nothing is built yet. I'd like your opinion before we start.

A Recorder sits between the agent and its tool servers, usually an MCP gateway. The agent needs no changes. When a tool server supports the journal, its normal tool result carries three extra things: what changed, a token to reverse it, and how long reversal stays possible.

"_meta": { "hatp/journal": { "undo": { "kind": "compensate", "undoBy": "2026-11-07T14:02:10Z" }, "compensationToken": "ctk_9QwX…", "effect": { "summary": "Deal D-881 stage: Proposal → Won", "resource": "crm://acme/deal/D-881", "version": "v13" }, "receipt": { "…": "signed by the CRM" } } } Enter fullscreen mode Exit fullscreen mode The tool server writes the summary from the actual change, not from the agent's text, because a human reads it later when deciding what to undo. The Recorder chains every entry into a signed, hash-chained Run Record.

Tool servers that know nothing about HATP still get journaled. Their calls are recorded as unknown and treated as irreversible. So it works with any MCP server on day one, and gets better as servers add undo.

Each operation declares up front whether it can be undone:

Once every operation says whether it can be undone, you can stop asking "should this agent be allowed to act?" and ask "can we take it back if it's wrong?"

{ "autonomy": { "compensate": "allow", "unknown": "ask", "none": "ask", "approver": "human://acme.com/role/team-lead" } } Enter fullscreen mode Exit fullscreen mode The agent acts freely on anything reversible. Before anything irreversible, the Recorder doesn't forward the call: it runs it as a normal HATP transaction with a human approval, so the email goes out only after someone signs off. Your organisation sets this policy, not the agent, and the agent can't change it.

Reversing work can destroy someone's newer edits or notify people outside the company, so a reversal goes through approval like any other risky action.

You ask to undo the run "from step 2 onwards". The Recorder then:

Between the agent's change and your undo, Eve may have moved the deal to "Negotiation". Blindly restoring "Proposal" would wipe out her change.

So every compensation carries ifVersion: the version the agent left behind ( v13 ). If the record has changed since, the tool server refuses with UNDO_CONFLICT and says what changed. The approval screen then shows the conflict, and only a human can choose to overwrite it.

HATP v0.1 compensates only when a transaction fails partway. With the Journal, a coordinator records a committed transaction as a run, so the same tokens can reverse it later: "that trip committed fine, but it was the wrong week."

Spec and SDK: https://github.com/probita-ai/hatp. Comments here or issues on GitHub are both welcome.

Quelle: dev.to (dev.to). Original öffnen