Writing ·
How to validate an AI agent's persistent effects before commit
Specify approved changes independently, observe the candidate effects inside a controlled boundary, and commit only an exact match while gating retries and downstream work.
By Youssef Hemimy · agent safety · agent reliability · AgentOps
Do not treat an approved tool call or a successful response as proof that the resulting state is approved. For a consequential transactional operation, specify allowed durable changes independently of the agent, hold the candidate changes, observe effects within a declared boundary, and commit only when the result matches. Save the decision so retries and downstream work cannot turn an unresolved attempt into apparent success.
An allowed action can have an unapproved result
Imagine an agent asked to mark an invoice paid. A reviewer approves the invoice-status update, and the SQL command succeeds. A trigger also inserts an unapproved notification. Checking only the command or invoice row misses the extra write. The EffectMatch paper uses this example to separate call approval from persistent-outcome approval. Authorization still decides whether the action may be attempted; outcome validation decides whether it left only permitted changes. See how to bind an approval to an exact agent action.
01
Approve
Application names allowed durable effects independently of the agent.
02
Hold
Run the candidate in a controlled transaction; collect direct and induced writes.
03
Compare
Check the observed set against approval at a fixed granularity.
04
Decide
Exact → commit. Diverged or indeterminate → block and record.
Outside the held boundary: remote durable effects require readback and reconciliation, not a local rollback claim.
Name the three artifacts before execution
| Artifact | Owner and role |
|---|---|
| Approved effects | The application or task owner specifies permitted state transitions and what must remain unchanged from current business state. The agent's command is not independent approval. |
| Observed effects | A registered backend observer captures changes attributable to this attempt within an explicitly declared scope and comparison granularity. |
| Decision record | The runtime records exact, diverged, or indeterminate; that durable result controls commit, retry, and dependent work. |
EffectMatch models approved and observed outcomes as comparable collections of changes. EXACT means complete observed effects equal approved effects; DIVERGED means a complete observation differs; INDETERMINATE means completeness cannot be established. “Complete” is relative to the certified backend profile and granularity: a write-count comparison does not prove value-level correctness.
Put comparison before commit where the backend permits it
- Bind approval to this attempt. Record its source, target, relevant state and plan revision, expiry, and single execution occurrence. A changed invoice or reused approval needs another decision.
- Declare and check the effect boundary. Identify tables, triggers, functions, and dispatch routes that may persist a change. Cover or block each reachable route; an unknown route is not “no effect.” The paper's PostgreSQL prototype certifies a restricted, preregistered profile, not arbitrary database behavior.
- Hold and inspect the candidate. Execute in a private transaction where possible, collect direct and induced writes, and compare the result with approval at the chosen granularity. PostgreSQL transactions provide an all-or-nothing database unit; observation completeness requires additional machinery.
- Commit only an exact, current result. If the invoice update also inserted an unapproved notification, roll back the held transaction. If observation is incomplete, persist uncertainty and block dependent work until a named recovery path resolves it.
A transaction makes a group of writes atomic; it does not decide whether the group is authorized. A post-hoc final-state test may expose a defect but cannot prevent an already-completed commit. For that distinct testing decision, see evaluating stateful agent outcomes.
Remote effects need reconciliation, not fictional rollback
A payment, email, or service mutation may be durable before the agent receives its response. No local transaction automatically undoes it. EffectMatch's GitHub study reads back registered issue fields and gates local continuation, but does not attribute every remote effect or reverse the remote change.
Design the tool contract around stable request identity, bounded readback or reconciliation, and a durable unknown or diverged state that blocks dependent work. Microsoft's compensating-transaction guidance describes undoing completed distributed steps as application-specific work that must account for concurrent changes, not a simple snapshot restore.
What the evidence supports
EffectMatch reports preserving clean executions and rejecting tested incorrect commits in controlled comparisons. Its broader reference comparison includes 206 public business tasks; independently specified approvals cover a smaller set of business and PostgreSQL tasks. Ablations examine comparison, observation, execution binding, and durable continuation records. These are mechanism tests, not a production failure rate or proof that every hidden effect can be found.
The PostgreSQL profile and other backend adapters have different control powers. The arXiv v1 results do not establish universal coverage. Keep the boundary and its granularity explicit in any release claim.
Sources
FAQ
Is approving the SQL command enough?
No. A permitted command can trigger additional persistent writes. Compare the complete observed effects within a declared boundary with independently approved effects before committing the held transaction.
Does a matching row readback prove there were no extra effects?
No. It proves only what that readback covers. Other tables and dispatch paths must be observed or blocked before making a stronger claim.
What if a remote side effect already happened?
Stop dependent work, determine the remote state, and use an authorized reconciliation or compensation path. A local rollback does not reverse an external action.
Building something that has to hold up?
We do this work for teams — agent reliability hardening, custom MCP servers, and full-stack AI systems built to survive production.