Workflow patterns
The five canonical patterns side by side on the same task, with calls, latency, cost and failure behaviour — plus durable execution with a crash halfway.
Real vs simulated: Calls are simulated with the illustrative tiers; the crash/resume logic is real.
Prices and speeds: small $0.25/$2, mid $1/$5, large $3/$15 per M tokens (illustrative).
| Pattern | Model calls | Latency | Cost / ticket |
|---|---|---|---|
| 1 | 6.1 s | $0.0127 | |
| 3 | 6.3 s | $0.0060 | |
| 2 | 3.5 s | $0.0049 | |
| 4 | 5.9 s | $0.0066 | |
| 5 | 15 s | $0.0266 | |
| 3.1 | 7.1 s | $0.0077 | |
| 5 | 10 s | $0.0292 |
Routing
Use it when: Distinct request types with different best handlers — or easy vs hard traffic.
How it breaks: Misroutes: a hard ticket sent to the small model gets a confident weak answer. Measure router accuracy.
Durable execution: crash halfway
#1 Fetch the ticket #1 Classify and draft (model) #1 Refund €30 (payments API) 💥 worker crashed after the call, before saving the checkpoint — job redelivered #2 Fetch the ticket #2 Classify and draft (model) #2 Refund €30 (payments API) — DONE AGAIN #2 Email the customer #2 Close the ticket
What the outside world saw
- ×2 Refund €30
- ×1 Email sent
- ×1 Ticket closed
Without checkpoints the redelivered job starts over and repeats side effects. Checkpoints resume from the last saved step — but the step that was in flight when the worker died runs again, so it must be idempotent. Durable-execution engines (Temporal, Step Functions, LangGraph checkpointers) give you the first; only your API design gives you the second.