# Phase 4: Feedback Loop **Purpose:** The core primitive — plan → execute → observe → reflect → refine. **TS Module:** `src/tier2-primitives/loops/feedback-loop.ts` ## What It Does Runs the phase machine for N iterations until convergence: ``` plan → execute → observe → reflect → refine ↑ │ └──────────────────────────────────────┘ ``` Each phase produces structured output stored in the state accumulator. ## PhaseExecutor Interface Implement this to connect any model: ```typescript interface PhaseExecutor { plan(task: string, previousIteration: LoopIteration | null): Promise; execute(plan: string): Promise; observe(executed: string): Promise; reflect(observation: string, previousIteration: LoopIteration | null): Promise; refine(reflection: string): Promise; } ``` ## Usage ```bash fable-agent run "Your goal" --loop 10 ``` ## Key Rules - The executor determines the model — swap it to route phases differently - Hooks: `onPhase`, `onIteration`, `onConverge` for observability - The loop converges via rubric criteria, not iteration count