Loop Engineering from First Principles — Kyle Mistele, HumanLayer
Jul 25, 2026 · 17:57
Kyle Mistele argues that the fix for AI-generated 40,000-line pull requests is not a better prompt but a better loop, borrowing from control theory: a sensor measures the gap between current and desired codebase state, a controller picks the smallest incremental change, and an actuator agent applies it using hand-written golden patterns. Mistele illustrates with HumanLayer's own loop that migrates their RPC API to Effect one procedure at a time, using AST grep as a deterministic sensor, a controller that selects the smallest unmigrated procedure, and an actuator agent gated by deterministic CI running a single iteration per day. The loop tracks its own PRs in version control, refuses to stack a new change while an earlier one is still open, and includes a feedback file and comment trigger for humans to re-steer it. Mistele concludes that this design makes the code incrementally better, readable, and verifiable, solving the problem of unreadable mass-generated code.