1.2 KiB
1.2 KiB
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:
interface PhaseExecutor {
plan(task: string, previousIteration: LoopIteration | null): Promise<string>;
execute(plan: string): Promise<string>;
observe(executed: string): Promise<string>;
reflect(observation: string, previousIteration: LoopIteration | null): Promise<string>;
refine(reflection: string): Promise<string>;
}
Usage
fable-agent run "Your goal" --loop 10
Key Rules
- The executor determines the model — swap it to route phases differently
- Hooks:
onPhase,onIteration,onConvergefor observability - The loop converges via rubric criteria, not iteration count