AI architecture · Distributed systems

Distributed Systems for Agentic AI: Retries, Idempotency and Failure Recovery

When an AI agent can call tools and change state, the hardest failures look less like prompt bugs and more like distributed-systems failures.

· 12 min read · Published 2026-08-22
Independent reference architecture. No employer-confidential systems or data.
Original Essay · Reliability & Scale × Harden · AI Agents · Distributed Systems · Idempotency · Observability

Agentic AI systems are often presented as a new application pattern. Operationally, many of their hardest problems are old distributed-systems problems wearing a probabilistic interface.

The moment an agent can call tools, wait on external services, mutate state or continue a task after failure, the architecture has to answer familiar questions: What is durable? What can be retried? What is idempotent? What happens after partial execution? Which component owns the workflow state?

A simple agent can create a partial-failure problem

Imagine an agent plan with four actions:

1. Create analysis record
2. Update metadata
3. Notify reviewer
4. Schedule downstream job

Steps one and two succeed. Step three times out. The model retries the plan from the beginning. If the tools are not designed for retries, you may now have duplicate records, conflicting metadata or multiple downstream jobs.

This is not primarily a prompting problem. It is a transaction and state-management problem.

Principle 1: the agent should not be the durable state machine

A model can decide among options, decompose a request or propose a next action. Durable workflow state should live in a system that can be inspected independently of the model: a workflow engine, database-backed state machine or application service.

That gives the system a stable answer to “what has already happened?” even if the model call is retried, the process restarts or a different model completes the next step.

Principle 2: design tool calls for idempotency

For consequential tools, give each logical operation an idempotency key. If the same request is replayed, the service should return the prior result rather than execute the side effect again.

tool_request {
  operation: "create_review_case",
  idempotency_key: "workflow-842:step-03",
  payload: {...}
}

Idempotency is especially important when the caller is probabilistic because duplicate intent can arise from network retry, orchestration retry, model re-planning or human re-submission.

Principle 3: classify retries by failure type

“Retry three times” is not a strategy. Distinguish transient failures from semantic failures.

Principle 4: make partial execution a first-class state

Distributed workflows do not fail atomically. A useful orchestrator should represent states such as tool_succeeded_review_pending or action_unknown_reconciliation_required , not collapse everything into “agent failed.”

For operations that cannot be rolled back, define compensating actions. Compensation is not a true distributed transaction; it is an explicit business-level recovery path.

Principle 5: use human gates at irreversible boundaries

Human review is most valuable when the next action is expensive, externally visible, destructive or hard to reverse. A reviewer should see the proposed action, evidence, tool inputs and current workflow state—not just a generated paragraph.

Principle 6: separate model observability from workflow observability

LLM traces matter, but production debugging needs both planes.

A beautiful model trace is not enough if you cannot answer whether a downstream action actually executed.

Reference architecture

Client
  ↓
API / identity
  ↓
Durable workflow state  ←──────────────┐
  ↓                                     │
Agent / planner                         │
  ↓                                     │
Structured action proposal              │
  ↓                                     │
Policy + schema validation              │
  ↓                                     │
Idempotent tool gateway ─→ services ────┘
  ↓
Human gate where required
  ↓
Event log + reconciliation + evals

Architecture review questions

An AI agent may choose the next step. It should not be the only component that remembers whether the last step happened.

That distinction is what turns an impressive agent demo into a production system with understandable failure behavior.

Continue exploring All architecture & field engineering writing ↗