Skip to main content
The Feedback Loop Pattern creates a workflow where content progresses through repeated cycles of evaluation and improvement. Unlike linear approaches, this pattern enables continuous refinement through deliberate iterations that build upon previous work, with each cycle enhancing quality.

Key Characteristics

Feedback Loop Pattern
  • Iterative Refinement: Output from later stages feeds back to earlier stages for improvement
  • Quality Gates: Review stages determine whether additional iterations are needed
  • Targeted Improvements: Specific feedback guides revisions in subsequent cycles
  • Cumulative Enhancement: Knowledge gained in each iteration informs future refinements

Information Flow

Feedback Loop Flow In the Feedback Loop Pattern, information flows cyclically through specialized stages multiple times. The process begins with creation phases, followed by cycles of review and revision. These iterations continue until quality criteria are met, with context maintained throughout to ensure cohesive progression.
  • Creation → Review → Revision → Repeat: Content cycles through these stages multiple times
  • Feedback-Driven Progress: Each review generates actionable insights for improvement
  • State Preservation: Context variables track document evolution across iterations
  • Quality-Based Termination: Cycles continue until review determines no further iterations needed

Implementation

Our implementation demonstrates the pattern through a document creation process with specialized agents handling distinct lifecycle stages. Through structured interfaces and state tracking, the system enables multiple improvement cycles while maintaining coherence and building upon previous work.
  • Specialized Agent Roles: Six agents (Entry, Planning, Drafting, Review, Revision, Finalization) each focus on distinct tasks
  • Structured Data Exchange: Pydantic models ensure consistent information transfer between stages
  • Context-Based Routing: OnContextCondition handoffs direct content based on stage and iteration status
  • Reusable Expertise: Review and Revision agents apply accumulated knowledge across multiple iterations

Agent Flow

Code

In this code example we use OpenAI’s GPT-4o mini with structured outputs.We also set the LLM parameter parallel_tool_calls to False so that our agents don’t recommend more than one tool call at a time. This parameter may not be available with all model providers.

Output