[research@ai4se] : ~ $ β–Œ
cd ../
[process] | | 8 min

# Inner Loop / Middle Loop / Outer Loop: The Three Closed Loops of Agent Work

Agent work isn't linear β€” it splits into three nested closed loops: the inner loop (code-test), the middle loop (task-review), and the outer loop (metrics-improvement). Understanding this model is foundational to designing AI4SE processes.

[workflow-design][process]

The Three-Loop Model

Outer Loop (weeks/months): Measure β†’ Improve Rules/Process/Methods
  └── Middle Loop (hours): Plan β†’ Execute β†’ Review
        └── Inner Loop (seconds/minutes): Code β†’ Test β†’ Fix

Key Activities per Loop

LoopCadenceDriven byOutput
InnerSeconds to minutesAgentCode + tests + immediate fixes
MiddleHours to daysHuman + AgentCompleted tasks + passing review
OuterWeeks to monthsHuman-ledMetrics β†’ updated Rules / Spec / Harness

Why the Three Loops Matter

  • Different loops need different metrics
  • Inner optimizes for speed, Middle optimizes for quality, Outer optimizes for the system
  • Optimizing only the Inner loop = a local-optimum trap

In Practice

  • Inner: leave it to the Agent, intervene minimally
  • Middle: place gates at Review and Plan
  • Outer: check metrics periodically, adjust global constraints