Self-Correction and Reflection
Self-correction, also called reflection, is the mechanism by which an AI checks its own execution results and adjusts course when they differ from expectations. If planning sets the direction, self-correction is how the system gets back on track after drifting.
The Basic Flow
graph LR
Act["Execute\nadvance a step"] --> Check["Verify\ndoes the result match expectations"]
Check -->|Yes| Next["Move to the next step"]
Check -->|No| Fix["Adjust the approach and retry"]
Fix --> ActThe design hinges on one question: what evidence is used for verification.
Self-Assessment Is Not Enough
The simplest check is asking the AI whether its own result is correct. It is easy to set up, but it has a structural weakness: when the error originated in its own judgment, reviewing from the same viewpoint will not surface it.
Reliability improves when objective external facts serve as the evidence.
| Evidence | Example | Reliability |
|---|---|---|
| Self-assessment | The AI reviews its own output | Low, since blind spots repeat |
| Execution results | Test outcomes, command exit codes | High |
| Independent review | A check by a subagent | Medium to high |
| Human review | Approval by a reviewer | High, but costly |
In practice the split is mechanical checks where tests can confirm the result, and independent or human review where judgment is required.
Cap the Loop
Self-correction can repeat indefinitely. Retrying the same fix without improvement only consumes time and cost.
- Set a retry ceiling, such as three attempts per step
- On reaching the ceiling, hand off to a human instead of continuing automatically
- After the same failure twice, revisit the plan rather than the fix
Distinguish What to Correct
What needs fixing after a failure is not always the same thing.
| Failure type | What to correct |
|---|---|
| Runtime error | Inputs or parameters |
| Output differs from expectation | The instruction or the context supplied |
| Assumption no longer holds | The plan itself |
Retrying the same procedure does nothing for the third category.
Summary
- Self-correction verifies execution results and adjusts the approach
- Self-assessment alone repeats the same blind spots, so use objective external facts
- Cap correction loops and hand off to a human beyond the limit
- Match the correction target — inputs, instruction, or plan — to the failure type