When a write commits but the response is lost, do not repeat it
What should an agent do when a write goes out and no clear answer comes back? Not retry. A write whose response is lost has three possible states: it happened, it did not happen, or you do not know yet. Record the third state durably before you send anything, and let nothing resend while it is open. Most of the cases below come from code that only knew the first two.
Related: unknown is an outcome. This note is the casebook from my own agent tooling.
A 201 that was read as a failure
On 2026-11-02 a Codex agent was pairing a machine to a remote-control service. The request returned HTTP 201. The agent's one-off handler expected 200, so it treated the 201 as a failure and discarded the response before saving anything. The retry returned 409, which the agent inferred, and said it was inferring, was a duplicate rejection. The replacement request then sat out its ten-minute expiry, eight polls returning pending, with no key saved.
Nothing was lost on the wire. The response arrived and the handler threw it away. A check that is too strict discards evidence as surely as one that is too loose. Two rules came out of it: judge a status code by its meaning, and save the response before judging it. The agent reported all of this honestly, which is the subject of landed is not done.
Reserve the effect before you dispatch it
A separate, larger fence for the same kind of failure came in two pull requests to my bug-tracker tooling between 2026-11-10 and 2026-11-12. A write there could commit and lose its response, then repeat after a requeue or after its receipt was corrupted. The loop could report success while an effect was still uncertain.
The fix reserves a durable pending effect before dispatch and treats unreadable state as uncertainty. Then it sorts errors into two kinds. A definite server refusal is recorded as refused and is not resent. A 5xx, a 408, a 429, an unknown code or a dropped connection stays uncertain. The second pull request stacked the same fence onto image generation and image edits, which are not idempotent.
The table is my illustration of that rule, not output from the tool:
# illustration only, not a real log
what came back record as resend?
success code (2xx) done no
definite refusal refused no
5xx, 408, 429, unknown code uncertain no
connection dropped uncertain no
own state unreadable uncertain no
The ledger keeps entries for 14 days by default. The change also lists its own rollback risk: rolling the code back drops the pending-effect fences.
A committed row can be lost by another writer
In the outbox of my agent coordination layer, a consumer filter skipped a committed row for good when two writers took transaction ids and outbox ids in opposite orders. The reproduction committed 164 rows and delivered 163. The first fix was closed after review. The second takes a session advisory lock before any transaction id is assigned, releases it right after the last outbox insert, and sets a 5 second lock timeout inside that window. With the lock removed, the interleave test fails 3 of 3.
A related failure showed up in a family device-rules product of mine. An app held on arrival was recognised only by a value in a column that every closed-direction write restamped. After a parent Lock or a category policy, the next Allow from any route opened the high-risk app without the step-up check. The Lock erased the hold. The fix gives the hold its own column and one shared predicate with a NULL-safe SQL twin. It still honours the old stamp, so a code rollback keeps the holds. The coordinator agent triaged it as critical.
When the tool that failed is the signer
A private signed desktop build was produced, but the signer recorded exit 1 with the first failure unknown, somewhere in post-archive stages 137 to 143. The artifact existed. Whether it was good was not known.
The tempting moves are to overwrite the record or to declare success. Neither happened. A separate recovery checker passed independent review and all 16 of its gates, exit 0. It compared entitlements, code directory flags and designated requirements, required the hardened runtime, pinned the executable name, and compared signature-stripped content using fresh non-executable copies. The signer's receipt was preserved unchanged and no success receipt was fabricated. The notarization submission had already been accepted, and nothing was resubmitted.
Rollback is a write too
A database migration rollback was repaired to keep its guard and drop atomicity, and reviewed along the same lines. It takes exclusive locks in order, refuses unsafe isolation and incomplete ledger states, and restores the caller's lock timeout. On PostgreSQL 16 the full rollback preserved the success ledger even when psql kept going after the refusal. A concurrent writer committed a new success while the rollback waited, and the rollback saw it and refused.
Tell the user what is known
A rules screen in the same family product told parents a change had applied as soon as the server saved it, before any device acknowledged it. The coordinator agent triaged that as critical too. The copy changed from "now applies to" to "is saved for", followed by "It takes effect on each device once that device confirms it". Four message keys changed. No new acknowledgement channel was added: the change points to the existing delivery pane.
Where repeating is fine
Schema bootstrap is the contrast. In one service, setup ran 8 CREATE TABLEs, about 9 catalog reads and trigger fences on every identity call. It is idempotent, so repeating it was safe, only wasteful. It is now memoized per database handle, and concurrent first calls share one run. Because other tooling drops and re-creates the fences, the memo re-runs once it is 10 minutes old.
Checklist
- Write a durable pending record before dispatching a non-idempotent write.
- Save the response before judging it, and judge status codes by meaning.
- Classify failures as definite or uncertain. Send neither again.
- Treat unreadable state as uncertain, never as absent.
- Give a safety state its own column, not one that other writers restamp.
- Keep the failed receipt, and qualify the artifact by a separately reviewed path.
- Test rollback with a concurrent writer and a client that continues after a refusal.
- In the UI, say "saved" until the device confirms.
What is still open
The app test suite for the rollback change was still pending in that session. The Spanish and French versions of the new copy are agent translations, disclosed as awaiting a translator check.