Opportunity

Idempotency for LLM retries and agent tool calls

The PainHunt Team· Published · Updated · 3 min read

TL;DR: An operator wants retried tool calls to avoid repeating a consequential action. Investigate whether the agent side-effect recovery proposal improves that task.

The workflow to examine

Evidence to inspect: Action identifiers, retry boundaries, persisted results and the external system's supported semantics.

Proposed design

Investigate an application-owned identity for a business action, with a durable record of its known and unresolved states. The model's latest tool arguments alone should not decide whether an attempt repeats an earlier action or requests a new one.

  • Assign the action identity deliberately. Define which business action an identifier names, persist it and reuse it for retries of that action. A hash or conversation counter may be an implementation input, but it is not a universal way to distinguish a repeated action from a legitimate second one. Check account, object and action scope before dispatch.
  • Record intent without calling it completion. A row written before execution proves that work was planned. Track whether the downstream effect is pending, confirmed or unknown, with the supported action reference and result where available. A crash between the external effect and the ledger update still needs reconciliation.
  • Keep transport acknowledgment separate. A stream marker can help interpret a received response, but that marker can also be lost. Its absence does not prove that the action did not happen, and emitting it does not make an external write atomic with the local ledger.
  • Integrate with the downstream contract. Check the exact operation, key scope, retention window and retry behavior the target system supports. A wrapper can apply those rules to its declared paths; it cannot promise to govern an unwrapped tool or create an unsupported downstream guarantee.

Start with one consequential operation in a sandbox. Compare the proposed wrapper with the application's current durable execution and reconciliation process before choosing a library, hosted service or further platform work.

Risks and honest caveats

Existing capabilities may cover the boundary. Inspect the current framework and downstream system before describing a missing feature. A separate component needs a specific integration or recovery task to improve; a forecast about framework roadmaps is not evidence of a market gap.

The correct key needs business context. Whether two "charge the customer" calls represent a retry or two legitimate charges depends on the approved business action. Guessing can suppress a legitimate second action as well as allow an unwanted duplicate; test both outcomes.

Coverage requires inspecting every relevant path. A ledger only governs operations routed through it. Check alternate tools, retries and manual recovery paths rather than assuming that one wrapped function covers the application's side effects.

Unknown outcomes need an owner. Some interrupted attempts may require readback or human review. Include that work in the proposed offer, and keep willingness to adopt and pay unverified until a relevant operator tests it.

A proposed test for agent side-effect recovery

Interrupt a sandbox call after the action completes but before acknowledgment, then retry and inspect the final state.

Exercise three separate interruption points: before the downstream effect, after the effect but before the local completion record, and after local completion but before the caller receives the result. Reuse the same intended action identifier, then submit a distinct permitted action to check that it is not suppressed as a duplicate.

Inspect both the downstream state and the ledger. The expected result must follow the target system's supported contract; if an effect cannot be established, preserve that uncertainty and stop automatic replay until the approved reconciliation step resolves it. These are proposed checks, not a claim of universal exactly-once execution.

A reason to stop or change direction: The system cannot bind retries to the same intended action or promises exactly-once behavior it cannot establish.

Research aids: Pain Point Browser, Idea Validator and how the research scores work.

Related reading: checkpointing for long AI agent tasks; AI agent permissions and access audit logs.

Frequently asked questions

Why isn't a request hash automatically an idempotency guarantee?

A hash identifies chosen input bytes, not necessarily the intended business action or its completed effect. Define the action identity, persistence and retry boundary, and check the external system's actual semantics.

Why is a dropped response ambiguous?

The caller may lose acknowledgment after an external action has completed. An intent row or a missing stream marker does not settle that outcome. Preserve an unknown state and reconcile the action through the downstream system's supported identifiers and records before deciding whether to retry.

Doesn't the provider's idempotency key solve this?

It can address the operations and time window the provider documents. It does not automatically cover a multi-step workflow, a different downstream action or lost local state. Test each declared boundary in a sandbox.

Research the problem behind your idea

Explore problem summaries and source links to compare workflows and decide what to investigate next.

Open the Pain Point Browser

Related articles