liveBook · Manning

Reflection

As explained in AI Agents in Action, Second Edition

Reflexion is an agent technique in which an agent uses feedback or self-reflection to improve subsequent decisions or attempts.

Reflection is a solver–critic loop: an agent evaluates an attempt, turns the failure into a hint or error analysis, and tries again with that feedback in context. section 5.3.2

A better second attempt does not mean the model learned permanently. No weights are updated, and past sessions are forgotten unless feedback is explicitly preserved; improvement comes from richer prompts. section 5.3.2

Use reflection when:

  • The first attempt is likely to fail, but its failure contains information that can guide revision. section 5.3.2
  • A critic can check the answer against a known solution, test, or deterministic validation rule. section 5.4.3 section 5.6
  • You can afford iterative calls, extra tokens, and latency in exchange for deeper improvement on one reasoning path. section 5.3.2 section 5.4.3

Reflection differs from tree-of-thought by going deeper on one path through revision, while tree-of-thought explores multiple branches and prunes weaker ones. It can also wrap CoT, ReAct, or tool use. section 5.3.2 section 5.6

A retrying time-travel solver

A solver attempts a time-travel calculation. A critic checks the answer and returns a concise hint when it is wrong. The solver receives that hint as context and retries until it passes the check or reaches the retry limit. An exercise replaces a hardcoded target with check_answer(days), accepts answers equal to 26, limits attempts to four, and reports failure when all attempts fail. section 5.5

How AI Agents in Action, Second Edition covers it

How deep it goes
Explains the solver–critic loop, prompt conditioning, validation, and retry limits, but stops short of weight updates or persistent memory.
Examples
Uses time-travel calculations, solver–critic agents, a correctness-checking tool, four-attempt retries, and forced success or failure paths.
What it assumes
Assumes basic agent loops and tool calls, while demonstrating critique, feedback injection, validation, and retry control.
What you can do after
Build it from scratch as a solver–critic retry loop with feedback injection, deterministic checks, and bounded attempts.
How it connects
Connects to chain-of-thought, ReAct, tree-of-thought, sequential thinking, tools, guardrails, schemas, and typed outputs.

Also explained in

Compare how 13 books explain reflection →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of AI Agents in Action, Second Edition. The section links point to the parts of the book it draws on.