Skip to main content
Home
GrN.dk

Main navigation

  • Articles
  • Cases
  • Services
  • Your Digital Project Manager
  • About Greg Nowak
  • Image Gallery
  • Contact
User account menu
  • Log in

Join my community / free newsletter — sign up here

Breadcrumb

  1. Home

One Timeout, Two Orders: How to Make AI Actions Safe to Retry

Illustrated infographic summarizing: One Timeout, Two Orders: Make AI Actions Safe to Retry

By Greg Nowak. Updated 25 August 2026.

An AI agent submits an order. The supplier accepts it, but the response disappears during a network timeout. The agent sees a failed call and tries again. Unless the integration recognises both attempts as one business action, the customer may receive two orders.

This is not limited to autonomous agents. The same failure can duplicate invoices, CRM records, support tickets, emails and webhook-driven jobs. A timeout means only that the caller did not receive an answer in time. It does not tell you whether the action happened.

Decide what a retry is allowed to repeat

Retries are useful for temporary network failures and overloaded services. Backoff, jitter and attempt limits control when requests are repeated, but they do not prevent repeated business effects. That protection must be part of each tool’s contract.

Operation Safe retry behaviour Minimum safeguard
Read product or account data Repeat after a temporary failure Backoff, jitter and an attempt limit
Create or update a record Return the first resource or result Stable idempotency key and stored status
Place an order or send a message Never repeat an accepted action Provider retry key, plus reconciliation
Receive a webhook Acknowledge a previously claimed event Atomic event claim and idempotent worker
Start slow work Report that the original job is still running Durable queue, job ID and status endpoint
A retry policy should be based on the operation’s business effect, not merely its HTTP method.

Give one business intention one stable key

An idempotency key identifies the intended action, not an individual HTTP attempt. Create it when the workflow decides to perform the action, save it with the workflow state and reuse it for every retry. Generating a new UUID inside the retry loop defeats the protection because every attempt then appears unrelated.

Keep the material request unchanged. If the amount, recipient or product changes, create a new intention and therefore a new key. Conversely, reject a reused key whose request fingerprint differs from the original.

Provider behaviour varies. Stripe’s API v1 documentation says that it stores the first status and response body for a key and compares later parameters with the original request. LINE’s messaging guidance requires the retry key on the first attempt and blocks a later request after the original has been accepted. Both also impose retention rules, so your own ledger may need to remember an intention for longer than the provider does.

Make the ledger durable and the claim atomic

A useful action ledger records the key, operation type, request hash, status, timestamps, attempt count, provider request ID and completed result. The database—not process memory—should decide which worker owns the action.

For PostgreSQL, a small claim can use a primary key and ON CONFLICT DO NOTHING:

INSERT INTO action_ledger
  (idempotency_key, operation, request_hash, status)
VALUES
  (:key, :operation, :request_hash, 'processing')
ON CONFLICT (idempotency_key) DO NOTHING;

If the insert succeeds, that worker owns the work. If it does not, read the existing row: return its stored result when completed, report that it is still processing, or apply an explicit recovery policy. A separate “check, then insert” sequence is unsafe because two workers can pass the check simultaneously. PostgreSQL documents ON CONFLICT as the database-level alternative for handling concurrent uniqueness conflicts.

Store the first useful response or a stable resource identifier. “Already processed” is often too vague for an agent; returning the original order ID gives it a safe way to continue the workflow.

Know the gap a ledger cannot close

A local ledger alone cannot guarantee exactly-once execution against an unrelated external system. A worker can call the supplier successfully and crash before marking its ledger row complete. On recovery, the system still does not know whether to call again.

The strongest design passes the same key to a provider that supports idempotency. If that is impossible, use a unique business reference the provider can query, or introduce a reconciliation state such as outcome_unknown and stop automatic retries until the result is checked. For consequential actions, an honest uncertain status is safer than guessing.

Queues help throughput, not duplicate prevention

Inbound webhooks present the problem in reverse: providers may deliver the same event more than once. Verify the signature, atomically claim the event identity, enqueue the work and acknowledge promptly. The worker must remain idempotent because queue messages can also be retried.

Stripe’s current webhook guidance recommends recording processed event IDs, accounting for logically duplicated events and handling work asynchronously. The queue separates receipt from execution; the ledger prevents two deliveries from producing the same effect.

Test success followed by silence

The most revealing test is not “the API returned an error.” Simulate the downstream service accepting an order and then dropping the response. Allow the agent or worker to retry and verify that only one business action exists.

  • Send two simultaneous requests with the same key.
  • Reuse a key with a changed payload and confirm it is rejected.
  • Crash after the external call but before the local completion update.
  • Retry after the provider’s key-retention window.
  • Trace workflow ID, action key, attempt, provider request ID and final status together.

Start with the actions that can cause damage

Inventory every agent tool, scheduled job and webhook. Mark reads, reversible writes and consequential actions separately. Then document who creates the key, where it is stored, how long it survives, what response is replayed and how an uncertain outcome is reconciled.

Greg can help your team map these failure boundaries and build a reusable gateway for stable keys, atomic claims, result replay and operational logging. If retries currently depend on hope or manual cleanup, get in touch for a practical review.

Retries should repeat delivery attempts, not business decisions. With that distinction enforced, a timeout remains an operational nuisance instead of quietly becoming a second order.

Related on GrN.dk

  • A Voice Agent Is Only Ready When the Human Handoff Works
  • Agent-ready APIs: audit the contract before MCP rollout
  • When AI writes JSON, one bad field can break the workflow

Need help with this kind of work?

Make your AI integrations safe to retry Get in touch with Greg.

Sources

  • Stripe API Reference: Idempotent requests
  • LINE Developers: Retry failed API requests
  • Stripe Documentation: Receive events in your webhook endpoint
  • PostgreSQL Documentation: INSERT
Last modified
2026-08-25

Tags

  • ai-agents
  • api-integrations
  • idempotency
  • webhooks
  • workflow-reliability

Review Greg on Google

Greg Nowak Google Reviews

 

Written recommendations from Trafik og Veje, Aarhus Municipality (2011) and AgroTech (2010) — read them on LinkedIn.

Illustrated infographic summarizing: What Are Customers Asking? Let AI Find the Patterns in Support Tickets
What Are Customers Asking? Let AI Find the Patterns in Support Tickets
2026-09-04

AI-based ticket analysis can uncover recurring complaints, product defects and gaps in documentation—without the company needing yet another chatbot.

Illustrated infographic summarizing: OpenAI Has Machine Identity Now. Which Jobs Should Lose API Keys?
OpenAI Has Machine Identity Now. Which Jobs Should Lose API Keys?
2026-09-03

OpenAI’s X.509 workload identity can replace API keys for the right workloads. This practical framework helps teams decide where to start safely.

Illustrated infographic summarizing: WordPress 7.1 Exposes AI-Ready Actions. Who Gets to Run Them?
WordPress 7.1 Exposes AI-Ready Actions. Who Gets to Run Them?
2026-09-02

WordPress 7.1 helps AI agents discover and invoke site abilities. Here is how to keep exposure, authentication and permission firmly separate.

Illustrated infographic summarizing: From Sales Meeting to CRM: Automate Follow-Up Without Compromising Data Quality
From Sales Meeting to CRM: Automate Follow-Up Without Compromising Data Quality
2026-09-01

How to use AI for meeting notes and follow-up while fixed rules protect CRM data, customer matching and the sales pipeline from errors and premature changes.

Illustrated infographic summarizing: Your AI Gateway Can Name the User. Decide What That Log Is For
Your AI Gateway Can Name the User. Decide What That Log Is For
2026-08-31

Identity-aware AI Gateway logs can sharpen security and cost control, but only when attribution, access, retention, guardrails, and response are clearly defined.

Illustrated infographic summarizing: Zero Data Retention Is a Workflow Audit, Not a Checkbox
Zero Data Retention Is a Workflow Audit, Not a Checkbox
2026-08-30

Zero Data Retention covers the provider, not every copy in your stack. See how to audit endpoints, logs, storage, deletion and project-level controls.

Illustrated infographic summarizing: MCP 2026-07-28 Is an Auth Migration, Not a Version Bump
MCP 2026-07-28 Is an Auth Migration, Not a Version Bump
2026-08-29

MCP’s July 2026 release removes protocol sessions and tightens OAuth. Here’s a practical plan for migrating clients, servers and enterprise access safely.

Illustrated infographic summarizing: Turn a Technician’s Voice Note into a Work Order—Not Raw Audio
Turn a Technician’s Voice Note into a Work Order—Not Raw Audio
2026-08-28

Voice input can reduce the technician’s documentation burden when hours, materials and status are validated before the information is saved in the work order system.

Illustrated infographic summarizing: ChatGPT Disabled Personal Knowledge Sync. What Broke on Your Team?
ChatGPT Disabled Personal Knowledge Sync. What Broke on Your Team?
2026-08-27

ChatGPT retired personal sync connections for Enterprise and Edu. Here is how to find affected workflows, migrate access, and test permissions.

Illustrated infographic summarizing: Cloudflare’s September Bot Defaults Could Quietly Cut AI Visibility
Cloudflare’s September Bot Defaults Could Quietly Cut AI Visibility
2026-08-26

Cloudflare’s September bot defaults give publishers more control, but one training block could also cut search crawling and AI-driven discovery.

More articles

Built by AI — available for your business. The daily articles on this site are researched, written and illustrated by an autonomous AI pipeline. At nowa.dk I install the same kind of AI automation in businesses at fixed prices — site in Danish, English version here, and web/marketing agencies have a dedicated page.

RSS feed

Footer

  • All articles
  • Contact

GrN.dk — AI automation, web platforms, web optimization, data handling and logistics.

© 2026 GrN.dk · LinkedIn · Contact · AI automation in Danish: nowa.dk

Behind GrN.dk: Individual Entrepreneur Codecrafter · Tax ID 305669096 · Bakhtrioni St. 22, 0194 Tbilisi, Georgia · official business register