Agentic AI Tutorial 0/80 lessons ~6 min read Lesson 25

    Reflection Loops

    Reflection is the agent critiquing its own output and trying again if it's not good enough.

    Course progress0%
    Focus
    7 guided sections
    Practice signal
    Examples included
    Career prep
    Foundation builder

    Introduction

    Reflection is the agent critiquing its own output and trying again if it's not good enough. Patterns: Reflexion, Self-Refine, Critic agents. Reflection often boosts quality 10-30% at the cost of more LLM calls.

    Beginner analogy: writers don't ship first drafts — they read, criticise, rewrite. Reflection makes agents do the same.

    Understanding the topic

    Core concepts:

    • Self-refine: same LLM critiques and improves.
    • Critic agent: separate LLM with a stricter rubric.
    • Stop when score > threshold or max iterations hit.
    • Reflection works best with explicit rubrics.
    • Pair with retrieval — let the critic check facts.

    Syntax reference

    Visual workflow / architecture:

    bash
    Plan ──► Execute ──► Critique
    ▲ │
    │ ▼
    └──── Revise ◄──── Score < threshold?

    Real-world use

    Devin reflects on test failures; Cursor's agents critique their diffs; many code-gen agents auto-run tests and reflect on errors.

    Best practices

    • Define rubric criteria explicitly (correctness, style, length).
    • Cap iterations or you'll burn dollars.

    Common mistakes

    • Infinite reflection loops on impossible rubrics.

    Hands-on exercise

    Interview preparation — practice these questions:

    • Q1. What is reflection in agents?
    • Q2. Self-refine vs critic-agent — when each?
    • Q3. Scenario: reflection hurt accuracy. Why might that happen?
    Ready to mark this lesson complete?Track your journey across the entire course.