Skip to content

Latest commit

 

History

History
49 lines (32 loc) · 2.39 KB

File metadata and controls

49 lines (32 loc) · 2.39 KB

Chapter 08 — Feedback loop (iteration and self-repair)

Simple explanation

The first generated site is rarely perfect. A feedback loop means: detect problems, tell the agent exactly what failed, and regenerate only what must change—like revising an essay with teacher comments.

Neighbors: Chapter 03 — Workflow · Chapter 16 — Context, LLM I/O, files · Chapter 05 — Prompts / Feedback engine · Chapter 12 — Common issues · Algorithm context: README.md (repair path fbA / fbBrep*incRgenCall)

Deep technical breakdown

Automated loop: validator.errors[]RepairBriefPatchBundle (delta) → re-run checks until pass or max retries.
Human loop: UI shows diff + preview URL; user comments create a new RepairBrief with source: human.
Diff-based updates: prefer unified diffs or structured patches to avoid rewriting entire files (smaller prompts, fewer regressions). Track baseCommit so retries apply on consistent parent.

Mermaid diagram

flowchart LR
  gen[Generate_v1]
  val[Validate]
  fb[Feedback_brief]
  gen2[Generate_v2_delta]

  gen --> val
  val -->|"errors"| fb
  fb --> gen2
  gen2 --> val
  val -->|"pass"| done[Ship]
Loading

That loop is the same as the fbA / fbBrepair_count_lt_R_repairincrement_repair_countgenCall region in the main job algorithm diagram in README.md and Chapter 03 — Workflow. Keep those diagrams aligned when you change repair policy.

Real example

TypeScript error TS2307 missing CSS module → feedback brief goal: “add Hero.module.css with class names referenced in TSX.” Codegen issues add patch only for CSS file.

Challenges and pitfalls

  • Wobble: fix A unfixes B—use nonGoals and snapshot tests on critical sections.
  • Unbounded scope: user asks for new feature during bugfix—route to new job.

Tips and best practices

  • Keep a patch budget (max files touched per repair).
  • Show users a side-by-side diff with Figma frame thumbnail.

What most people miss

Successful loops depend on error causality: validators must attribute errors to specific files and nodes; otherwise the LLM guesses.