How to prevent a free LLM API workflow retry from repeating a tool action

Treat a timeout after sending as an unknown outcome, not proof that nothing happened. Give each side-effecting action a stable operation key, and have the system that performs the action enforce that key or deduplicate it in durable storage. Keep model-call retries separate: an OpenAI-compatible request format does not by itself guarantee exactly-once processing or provider idempotency.

A workflow retry crosses the model request and action boundary; only the action destination's stable-key ledger prevents a repeated effect

Separate the model request from the action

A workflow often has at least two different operations:

  1. Ask a model to classify, draft, or choose a tool.
  2. Use the result to send an email, update a row, create a ticket, or call another write endpoint.

If the model request times out after it was sent, a retry may produce another inference. Whether that attempt consumes a free provider's request or token allowance depends on the provider's accounting rules. Check those rules instead of assuming either outcome.

The downstream write has a separate risk. A network timeout can happen after an email, database update, or ticket was accepted but before the workflow received its response. Replaying the write may repeat the action unless the destination recognizes the same operation key or your workflow checks a durable deduplication record first.

An API can accept an OpenAI-shaped Chat Completions request without promising exactly-once handling for every POST. Verify idempotency support for the specific endpoint you call. Never assume that repeating the same prompt, using a compatible SDK, or receiving the same-looking model text makes a write safe to replay.

Use one stable key for the business action

The key must identify the action across attempts that represent the same business operation. For a synthetic order workflow, a key could be:

order-8472:send-confirmation:v1

Build a real key from a stable record ID plus the action name and, when needed, an action version. Do not include a prompt, customer name, email address, API key, or other sensitive value. If the upstream event has a durable event ID, that can be a better source than an execution number.

These identifiers solve different problems:

Identifier Good for Why it is not automatically the action key
Workflow execution ID Finding one n8n run in execution history. A manual rerun creates a new execution, so it may not deduplicate the same business action across runs.
Model tool_call_id Pairing a tool call with its result in one model response. A later inference can create a different ID for the same intended action.
Retry attempt number Logs such as attempt 1, 2, or 3. It changes on every try, which defeats deduplication if used as the key.
Stable action key Identifying one external write across retries and replays. It works only if the destination or your own ledger actually checks it.

n8n documents Retry On Fail for retrying a failed node and offers a maximum-tries and wait setting. Its idempotency guidance recommends reusing a stable key for the same operation; a fresh execution ID is suitable only when a new workflow run is meant to be a new operation. The receiving API must still implement the key or another deduplication rule.

Record an ambiguous result before deciding to retry

Use a small action ledger with states such as ready, sent, unknown, and done.

Observation Ledger state Next step
No request was started ready Send the action with its stable key.
Request was sent, then the connection timed out unknown Look up the destination by the stable key or its receipt before sending again.
Destination confirms the operation exists done Return the stored result; do not repeat the effect.
Destination confirms no operation exists and supports dedupe ready Retry with the exact same key.
Destination cannot answer whether it accepted the operation unknown Keep the action paused for reconciliation; a second write could duplicate it.

For a database-backed workflow, a unique constraint on the stable action key can provide the deduplication boundary. For a service that documents an Idempotency-Key header, use its required header and retention window exactly. If neither is available, record the action intent and destination response in your own durable store, and design a lookup or manual reconciliation step. A header that the server ignores is only a label, not idempotency.

For n8n, do not rely on a node's Retry On Fail switch to make an external write safe. Check whether the specific destination accepts an idempotency key. If it does, pass the stable business-action key through the node and reuse it on retries. If it does not, route ambiguous timeouts to a reconciliation branch instead of automatically replaying the write.

A local lost-response check

I used a loopback-only action service to test the uncertain case without a provider account. The stub accepts a write and records the effect, then drops the first response. A client cannot distinguish that from a request which never reached the server, so it retries once with the same action key.

Stub behavior HTTP attempts Recorded effects
Server ignores the supplied key 2 2
Server maps the key to the first receipt 2 1

The local fixture is daily/research/retry-idempotency-loopback.mjs. It asserts both outcomes and writes a small JSON receipt. No request leaves 127.0.0.1; this proves the retry boundary in the synthetic example only. It does not prove that a free LLM provider deduplicates inference requests or that its quota counter treats failed attempts a particular way.

This is the important acceptance condition for your own integration: after simulating “effect accepted, response lost,” the replay must return the first receipt or stop for reconciliation. Count HTTP attempts and external effects separately. One successful workflow execution does not by itself prove that only one request or one external action occurred.

Keep retry layers visible

Retries can live in the workflow node, a client SDK, a queue, and a manual “retry failed execution” action. Count each layer independently. If an SDK exposes its own retry setting, record it and test the exact client you use; do not attribute the official OpenAI Node SDK's defaults to a different n8n node or a third-party compatible API.

Cap automated attempts and record a correlation ID, workflow execution ID, attempt number, stable action key, HTTP status, and any destination receipt. Do not log prompt text, credentials, or private inputs just to diagnose duplicate work. For a model timeout, follow the provider's request and quota documentation. For a downstream write, decide from the destination's idempotency contract and recorded receipt.

Questions developers ask

Does an OpenAI-compatible free API deduplicate repeated requests?

Compatibility describes the accepted request shape. It is not enough to prove that a specific endpoint stores idempotency keys or returns a prior inference result. Check the provider's documentation for that endpoint. If it does not define a deduplication contract, treat a post-send timeout as an unknown model outcome.

Can I use the n8n execution ID as my key?

It can identify one execution and may keep retries inside that execution tied together. It changes for a manual rerun, so use a stable event or business record key when that rerun should represent the same external action.

Is the model's tool_call_id enough?

No. It pairs a call and result in a particular response history. A new inference may produce another ID. Generate an application action key before the side effect and make the destination enforce it.

Should I turn off all retries?

Not necessarily. Keep bounded retries for operations whose behavior you understand. Disable or separate overlapping retry layers while diagnosing; use destination-side deduplication for writes; and pause for reconciliation when the first outcome is unknown.

Sources checked 2026-11-10