Durable Task: When Processes Need Step Memory

When durable execution pays off: long-running workflows, sagas, bulk LLM processing, and AI agents—and when a queue or Kafka is enough.

  • What is durable execution
  • The cost of a process without memory
  • Where durable execution pays off
  • Where it is unnecessary

Trigger

  1. Microsoft published an analysis on the .NET blog Durable Task in the Real World.

  2. The authors describe five practical scenarios where durable execution is justified, as well as cases where it only adds complexity.

  3. A separate section is dedicated to AI agents.

  4. My takeaway is this rule: durable execution pays off when a business process outlives a single request and a lost step costs money. In other cases, a queue and an idempotent handler are enough.

What is durable execution

  1. Durable Task is Microsoft's open-source framework, on which Azure Durable Functions are built.

  2. The developer describes the process in regular C# code: call a service, wait for the response, then call the next one.

  3. The framework records the result of each completed step in its history. Suppose the process failed at the fourth step.

  4. After a restart, the orchestrator rereads the history (this mechanism is called replay), inserts the saved results of the first three steps, and continues from the fourth.

  5. The wait may last for days: a timer or external event is stored in the database while the thread remains free. This comes at a cost.

  6. Orchestrator code must be deterministic: it must not call `DateTime.Now`, generate a `Guid`, or make direct HTTP requests.

  7. The developer moves external calls into activities and obtains time and random values through the framework API. A team that does not know these rules will encounter bugs that reproduce only during replay.

The cost of a process without memory

  1. Consider an order that passes through five systems: the website, 1C, the warehouse, the delivery service, and EDI. Assume each system has 99% availability.

  2. The order then completes the chain without failure with a probability of 0.99⁵, or about 95%.

  3. With 2,000 orders per day, approximately 100 will get stuck somewhere in the middle.

  4. Companies usually fill this gap with a status table, a cron retry script, and a manager who manually searches for lost orders each morning.

  5. The result is custom-built durable execution without guarantees or tests, whose design is known by only one developer.

Assess where AI can deliver impact in your process

Where durable execution pays off

  1. ### Processes that wait for a person Examples: contract approval, supplier onboarding, and document signing in EDI.

  2. The process sends a document, waits three days, escalates to a manager on timeout, and continues after signing.

  3. With a queue, this process becomes a state machine spread across five tables. In an orchestrator, it takes a few dozen lines of sequential code. ### Sagas with compensation

  4. The warehouse reserved the item, the payment failed, and the reservation must be released.

  5. The orchestrator stores a list of completed steps and runs compensations in reverse order.

  6. Without this, phantom reservations accumulate in the warehouse: the item is physically on the shelf, but cannot be sold. ###

  7. Parallel batch processing Suppose you need to enrich 50,000 item cards in Pimcore or Akeneo using an LLM.

  8. The orchestrator splits them into batches, runs them in parallel (fan-out), and combines the results (fan-in).

  9. If the model fails or the quota runs out on item card 30,000, processing will continue from the point of failure.

  10. Without an orchestrator, the tokens paid for the first 30,000 item cards would have to be spent a second time. ### AI agents

  11. An agent works in a loop: the model selects a tool, receives the result, and decides what to do next.

  12. Sometimes an agent stops and waits for human approval.

  13. Each iteration costs tokens and may have a side effect.

  14. Suppose the agent fails on the twelfth call out of fifteen.

  15. Restarting from scratch would pay for eleven calls again.

  16. In addition, the client may receive an email twice, and a duplicate document may appear in 1C. Durable execution saves the result of every model and tool call, so after recovery the agent continues from the last step.

Where it is unnecessary

  1. Short, idempotent requests that complete within seconds are handled by a retry policy. For the flow “message from Apache Kafka → database record”

  2. An orchestrator is unnecessary too: Kafka stores the offset, and a second source of truth would only complicate debugging.

  3. If 1C exchange already runs through an ESB with guaranteed delivery, such as Datareon, MuleSoft, or Talend, duplicating these guarantees with an orchestrator is pointless.

  4. There is also an operational risk that teams often overlook at the start: versioning. Imagine that 400 process instances are waiting for signatures while you change the orchestrator code.

  5. During replay, the old history will not match the new code, and the processes will fail.

  6. The versioning strategy must be planned before the first release.

A three-question selection rule

When we design an integration, we ask three questions:

Does the process last longer than a minute or wait for an external event?

Does it involve more than three steps across different systems?

Repeating a step costs money or corrupts data

Two “yes” answers—choose durable execution. Fewer than two—a queue with idempotent handlers is enough. In KT.Team’s AI-native integration projects, we first map the process and calculate the cost of a lost step, then choose the tool. Event streams run through Kafka, while 1C exchange runs through Datareon. We build long-running sagas and agent loops in C#/.NET with an orchestrator. Model calls pass through the LLM & Security Gateway, where you can see how many tokens were spent on retries.

Verdict

Durable execution is difficult to learn, but it delivers results quickly for its class of tasks: its time to use, the period from implementation to the first benefit, is short. A process once reliant on a status table, cron, and manual investigation becomes linear code that survives failures. A team that uses an orchestrator for every HTTP call will get unnecessary infrastructure and determinism bugs.

The sales manager cares about one number: by morning, 100 orders that used to get stuck reached customers without a manager's involvement.

Discuss the article: Durable Task: When a Process Needs Memory…

Enter your email or phone number so we can get back to you.

Send via: