01

A timeout leaves the outcome uncertain

An artificial intelligence (AI) assistant submits a booking request. The service creates the reservation, but the connection drops before the assistant receives the response. When the assistant retries, the service creates a second reservation. The customer now has two bookings from one request.

After a timeout, the caller may have no way to tell whether the action happened. Agents face the same distributed-system failures as other applications. A model adds another complication: unless the workflow constrains its next step, it may retry or choose a different tool.

02

Record the action before sending it

Create a durable record for each intended operation. Store its identifier, authorized request, target service, current state, and any external reference returned. The record should survive a worker restart and remain available when the conversation has ended.

Use states that distinguish pending work, confirmed success, confirmed failure, and an unknown outcome. A timeout belongs in the last category until another check establishes what happened. Marking every timeout as a failure invites an unsafe retry.

The workflow controller should enforce the allowed state transitions, including whether a booking can be submitted again. The model can interpret the request and explain the outcome.

Two workers can pick up the same pending operation and both submit it. A supported locking, leasing, or conditional-update mechanism should give one worker ownership of the next transition. Recovery must also account for an expired worker that continues running after another has taken over.

One intended booking may involve several network attempts, each with its own timestamps and response details. Keep those attempts under the same operation so support can follow their history. If a conversation restart creates a new operation for unfinished work, it can bypass the protections attached to the original request.

03

Give retries a stable identity

Where the destination supports idempotency keys, send the same key for retries of the same intended operation. That allows the receiving service to recognize the duplicate request. AWS describes this approach in its guidance on safe API retries, including the need to distinguish a repeated request from a new intention. 1

The service's contract determines how to use its keys. They may expire, apply only within a particular account, or reject changed parameters. Store the request associated with each key. Reusing one for a different booking can cause problems just as generating a fresh key for every retry can.

If the destination provides no such support, look for an operation-status endpoint or a search by a stable client reference. A local record alone cannot guarantee that the remote service will execute an action once. Where the result remains ambiguous, pause and expose that uncertainty to an operator.

The booking may exist before the provider's search endpoint exposes it, so an empty result immediately after a timeout may leave the outcome unresolved. Define how long the controller waits, which lookup is authoritative, and when an operator should investigate. The model should not treat an empty result as permission to start over.

Retry policy depends on the error. A temporary connection failure may justify another attempt with the same operation identity; invalid passenger details need correction first. When an overloaded service rejects requests, apply a bounded delay. Repeatedly sending an invalid request consumes capacity and makes the original problem harder to find.

04

Recover from the last confirmed step

Suppose the booking succeeded, but the confirmation email failed. Resume at the email step after verifying the reservation. Replaying the entire conversation would repeat work that already changed the outside world.

For dependent actions, work out which steps can be reversed and at what cost. Releasing a temporary hold may be straightforward; canceling an issued ticket could incur a fee. A compensation step needs its own permissions and audit record, along with a plan for its possible failures.

Human approval should apply to the concrete action being performed. If recovery changes the price, recipient, or commitment, the workflow may need fresh approval. An earlier instruction to reserve one option should not silently authorize a materially different one.

A workflow that reserves inventory before charging a customer leaves an outstanding reservation if payment fails. Record those dependencies so a recovery worker can find the obligation without reconstructing the assistant's prose. Store the reservation reference and expiry alongside the payment state.

Compensation can fail too. A cancellation request might time out after the provider has processed it. Treat that as another uncertain operation with its own status checks. Keep the original record open until the required follow-up is resolved or deliberately assigned to an operator. Marking the workflow finished because a cancellation was attempted hides work that still affects the customer.

05

Give support a recoverable case

During recovery, tell the user that the reservation is being checked. Avoid announcing failure while a booking may exist, or success before confirmation. Provide one operation reference that support staff can follow across the agent and destination service.

Support staff need to see the intended action, last confirmed step, external references, and recovery attempts, along with the next safe action. Record their manual decisions in the same place so an automated worker cannot later resume and contradict them.

Track the number and age of unresolved operations. A low request-error rate can conceal bookings stuck for hours. Test a dropped response by checking how many reservations actually exist at the destination. An agent's success message cannot establish that recovery worked if the customer still has two bookings.

06

Test the unknown outcome explicitly

In a test environment, let the booking service accept a request, then interrupt the response before the workflow receives it. Restart the worker and check its next action. It should recover the existing operation record and reconcile the booking, rather than create a fresh operation because the conversation was restarted. Check the service's own reservation count as well as the assistant's answer.

Repeat with a status lookup that initially returns no result. If that lookup is eventually consistent, an immediate absence does not establish that the first request failed. The workflow needs a bounded reconciliation interval consistent with the service contract. When that interval expires, preserve the unknown state and give an operator the operation identifier, attempted parameters, and lookup history. Do not describe the booking as canceled or successful until its state is established.

07

Separate retry decisions from the conversation

Give the workflow an operation record that survives a new chat message, a worker restart, and an operator handoff. In the booking example, record the intended customer, booking parameters, operation identifier, last confirmed remote state, and the next permitted action. A conversational summary can describe progress, but it should not be the authority that decides whether another booking request is safe. If the user repeats the question after a timeout, load the operation record before creating any new work. Ask for clarification when the requested booking has changed rather than silently reusing an identifier for a different intention.

Consider two workers recovering the same operation after a lease expires. Both may read an unknown result and decide to retry. Where the destination supports an idempotency contract, use it as documented; also define how the local workflow prevents competing owners from advancing the operation at once. The exact locking or version-check mechanism depends on the storage system. Test a stale worker attempting to write after a new owner has taken over. Its response must not overwrite a later confirmed state. Record attempts separately from the business operation so that an operator can distinguish several network requests from several actual bookings.

Handle a reversal as another business operation with its own rules. Canceling a reservation may incur a charge, fail after a cutoff, or require a person to approve it; establish the actual service contract before automating that step. A compensating action is not proof that the original action never happened. Show the user the state that has been confirmed and keep unresolved steps visible. For a manual handoff, provide the destination reference, attempted parameters, response history, and actions already ruled out. Give the operator one supported route to resume the workflow after reconciliation. This avoids a separate manual process that fixes the booking but leaves the agent ready to repeat the disputed action later.

08

References

Amazon Builders Library · Making retries safe with idempotent APIs

09

Related

Where to read next on the same subject.