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

Reflexion Agent - Building Revisor Chain

Revisor consumes draft + tool evidence, then rewrites output with better grounding and citations.

Core Theory

The reviser is where Reflexion converts evidence into better output. It receives the first draft plus tool observations and must produce a revision that is both more accurate and better grounded.

Reviser input pack: original answer, critique list, normalized tool findings, and style/policy constraints.

Recommended reviser output schema: { revised_answer, citations, residual_issues, next_search_queries, quality_score }.

What a good reviser does:

  • Incorporates only evidence-backed claims.
  • Adds explicit citations per major claim.
  • Flags unresolved gaps rather than fabricating.
  • Requests additional search only when needed.

Loop efficiency rule: if residual issues are minor and score improvement plateaus, finalize instead of over-iterating.

Deepening Notes

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

  • der chain we just Chang the first instruction alone and then we created a chain out of it we provided a tool as well to ground its response so we are going to be doing the exact sa
  • ht here so that you can see so this is the responder chain all that we're doing is we are piping this template with the bind tools and then we are forcing it to only use the answer
  • we are forcing it to only use the answer question tool responder right so we are going to do the same thing here as well so this is going to be the promt template let's pipe it so
  • be the promt template let's pipe it so let's go ahead and pipe it with the llm so we are going to say bind tools and then let's provide in the tools which is going to be an array
  • od right so once we have all of the building blocks done connecting it all together using L graph becomes a piece of cake okay so

Interview-Ready Deepening

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

  • Revisor consumes draft + tool evidence, then rewrites output with better grounding and citations.
  • The reviser is where Reflexion converts evidence into better output.
  • It receives the first draft plus tool observations and must produce a revision that is both more accurate and better grounded.
  • Reviser input pack: original answer, critique list, normalized tool findings, and style/policy constraints.
  • Recommended reviser output schema: { revised_answer, citations, residual_issues, next_search_queries, quality_score } .
  • 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.
  • What a good reviser does: Incorporates only evidence-backed claims.

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

Revision step walkthrough: 1) Draft says: "Revenue increased in Q3." 2) Tool evidence provides exact numbers and region breakdown. 3) Reviser rewrites: "Q3 revenue increased 23%, led by North America (+31%) [source: earnings_q3_p4]." 4) Reviser returns residual issue: "No YoY comparison yet" with optional next query. 5) Router decides one more loop or finalize based on policy.

🧠 Beginner-Friendly Examples

Guided Starter Example

Revision step walkthrough: 1) Draft says: "Revenue increased in Q3." 2) Tool evidence provides exact numbers and region breakdown. 3) Reviser rewrites: "Q3 revenue increased 23%, led by North America (+31%) [source: earnings_q3_p4]." 4) Reviser returns residual issue: "No YoY comparison yet" with optional next query. 5) Router decides one more loop or finalize based on policy.

Source-grounded Practical Scenario

Revisor consumes draft + tool evidence, then rewrites output with better grounding and citations.

Source-grounded Practical Scenario

The reviser is where Reflexion converts evidence into better output.

🧭 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 - Building Revisor Chain.
  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

Revisor chain implementation and revision constraints.

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. Inspect revise_instructions and citation requirements.

🎯 Interview Prep

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

  • Q1[beginner] What extra inputs does reviser need beyond the first draft?
    Strong answer structure: define the concept in one sentence, ground it in a concrete scenario (Revisor consumes draft + tool evidence, then rewrites output with better grounding and citations.), 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 add citations in reviser output?
    Strong answer structure: define the concept in one sentence, ground it in a concrete scenario (Revisor consumes draft + tool evidence, then rewrites output with better grounding and citations.), 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] How do you avoid endless revise loops?
    Strong answer structure: define the concept in one sentence, ground it in a concrete scenario (Revisor consumes draft + tool evidence, then rewrites output with better grounding and citations.), 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?
    Tie reviser quality to concrete evidence coverage, not style alone.
πŸ† 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...