Effect IDs Before Retry: A 10,000-Run Crash Experiment
Retry is not recovery. I can make that distinction concrete with a small failure experiment: 10,000 executions, one external effect, and a crash in the worst possible place—after the effect happened but before the worker recorded success.
The question is deliberately narrow: what changes when a logical effect receives a stable identity before the first attempt?
The failure window
Consider an agent that sends a notification after approving an order. Its local sequence looks harmless:
call notification service
record "notification sent"
continue workflow
Now place a crash between the first and second line. The notification service accepted the request, but the local run has no receipt. After restart, the agent sees an unfinished step and retries.
A retry counter limits how many times this can happen. It does not answer whether the first effect already happened.
I modeled exactly this window. Each run may attempt the same logical notification up to eight times. After every external effect, the worker crashes with probability 0.35 before writing its local checkpoint. The seeded simulation executes 10,000 identical schedules against three strategies:
- naive retry — perform the effect again;
- idempotency key — send the same stable effect ID to a sink that deduplicates it;
- reconcile before retry — check the sink for that ID and accept the observed effect as completion.
This is not a benchmark of Temporal, LangGraph, an agent SDK, or a production network. It is a controlled state-machine experiment about one crash window.
Results
| Strategy | Completed runs | Runs with duplicate effects | Total effect applications | Maximum in one run |
|---|---|---|---|---|
| Naive retry | 9,997 | 3,486 | 15,340 | 8 |
| Stable idempotency key | 9,997 | 0 | 10,000 | 1 |
| Reconcile before retry | 10,000 | 0 | 10,000 | 1 |
All strategies saw the same seeded crash schedules. Three naive and idempotency-key runs exhausted all eight attempts without reaching the local post-effect checkpoint. The reconciliation strategy still closed those runs because the next attempt could observe that the named effect already existed.
That last difference matters. Deduplication protects the external system from duplicate application. Reconciliation also repairs the runtime's knowledge.
The ID is part of intent
The useful object is not an attempt ID. Every retry already has one of those. The useful object is a stable effect ID assigned before execution:
{
"run_id": "run_7f3c",
"step": "notify_order_42",
"effect_id": "order-42:approval-notification",
"attempt": 3,
"policy": "reconcile_before_retry"
}
attempt changes. effect_id must not.
If a new key is generated on every attempt, the receiving system correctly sees three different requests. Nothing in HTTP retry logic, exponential backoff, or an agent's memory can reconstruct that they were one intended effect.
This gives effect identity a precise lifecycle:
intent created
-> effect_id assigned
-> request sent with effect_id
-> remote receipt stored or rediscovered
-> local transition committed
The identity must cross the same boundary as the mutation. Keeping it only in the prompt or trace is useful for diagnosis, but it cannot support remote deduplication or lookup.
Deduplication and reconciliation solve different halves
An idempotency-aware receiver can map repeated requests with one key to one committed effect. That prevents duplicate charges, messages, releases, or tickets. It cannot automatically tell a restarted caller that its previous attempt succeeded unless the API also supports retrieving the result by key.
Reconciliation asks the external system a state question before repeating an operation:
GET effect by stable identity
found + expected payload hash -> record receipt, do not retry
not found -> execute with the same identity
found + conflicting payload -> stop for investigation
unknown / timeout -> remain uncertain; do not guess
The payload comparison is important. Reusing a key for different content should be a conflict, not silent success. Identity without semantic binding can suppress the wrong operation.
This is the concrete extension to my earlier recovery semantics for AI agents: retry, resume, compensation, and reconciliation are different transitions. Here the stable effect ID is the artifact that lets reconciliation operate.
Where to put the boundary
A model may propose the notification. It should not invent retry identity after a timeout. The harness can attach the current run context, but the execution layer should derive and persist the effect ID before calling the tool.
For a side-effecting tool, I want a contract close to this:
prepare(intent) -> effect_id, payload_hash
execute(effect_id, payload) -> receipt | unknown
reconcile(effect_id) -> absent | committed(receipt, payload_hash) | conflict
commit(receipt) -> local durable transition
The runtime owns this protocol because it survives model turns and process restarts. This follows the broader boundary in What Is an AI Engineering Runtime?: probabilistic choice may select an action, while named state transitions govern its consequences.
It also clarifies why a tool schema alone is insufficient. A schema can require effect_id; only the surrounding system can guarantee that retries reuse it, receipts persist, and conflicts stop execution.
What the experiment does not prove
The model assumes one logical effect, an observable sink, and a crash only after effect application. Real systems add timeouts before acceptance, eventually consistent reads, partial effects, receiver bugs, key expiry, and multi-step compensation. A stable ID does not create exactly-once delivery, and reconciliation can be unsafe when the target cannot expose authoritative state.
The numbers also depend on the chosen crash probability and attempt cap. They are not an estimate of production incident rates. The reproducible result is structural: under this model, naive retry permits duplicate effects; stable sink identity removes duplicates; lookup by that identity can additionally close runs whose local acknowledgment was lost.
That is enough to change a design review. Before asking how many retries an agent gets, I now ask a prior question:
What names the effect across every attempt?
If the answer changes on retry, the system is not recovering. It is repeating an intention and hoping the world recognizes it.