IT Essentials

Long-horizon agents and durable execution: keeping weeks-long work alive across failures

A walk through durable execution — steps, a log, and replay — as the pattern that lets long-running AI agents survive crashes, lost replies and week-long waits, and why it still doesn't make them correct.

Why weeks-long work is suddenly on the table

Automation has long assumed a predictable process. Work that needed a person’s attention for weeks only got done when the return clearly paid for it. In a piece published on martinfowler.com in November 2026, Kiran Prakash (Thoughtworks) argues that long-horizon agents change that arithmetic. Guiding a churned customer through onboarding, shepherding a deal through sales, legal and procurement, or tracking referrals and appointments in healthcare administration — these paths are too unpredictable for classic workflow tooling, yet the tasks are exactly what an agent that keeps pursuing an outcome can now take on.

The catch is that most of the elapsed time is waiting. Quotes, a manager’s approval, the order, the delivery: days or weeks pass, and in the meantime processes die, APIs fail, and messages get delayed, duplicated or lost.

Where the agentic loop breaks

An agent is usually described as a loop with four parts: a goal, tools, state, and a model that reads the state each turn and picks the next tool. The code around the model that runs tools and updates state is the harness. While the process stays up, this works fine. Prakash’s advice is to treat a long-horizon agent as a distributed system, and his list of failure modes reads that way: the process restarts mid-wait; a supplier API is down; a reply is lost and the retry places the same order twice; a second replenishment starts while the first is still waiting; an order is actually accepted but recorded as a failure because no reply arrived; the price changes before approval lands three days later; new code is deployed under a running task; history grows without bound; an instruction aimed at the agent arrives inside a supplier’s email.

Durable execution: steps, a log, replay

Durable execution is a programming model in which the runtime records the input and output of every step that touches the outside world. When a failure occurs, the program runs again from the top, steps already recorded return their stored output instead of executing, and the program’s state is rebuilt from the log. Only the first step without a record runs for real. Code between steps only reads and writes local state, which is what makes re-running it safe. Waits suspend the workflow rather than hold a process, so no compute is spent while the agent is idle. Temporal, Restate, Inngest, DBOS and Cloudflare Workflows implement the pattern; the article’s stock-replenishment example was built on Temporal and Cloudflare Workflows, with the code shown from the Temporal version.

Durable is not the same as correct

Prakash is explicit that durable execution protects against crashes, not against being wrong. Idempotency of side effects, reconciling outcomes the agent never saw, re-checking prices and stock that moved during a wait, determinism when new code is deployed under a live workflow, and prompt injection through external input all remain the developer’s problem. One practical habit is worth stealing: keep business rules in code, not in the prompt. The place_order tool is simply not offered to the model until approval exists and the price sits within the approved range, enforced by a method such as allowed().

What to take away

Durable execution is less a new AI technique than workflow orchestration returning under a new name. Prakash adds one thing that treating the agent as just another distributed system misses: there is a model at the centre that can decide how to recover, so the harness’s job becomes feeding it the right input after a failure. Before adopting an agent for a multi-week task, the first question to ask is where the work restarts if it fails.

Sources

Drafted by AI from the original sources and reviewed by an editor before publishing. Check the sources for the authoritative details.

#durable execution #AI agents #workflow orchestration #Temporal #software architecture

← IT essentials