Skip to content
AITroveRead. Build. Understand.
Make this comfortable

Recurring prompts: survive retries without duplicate effects

Last updated: 4 Oct 202611 min read
tutorial
AdvancedBy AITrove Editorial

Schedulers may retry an invocation after a timeout even when the first attempt partly succeeded. Give the run a stable identity based on schedule and intended window, then record stage receipts outside the model. A retry can recompute a read-only summary, but sending the same message or editing the same record twice may be harmful. The prompt should ask for the existing receipt before proposing another effect. Idempotency belongs in the application and destination API; a sentence saying 'do this only once' does not enforce it. After an ambiguous result, query the authoritative destination before retrying.

Operational case

North Pier's report is generated for window W-47. The first attempt saves the draft but times out before the scheduler gets a response. A retry with the same run identity finds draft receipt R-47 and continues from that artifact, rather than creating a second draft. If a notification send times out, the system checks the message destination for the idempotency key before attempting another send. The prompt may describe the uncertainty, but it cannot declare delivery based on its own prior text.

Output
Run identity: north-pier / W-47 / review-v3.
Draft stage: receipt R-47 already exists -> reuse.
Notification stage: outcome unknown -> query destination by key.
Duplicate receipt found -> do not send again.
No authoritative result -> hold and escalate.

Performance and operating cost

A keyed receipt lookup is O(1) average in an indexed store. A retry adds latency and possibly another model call, so resume from verified stages where possible. Stable run keys reduce duplicate side effects and make cost attribution easier. Keep an expiry rule for idempotency records longer than the maximum retry horizon; otherwise a delayed retry can bypass the deduplication window.

Common Mistakes

  • Do not invent a fresh run ID for each retry of the same scheduled window.
  • Do not assume a timeout proves the effect failed.
  • Do not rely on prompt wording as the only duplicate-send control.

Connected lessons

prompt engineering
recurring workflows
Storage details