Skip to content

Commit 658937a

Browse files
committed
docs(guide): add mermaid diagram for durable task branching
1 parent 7389a98 commit 658937a

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

frontend/docs/pages/v1/durable-tasks-vs-dags.mdx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,34 @@ DAGs can handle waits, conditional branches, and [or groups](/v1/directed-acycli
1212

1313
Support workflows, approval flows, and agentic loops are good examples. Consider a support agent: it triages a ticket, sends an initial response, waits for a customer reply or a timeout, then either resolves or escalates. You could express a simple version of that as a DAG with or groups and [parent conditions](/v1/directed-acyclic-graphs#branching-with-parent-conditions). But in practice the branching logic tends to grow beyond maintainability, with multiple escalation paths, multi-turn conversations, and context-dependent retries. At that point, writing it as imperative code with checkpointing is less work. Agentic loops are an even clearer case: the number of iterations is unknown, each action depends on the previous result, and the stopping condition is evaluated at runtime. That requires a cycle, which a DAG cannot express.
1414

15+
```mermaid
16+
flowchart TD
17+
A[Triages ticket] --> B[Sends initial response]
18+
B --> C[Wait for reply or timeout]
19+
C --> D{What happens next?}
20+
21+
D -->|Customer replied| E{Issue resolved?}
22+
E -->|Yes| F[Complete resolution flow...]
23+
E -->|No| G{Which case applies?}
24+
25+
G -->|Billing dispute| H[Open billing escalation...]
26+
G -->|Technical issue persists| I[Request more details...]
27+
G -->|Customer adds new issue| L[Re-triage updated ticket...]
28+
G -->|Refund exception| M[Start manual review...]
29+
G -->|Enterprise customer| N[Route to priority support...]
30+
G -->|More scenarios...| O[Additional branches...]
31+
32+
I --> C
33+
L --> C
34+
M --> C
35+
N --> C
36+
37+
D -->|Timeout| J[Send reminder or escalate...]
38+
J --> K{Retry or escalate?}
39+
K -->|Retry| I
40+
K -->|Escalate| H
41+
```
42+
1543
Durable tasks handle these cases by letting you write control flow directly in code. Hatchet checkpoints progress around waits and [child spawning](/v1/child-spawning), evicts the task from the worker slot while it waits, and resumes from the checkpoint when the wait resolves. The workflow can pause for an arbitrary duration, pick up exactly where it left off, and make its next decision based on what actually happened.
1644

1745
## Mixing both models

0 commit comments

Comments
 (0)