LLMs & agents
Agentic workflows: what happens after the timeout?
An agentic workflow recovers safely when it can stop at any step (a timeout, a crash, a wait for approval) and resume without repeating an action that already happened. That takes three things: a durable record of each step, an idempotency key on every external write, and an explicit unknown state for results nobody has confirmed. A tool call times out just after an agent submits a record. The agent has no reply, but the record may already exist. Sending the create request again could leave you with two records and no clear account of how it happened. The workflow needs to hold that uncertain outcome until it can check the destination.

Treat an unknown result as its own state
Take a hypothetical ticket-creation tool. The service saves the ticket, then the connection drops before the new ticket ID reaches the agent. The ticket exists, but the agent has no confirmation. Replaying the conversation and issuing another create call could create a second ticket while leaving the first one unaccounted for.
The caller needs a durable attempt record before sending the request. Otherwise a restart may erase even the fact that it tried. In that record, we'd distinguish confirmed success, confirmed failure and 'result unknown'. If the remote service supports a lookup by request ID, the unknown case can use it to reconcile the result. Without such evidence, the timeout tells us only that a reply didn't arrive.
Keep the same identity when retrying the same action
For an API that supports idempotency, give the intended action a key once and retain it. Imagine that key is 'ticket-4827' in our synthetic example. The retry must use 'ticket-4827' too. Sending 'ticket-4828' asks the receiver to treat it as another operation. AWS describes this retry pattern in the guidance linked below.
The key belongs to a particular action and set of approved parameters. Reusing it after changing the customer or requested update would blur two different operations. Some APIs offer no deduplication and no reliable result lookup at all. For those, we'd stop the uncertain write and send it to an operator for reconciliation. A prompt cannot add an exactly-once guarantee to the remote service.
type Attempt = { key: string; status: "unknown" | "confirmed"; ticketId?: string };
interface AttemptStore {
get(key: string): Promise<Attempt | undefined>;
put(attempt: Attempt): Promise<void>;
}
interface TicketApi { // assumes the service deduplicates by key and can look a key up
create(body: object, idempotencyKey: string): Promise<{ id: string }>;
findByIdempotencyKey(key: string): Promise<{ id: string } | undefined>;
}
export async function createTicketOnce(store: AttemptStore, api: TicketApi, key: string, body: object) {
const saved = await store.get(key);
if (saved?.status === "confirmed") return saved.ticketId; // done before: don't repeat it
if (saved?.status === "unknown") {
// An earlier attempt may have worked. Check the destination before writing again.
const found = await api.findByIdempotencyKey(key);
if (found) {
await store.put({ key, status: "confirmed", ticketId: found.id });
return found.id;
}
}
await store.put({ key, status: "unknown" }); // durable before the request leaves
const created = await api.create(body, key); // same key on every retry; a timeout throws here
await store.put({ key, status: "confirmed", ticketId: created.id });
return created.id;
}Save the work that must survive a restart
For this example, we'd persist the task ID, input version, approved plan, tool results already obtained and the outstanding action. A chat transcript may explain how the plan developed, but rebuilding the current state from it requires another interpretation during recovery. Give the saved record the original data's access controls, and retain only what recovery needs.
The next worker loads that record and finds the first unresolved step. Before resuming, it checks whether the input still matches the saved version. A change sends the affected proposal back for review. An approval from before the change may no longer fit what the worker is about to do.
| Saved state | Next step after restart |
|---|---|
| Draft prepared; approval absent | Show the draft and request approval. |
| Approval recorded; action not dispatched | Check that the input version still matches, then dispatch. |
| Action dispatched; result unknown | Reconcile with the destination before attempting another write. |
| Result confirmed | Continue using the recorded result; do not repeat the action. |
Approval belongs to a particular proposal
For an update, an approval record might name the destination account, the operation and the proposed field values. That is much less ambiguous than a yes buried in the conversation. If the assistant later changes those values, it has changed the proposal. The earlier approval no longer covers it.
Permissions for routine reads can be agreed in advance. When an action does need review, the screen should tell the operator what will change and where, in ordinary language. They should be able to approve that proposal without reconstructing it from the assistant's entire conversation.
Try the failure you are designing for
For the test, put the interruption in the worst place: the synthetic service has saved its ticket, but the worker hasn't saved the returned ID. Restart the worker twice. Inspect the destination, not just the agent's answer. You want one ticket, with local state that either reconciles to it or clearly hands the uncertainty to an operator.
Then change the input before a restart. Try a refused permission and an approval that has expired. In those cases, stopping for review may be the correct result. A recovery test that checks only whether execution continued would miss that distinction.
Rubix Labs includes workflow architecture, approvals and evaluation in its agentic-systems offering. We'd put this failure drill in the pilot's acceptance checks. Before handing the system over, an operator should be able to stop it, inspect the last action and resume without guessing whether that action already happened.