1 min lesson
Failure handling
Consider this situation: "An agent proposes a five-file refactor. List the failure modes you'd design for before letting it apply and one mitigation each." Start with the decision, then the evidence.
Step 1 of 2
Failure handling
Edits fail in specific, recurring ways and naming them is what separates a careful systems answer from a hopeful one.
- Failure
- Partial application
- What goes wrong
- Edit applies to 3 of 5 files, then a tool errors
- Recovery
- Atomic-per-turn checkpoint; roll back to a consistent state, surface what landed
- Failure
- Conflicting edit
- What goes wrong
- User typed in a region the agent is rewriting
- Recovery
- Detect on apply, re-anchor the hunk or re-generate against the new buffer
- Failure
- Stale anchor
- What goes wrong
- The diff targets line numbers that have shifted
- Recovery
- Anchor edits to content/AST nodes, not raw line offsets
- Failure
- Doom loop
- What goes wrong
- Agent retries the same broken fix forever
- Recovery
- Cap iterations, detect repetition, hand back to the user with what it learned
| Failure | What goes wrong | Recovery |
|---|---|---|
| Partial application | Edit applies to 3 of 5 files, then a tool errors | Atomic-per-turn checkpoint; roll back to a consistent state, surface what landed |
| Conflicting edit | User typed in a region the agent is rewriting | Detect on apply, re-anchor the hunk or re-generate against the new buffer |
| Stale anchor | The diff targets line numbers that have shifted | Anchor edits to content/AST nodes, not raw line offsets |
| Doom loop | Agent retries the same broken fix forever | Cap iterations, detect repetition, hand back to the user with what it learned |
Interview move
When you describe an agent, always say how it stays in control: the diff is the contract, edits are a transaction, the loop verifies before it stops. Cursor's bar is "powerful tools without compromising ease-of-use," so an answer that pairs capability with a rollback story and a review surface lands far better than raw autonomy.