Skip to content
Concept-Lab
← LangGraphπŸ•ΈοΈ 11 / 42
LangGraph

Reflexion Agent - Introduction

Reflexion extends reflection by grounding critique/revision with live external data via tools.

Core Theory

Reflexion adds a critical missing capability to plain reflection: evidence acquisition. A reflection loop can critique quality, but Reflexion can also fetch new information and revise based on that evidence.

Minimal Reflexion architecture:

  1. Responder creates first draft + self-critique + search intents.
  2. Tool execution node gathers external evidence for those intents.
  3. Reviser rewrites output using observations and citation constraints.
  4. Router decides continue vs finalize based on score/improvement policy.

Why this is better than reflection-only systems: quality is improved by new facts, not only better wording. This matters for news, pricing, compliance, or any domain where stale knowledge is risky.

Core trade-off: better factuality and grounding at the cost of added latency, more tool calls, and larger state.

Control requirements: cap loops, bound tool usage, enforce citation schema, and define fallback when evidence remains weak.

Deepening Notes

Source-backed reinforcement: these points are extracted from the LangGraph source note to sharpen architecture and flow intuition.

  • because we are not really making any tools like T Search tool that we saw right we're not making it available to the reflection agent system okay so that is a drawback of reflecti
  • but also fact checks it with external data by making API calls in this case internet search in the reflection agent pattern we had to rely on the training data of llms but in this
  • e actor the actor is the main agent that drives everything it reflects on its responses and re-executes it it can do this with or without tools to improve based on self-critique th
  • later on we look at the diagram and it would make sense so we've got tools we've got the responder agent and we've got the revisor agent finally okay so the revisor agent agents jo
  • the list of Search keywords that the responder agent generated this tools component is actually going to you know the Tav search Tool if you remember in the first few sections we l

Interview-Ready Deepening

Source-backed reinforcement: these points add detail beyond short-duration UI hints and emphasize production tradeoffs.

  • Reflexion extends reflection by grounding critique/revision with live external data via tools.
  • A reflection loop can critique quality, but Reflexion can also fetch new information and revise based on that evidence.
  • Reflexion adds a critical missing capability to plain reflection: evidence acquisition.
  • Why this is better than reflection-only systems: quality is improved by new facts, not only better wording.
  • Core trade-off: better factuality and grounding at the cost of added latency, more tool calls, and larger state.
  • Responder creates first draft + self-critique + search intents.
  • Tool execution node gathers external evidence for those intents.
  • This matters for news, pricing, compliance, or any domain where stale knowledge is risky.

Tradeoffs You Should Be Able to Explain

  • More agent autonomy increases adaptability but also increases non-determinism and debugging effort.
  • Tool-heavy loops improve grounding, but latency and failure surfaces rise with each external dependency.
  • Fine-grained state graphs improve control, but poor state contracts can create brittle routing behavior.

First-time learner note: Think in state transitions, not giant prompts. Keep node responsibilities small and route logic deterministic so each step is easy to reason about.

Production note: Bound autonomy with loop limits, tool policies, and checkpoints. Capture route decisions and state snapshots for replay and incident analysis.

🧾 Comprehensive Coverage

Exhaustive coverage points to ensure complete topic understanding without missing core concepts.

Loading interactive module...

πŸ’‘ Concrete Example

Practical Reflexion run: 1) Draft answer says: "Market share rose significantly." 2) Self-critique flags missing current quarter numbers. 3) Search tools fetch latest earnings snippet + source URLs. 4) Reviser updates answer with exact figures and citations. 5) Router finalizes because quality threshold is reached. Without Reflexion, the answer would stay generic and potentially outdated.

🧠 Beginner-Friendly Examples

Guided Starter Example

Practical Reflexion run: 1) Draft answer says: "Market share rose significantly." 2) Self-critique flags missing current quarter numbers. 3) Search tools fetch latest earnings snippet + source URLs. 4) Reviser updates answer with exact figures and citations. 5) Router finalizes because quality threshold is reached. Without Reflexion, the answer would stay generic and potentially outdated.

Source-grounded Practical Scenario

Reflexion extends reflection by grounding critique/revision with live external data via tools.

Source-grounded Practical Scenario

A reflection loop can critique quality, but Reflexion can also fetch new information and revise based on that evidence.

🧭 Architecture Flow

Loading interactive module...

🎬 Interactive Visualization

Loading interactive module...

πŸ›  Interactive Tool

Loading interactive module...

πŸ§ͺ Interactive Sessions

  1. Concept Drill: Manipulate key parameters and observe behavior shifts for Reflexion Agent - Introduction.
  2. Failure Mode Lab: Trigger an edge case and explain remediation decisions.
  3. Architecture Reorder Exercise: Reorder 5 flow steps into the correct production sequence.

πŸ’» Code Walkthrough

Reflexion architecture setup from local code.

content/github_code/langgraph/4_reflexion_agent_system/chains.py

Responder/revisor prompts and tool-bound structured outputs.

Open highlighted code β†’

content/github_code/langgraph/4_reflexion_agent_system/schema.py

Pydantic output schema for answer, critique, and references.

Open highlighted code β†’
  1. Review actor prompt instructions and structured tool output contract.

🎯 Interview Prep

Questions an interviewer is likely to ask about this topic. Think through your answer before reading the senior angle.

  • Q1[beginner] How is Reflexion different from Reflection?
    Strong answer structure: define the concept in one sentence, ground it in a concrete scenario (Reflexion extends reflection by grounding critique/revision with live external data via tools.), then explain one tradeoff (More agent autonomy increases adaptability but also increases non-determinism and debugging effort.) and how you'd monitor it in production.
  • Q2[intermediate] Why are tools essential in Reflexion systems?
    Strong answer structure: define the concept in one sentence, ground it in a concrete scenario (Reflexion extends reflection by grounding critique/revision with live external data via tools.), then explain one tradeoff (More agent autonomy increases adaptability but also increases non-determinism and debugging effort.) and how you'd monitor it in production.
  • Q3[expert] What tradeoff does Reflexion introduce?
    Strong answer structure: define the concept in one sentence, ground it in a concrete scenario (Reflexion extends reflection by grounding critique/revision with live external data via tools.), then explain one tradeoff (More agent autonomy increases adaptability but also increases non-determinism and debugging effort.) and how you'd monitor it in production.
  • Q4[expert] How would you explain this in a production interview with tradeoffs?
    Reflexion is quality-through-evidence, not just quality-through-self-critique.
πŸ† Senior answer angle β€” click to reveal
Use the tier progression: beginner correctness -> intermediate tradeoffs -> expert production constraints and incident readiness.

πŸ“š Revision Flash Cards

Test yourself before moving on. Flip each card to check your understanding β€” great for quick revision before an interview.

Loading interactive module...