Undo the last change an agent made

MaintenanceBeginner~5 minUpdated

Before you start

Plugin 1.11.2 or newer. List changes and Undo change are both off until you switch them on in the Abilities tab. Undo change is left out of the Read only, Content editor and Shop manager presets, so the connection needs the Custom preset. The agent can only undo changes its own connection made (the same OAuth app or Application Password) in the last 24 hours, up to 30 undo calls an hour. You need the post's ID, which is the number after post= in the editor's address bar, or the agent already has it from the work in the same chat.

An agent made an edit and you don’t like it. Maybe it rewrote a paragraph you wanted left alone, or set the wrong featured image, or created a page that should not exist. You want the last thing it did gone, without hunting through revisions or rewriting by hand.

If the edit came from one of the 25 tools that record their changes, the agent can take it back itself. This has it list what it changed, show you the candidates, and undo exactly one after you say yes.

The prompt
Undo the last change you made to post [123]. Read first and change nothing yet.
List the changes you made to that post in the last 24 hours, newest first. For
each one tell me the tool it came from, the fields it touched, when it
happened, and whether it can still be undone. If one cannot be undone, tell me
why.
Then stop and tell me which single change you think I mean, and wait for my
yes. Once I say yes, undo only that one change and tell me the outcome,
including any field that did not go back exactly. Then read the post and
confirm it looks the way it did before that change. Do not undo anything else,
and do not try to undo the undo.

Why this is safe to run

The first half is a read. Listing changes shows the tool, the field names and the time for each change, never the contents, so you see what would move before anything does. The agent sees only its own connection’s changes, and a connection with no recorded changes sees an empty list.

The write is one undo per call, by the change ID the listing gave. It puts back the earlier value of the fields that change touched, only if nothing else has edited them since. It also checks again that the connection may still make that edit, so a permission you took away after the change is respected. Undo change is a destructive tool, so it stays off until you enable it, it is limited to 30 calls an hour per connection, and every call lands in the Activity Log.

The limits are real. This covers edits to posts, pages and custom post types, creates, trashes, block edits, terms, custom fields, featured images and SEO fields. Orders, user accounts, uploads, comments, menus and tools from other plugins are not recorded, so there is nothing for the agent to undo there. You can revert the recorded ones yourself later from the Changes tab.

Already connected? Skip the paste. Ask your agent for the “undo the last change an agent made” recipe, or just tell it which post to take its last edit back from, and it runs the same list-confirm-undo flow on your own site.

How it works

  1. List the changes this connection made to the post in the last 24 hours, newest first.
  2. Show you each one: the tool, the fields it touched, the time, and whether it can still be undone.
  3. Wait for your yes on the one change to undo.
  4. Undo that single change and report the outcome, including any field that did not go back exactly.
  5. Read the post back so you can confirm it looks right.

Questions

Can the agent undo a change someone else made, or one from last week?
No. It sees only changes its own connection made, and only from the last 24 hours. Anything else is yours to revert from the Changes tab in wp-admin, which keeps changes for up to 30 days.
What if it says a change can't be undone?
The listing gives a reason with each change. Common ones are that the post was edited after the change, that 24 hours have passed, or that the connection no longer has permission to make that edit. A revert that would overwrite newer work is refused, and the Changes tab is the next stop.
Does it work on categories and tags too?
List changes takes a post or a term, so you can ask about a category the same way. This recipe is written for a post or page.
Does undoing recall an email or a webhook?
No. Notifications, webhooks and anything the agent already read are not recalled. Undo only puts the earlier field values back, and undoing a create moves the new item to the Trash.