Workflow DAG

A graph that can be drawn.

Workflows are operated as persistent execution graphs featuring resumability, retries, and state history.

In practiceA document-processing pipeline runs OCR, classification, and archival as nodes in a durable graph, replaying only the failed node after a transient storage error.

Level
04 · Production
Subdomain
Runtime Architecture
Also known as
Durable Workflow, DAG Orchestration, Resumable Workflow
Trade-off
Production robustness is achieved at the expense of infrastructure and modeling effort.
Native in
LangGraph, AWS Strands, Google ADK, Microsoft Agent Framework, CrewAI
The mechanism

How it works.

The workflow is a graph that is stored outside the process running it. An engine records the result of every node, retries failed nodes by a policy, and can rebuild a run from its history.

1 · Define

  1. Declare the nodesEach one a unit of work
  2. Declare the edgesWhat depends on what
  3. Set a retry policyAttempts and waiting time per node

2 · Execute

  1. The engine starts a nodeWhen its inputs are ready
  2. The result is recordedIn the history of the run
  3. A failure is retriedBy the policy of that node
  4. The run survives a restartThe history says where it stands
History
The recorded results of all finished nodes. It is the source of truth for the run.
Retry policy
How often a node is tried again and how long the engine waits in between.
Replay
Rebuilding the state of a run from its history, without executing finished nodes again.
Walk it through

A real run, step by step.

TaskA document pipeline with three nodes: OCR, classification, archiving. The storage system is briefly unavailable:
Illustrative run.
NodeAttemptResult
ocr1The text of 12 pages, recorded
classify1“Invoice”, recorded
archive1Storage error
archive2After 30 seconds: storage error
archive3After 60 seconds: stored. The run is complete
What this shows: the expensive node, OCR, ran once. Only the failed node was repeated, with a growing wait. Had the worker process died between two attempts, another worker would have picked up the run from its history. The price is an engine to operate, and nodes that are written so that a repeat does no harm.
In code

The pattern in code.

Plain Pythonpython
WORKFLOW = {  # node: (function, depends on, attempts)
    "ocr": (run_ocr, [], 1),
    "classify": (classify, ["ocr"], 2),
    "archive": (archive, ["ocr", "classify"], 3),
}

def execute(run_id, document):
    # results of the nodes that already finished
    history = load_history(run_id)
    for node, (function, needs, attempts) in WORKFLOW.items():
        if node in history:
            continue  # finished before a restart: not run again
        inputs = [history[n] for n in needs] or [document]
        for attempt in range(1, attempts + 1):
            try:
                history[node] = function(*inputs)
                # recorded before the next node starts
                save_history(run_id, history)
                break
            except TransientError:
                if attempt == attempts:
                    raise
                wait(seconds=30 * attempt)
    return history
Fit

Use it, or not.

When to reach for it

  • Runs take a long time or can fail.
  • States and retries must be robustly managed.
  • Production demands traceability.

When it backfires

  • Tasks are brief and stateless.
  • Persistence creates unnecessary operational load.
  • The graph model does not fit the execution flow.
Pitfalls

Two ways this pattern will hurt you.

Hidden cycles in the DAG

A conditional edge creates an implicit cycle that the DAG validator misses. The workflow loops indefinitely at runtime.

Countermeasure

Run a static cycle check at build time. Reject any graph that contains a back-edge unless it's explicitly declared as a loop.

Over-static DAGs forcing pipeline-shaped problems

Every new requirement gets squeezed into the existing DAG shape. The graph becomes a tangled mess of conditional hacks.

Countermeasure

Re-evaluate the DAG topology quarterly. If conditional edges exceed 30% of total edges, consider decomposing into smaller graphs.

Framework support

Where Workflow DAG is native.

LangGraphdurable graph runtimeNative
AWS StrandsAWS Strands WorkflowNative
Google ADKworkflow graphsNative
Microsoft Agent Frameworkdurable workflowsNative
CrewAICrewAI FlowsNative
Temporalworkflows as codeAdaptable
Inngeststep functionsAdaptable
Restatedurable handlersAdaptable

Search

Search patterns, frameworks, and pages.