AuditService.logEvent(). Mutating actions also capture a before-state snapshot for 7 days, after which the snapshot is purged (the audit entry stays forever).
What is audit-logged
NewAuditAction values added by the agents feature:
All entries appear in the existing Recent Activity UI alongside human actions, filterable by
actor.type=agent.
The 7-day undo window
Mutating tool calls populateagent_undo_snapshot.before_state_json before dispatch via a Snapshottable interface implemented per affected service. The snapshot includes everything needed to restore: the entity’s full state at the time of the change, with a currentAfter field captured at undo time for drift detection.
What’s undoable
Using the Undo Center
/workspace/agent-undo (UI) or GET /api/v1/workspaces/{wid}/agent-undo (API). The table sorts by expires_at asc so soonest-to-expire is on top.
1
Pick an action
Click a row to see the before / after diff modal.
2
Click Undo
The runtime captures the current state, compares it to the snapshot, and applies the before-state.
3
Drift detection
If a human changed the same entity since the agent acted, the modal shows “Manual change detected — review before undoing” with a three-way diff. You can proceed anyway or cancel.
Drift-conflict modal
Whencurrent ≠ after, the runtime returns MERGE_CONFLICT (HTTP 409) from the undo endpoint. The UI surfaces:
- Snapshot’s before state
- Snapshot’s recorded after state
- Current actual state
- A two-button choice: Proceed anyway (apply before-state, drop intermediate change) or Cancel.
AGENT_UNDO_APPLIED audit entry with the mergeConflict=true flag.
Authorization
Snapshot retention
AgentUndoSnapshotPurger runs daily and drops snapshots where expires_at < now(). The corresponding audit entries remain — only the snapshot payload is purged.
API
POST .../undo:
200— applied cleanly.409—MERGE_CONFLICT(use?force=trueto override).410— snapshot expired (>7 days old).404— snapshot not found / already undone.
Related
- Agents overview — 7-day undo is part of trust by design.
- Rules and decisions — rule-set versions are audit-logged here.