Failure Detection and Recovery
In multi-step workflows, how mid-run failures are handled determines reliability. What goes undetected runs to completion on a wrong result.
Detection Comes From Completion Conditions
Detecting failure requires each step to have a defined completion condition. Without one, there is no way to judge whether the step finished.
| How the failure appears | Detection method |
|---|---|
| The tool raises an exception | Detected as an error |
| Processing succeeds but output misses requirements | Requires checking against the completion condition |
| Nothing happens and work continues | Undetectable without a completion condition |
The second and third are the dangerous ones. Because no error surfaces, only a mechanism catches them. Running verification right after a step with a hook is the reliable approach.
Choose the Fallback by Cause
Returning to the beginning every time is wasteful. Match the fallback point to the cause.
graph TD
F["A step fails"] --> C{"Where is the cause"}
C -->|Invalid input| Prev["Fix the previous step's output"]
C -->|Wrong procedure| Same["Rerun the same step with changed conditions"]
C -->|Assumption broke| Plan["Revisit the plan"]
C -->|External factor| Wait["Retry after a delay"]| Cause | Fallback point |
|---|---|
| Faulty input | The previous step |
| Problem in procedure or instruction | The same step, with changed conditions |
| Broken assumption | Revisit the plan |
| Transient external factor | The same step, after a delay |
Cap and Escalate
Automatic recovery needs a ceiling. Once the same step reaches it, escalate to a human rather than continuing.
Escalation should carry three things.
- Which step failed, and how many times
- The error, or the gap against the completion condition
- Which deliverables survive so far
Without these, the person starts by reconstructing the situation from scratch.
Do Not Discard Partial Results
Deliverables from completed steps should survive a failure. With progress held in state, successful steps never need redoing. Rolling back everything gets expensive in long workflows.
Summary
- Failure detection requires completion conditions on each step
- Failures without errors are the dangerous ones and need mechanical verification
- Choose the fallback point by cause: previous step, same step, or the plan
- Escalate past the retry ceiling, carrying the situation and surviving deliverables