Durable AI workflows

Persist useful progress, recover interrupted execution, and keep checkpoint recovery separate from the effects of external tools.

Written deep dive25% previewBy Daniyal Saqib

Read the opening here. A free account gives you the full guide.

01

Designing a Durable AI Document Processing System

Consider an enterprise application that allows employees to upload invoices for automated processing. The system uses an LLM to extract invoice numbers, supplier information, dates, line items, and payment amounts. It then validates the extracted information against business rules and stores the verified results in a database.

A single invoice may require several AI calls and take several minutes to process. During execution, an LLM provider may time out, a worker may crash, or the application may receive the same invoice submission multiple times. Restarting the entire process after every failure would waste model tokens and processing capacity. More importantly, repeating completed operations could create duplicate invoice records.

The challenge is to design a workflow that can execute each processing stage independently, preserve completed work, and resume unfinished operations without producing duplicate business results.

02

1. Designing the Workflow Execution Architecture

Start by separating the document submission process from its actual execution. When an employee uploads an invoice, the API should validate the request, store the original document in object storage, and create a workflow execution record in a database. Instead of processing the document within the HTTP request, the application schedules the work for background execution.

A message queue distributes processing tasks to available workers.

3 more sections to read

Sign in to keep reading

Durable AI workflows

Continue this section and read the complete guide and explore its visuals.

Free account. No payment required.

Read how we handle account information in our privacy notice.

3 more sections to read

There’s more in the full article

Continue reading with a free account.

Keep reading

Free account. No payment required.

Inside the full article

Continue the guide with 3 more sections.

  1. 2. Persisting Workflow State Between Processing StepsRead after sign-in
  2. 3. Solving the Database and Queue Consistency ProblemRead after sign-in
  3. 4. Preventing Duplicate Processing and Business ResultsRead after sign-in
Continue reading

3 more sections to read

Sign in to keep reading

Durable AI workflows

Continue this section and read the complete guide and explore its visuals.

Free account. No payment required.

Read how we handle account information in our privacy notice.