Learn AI

AI Concepts Workshop

© 2026 Cloudy Software Ltd

Self-Correction & Reflection

The 'System 2' of agents. Watching an agent write code, encounter an error, reflect on the stack trace, and fix its own bug.

script.py
# Goal: Fetch user data and print name
def get_user_name(id):

Agent "System 2" Trace

Drafting Solution
Generating initial code attempt...
Execution check
Running code in sandbox...
Reflection
Analyzing stack trace. 'data' var missing.
Self-Correction
Rewriting code to include variable definition.