Agentic AI Notebook
Agent Foundations
Phase 4Module 12 of 15

Reflection

Agents make wrong tool args and incomplete answers — reflection catches errors early.

Proofreading before send — catch mistakes while they are still cheap to fix.

Visual Workflows

Start here — scroll inside each diagram frame to explore, then use + / to zoom up to 200% if needed.

100%
Loading diagram...

Scroll inside the frame to explore · use + / − to zoom up to 200%

Self-Critique Loop

100%
Loading diagram...

Scroll inside the frame to explore · use + / − to zoom up to 200%

Draft critique revise until quality passes or max retries.

Key Takeaways

  • 1.Reflection = agent reviews output before returning.
  • 2.Self-critique: LLM checks quality and completeness.
  • 3.Verifier: separate model judges primary output.
  • 4.Reflexion: store lessons in memory for future tasks.

Real Example

Scenario

Report agent drafts a Q3 summary; critique flags a missing APAC breakdown and an uncited revenue total. Agent re-queries SQL for APAC, adds citations, then returns.

What you would do

Self-critique checks: date range ✓, all regions ✓, citations ✗. Revise triggers a second SQL call with `region='APAC'`. Cap at 2 critique rounds; use a cheaper model for critique. Monitor: critique-trigger rate and added cost per task.

Practice Task

Write a 6-item reflection checklist for customer-facing emails. Apply it mentally to a one-paragraph draft you invent — note what would fail.

Code Walkthrough

Highlighted lines show where Reflection happens in the code.

Reflection
1CRITIQUE_PROMPT = "Review the draft. List: missing sections, uncited numbers, policy risks."2
3draft = "Q3 revenue was strong across regions..."4critique = llm([{"role": "user", "content": f"{CRITIQUE_PROMPT}\n\n{draft}"}])  # prompt that asks the model to review its own draft5
6if "uncited" in critique.lower():7    revised = llm([{"role": "user", "content": f"Fix these issues:\n{critique}\n\n{draft}"}])8    draft = revised

Cheat Sheet

Quick recap

quick ref
  • Reflect on high-stakes outputs
  • Self-critique vs verifier agent
  • Skip for simple lookups
  • Max retry after failed critique
  • Reflexion stores lessons

Common Mistakes

  • Skipping evaluation for Reflection before production
  • No logging or tracing around reflection steps
  • Ignoring cost and latency implications