Durable execution: replay re-runs workflow, logged activities skip
attempt 1 — crash after call_llm
fetch_docs
run, log done
call_llm
run, log done
CRASH
write_report not yet run
event log (durable)
[fetch_docs started, fetch_docs done (result=X),
call_llm started, call_llm done (result=Y)]
attempt 2 — replay
fetch_docs
replay from log
call_llm
replay from log
write_report
run, log done
return report
done
what makes replay work
1. Workflow code is deterministic (no wall clock, no random, no hidden I/O).
2. Every activity is logged with args + result; replay re-reads the log.
3. Backend survives the crash (PostgreSQL / Durable Objects; not SQLite for prod).
4. HITL pauses are a workflow signal, not a polling loop.
LLM calls fit the activity shape: non-deterministic, expensive, potentially failing.