Loop Engineering — from skills to autonomous feedback loops
"A skill answers a question. A loop closes it."
Harness Engineering constrains what an agent can do. Loop Engineering defines what an agent keeps doing — autonomously, cyclically, and with explicit feedback edges that turn individual skills into self-correcting systems.
Relationship to Harness Engineering
Loop Engineering does not replace the harness — it builds on top of it. It is the outermost layer in a progression that contains all prior layers:
Prompt Engineering (2022–2024)
└─ Context Engineering (2025)
└─ Harness Engineering (early 2026)
└─ Loop Engineering (2026)
Each layer wraps and contains the ones before it. You still write prompts, you still curate context, you still build a harness. Loop engineering is the part where all of that gets put into motion and given a rhythm — designing a cycle you trust enough to walk away from.
| Layer | Responsibility | Artifact |
|---|---|---|
| Prompt | Wording of individual instructions | Prompts within SKILL.md |
| Context | Everything the model sees at inference time | .omao/ state, ontology, retrieved docs |
| Harness | Safety of individual tool calls | policies, enforce.py, PreToolUse hooks |
| Loop | Orchestration of skill sequences into autonomous cycles | loops: section in *.oma.yaml |
The Triple Feedback Loop, realized
The ontology-engineering document defines three nested loops conceptually. Loop Engineering makes them executable:
| Loop | Cadence | OMA implementation | Skills involved |
|---|---|---|---|
| Quality Loop | 1h + event-driven | loops.quality-loop | continuous-eval, self-improving-loop, autopilot-deploy |
| Incident Loop | event-driven | loops.incident-loop | anomaly-detection, root-cause-analysis, automated-remediation, slo-management |
| Cost Loop | 6h + event-driven | loops.cost-loop | cost-governance, anomaly-detection, predictive-scaling, slo-management |
Anatomy of a loop
Every loop follows the same structural pattern:
┌─────────────────────────────────────────────────────────┐
│ LOOP DEFINITION │
├──────────┬──────────────────────────────────────────────┤
│ mode │ continuous (monitoring) or event-driven (goal)│
│ cadence │ When does the loop tick? (cron/duration) │
│ trigger │ What events start it outside cadence? │
│ steps │ Ordered skill sequence with dependencies │
│ feedback │ Explicit edges forming the cycle │
│ gate │ Where does a human approve? (severity-based) │
│ exit │ When is the loop done? (verifier.passes) │
│ budget │ How much can it spend? (tokens/cost/time) │
│ breaker │ When does the loop halt itself? │
│ escalate │ Where does it hand off when stuck? │
└──────────┴──────────────────────────────────────────────┘
Steps follow Discovery → Triage → Modify → Verify
Each loop's steps map to this 4-phase pattern (based on the "4단계 순환 휠"):
- Discovery — Automation wakes up, checks state files, collects signals
- Triage — Analyzes signals, determines if action is needed. If no actionable items → skip remaining, idle until next tick
- Modification — Executes the change in an isolated worktree (sub-agent writes code, never in main)
- Verification — Sub-agent reviews, runs checks, creates PR if passing
The feedback edge (verify -> discover) closes the loop: after verification,
the next discovery cycle begins.
The critical design principle: "이 단계들 중 어느 것에도 직접 프롬프트를 던지지 않았다." (You designed this once. You don't manually prompt any of these stages.)
Termination model — layered exits
Loop engineering's hardest problem is knowing when to stop. OMA implements layered termination with multiple independent exit paths:
# Pseudocode equivalent of OMA's termination model
state = init_state(goal)
for iteration in range(max_iterations): # hard cap
result = run_iteration(state, steps)
if result.skip_remaining: # Triage said "nothing to do"
sleep_until_next_cadence()
continue
state = update(state, result)
if exit_when_satisfied(state): # verifier.passes
return success(state)
if no_progress(state): # same error N times
return escalate_to_human(state)
if budget_exhausted(state): # tokens/cost/time
return escalate_to_human(state)
return escalate_to_human(state) # max_iterations exceeded
The 5 exit paths
| Exit path | Trigger | Behavior |
|---|---|---|
| Normal success | exit_when condition satisfied | Loop returns to idle (continuous) or completes (event-driven) |
| Early skip | skip_remaining_if on Triage step | This iteration ends early, loop sleeps until next tick — NOT a termination |
| No progress | Same state repeated N times | Escalation to human with trace |
| Budget exhausted | Token/cost/time limit hit | Escalation with partial progress |
| Max iterations | Hard cap reached | Escalation — prevents infinite loops |
| Circuit breaker | Consecutive failures | Loop halted, cooldown period, then retry |
Continuous vs Event-driven
| Aspect | mode: continuous | mode: event-driven |
|---|---|---|
| Starts | On cadence tick (e.g. every 1h) | On trigger event (alert, signal) |
| "Exit" means | Skip this iteration, sleep until next tick | Loop run is complete, go idle |
exit_when | Pauses until next cadence | Fully terminates the run |
| Typical use | Quality monitoring, cost monitoring | Incident response |
| Never truly stops | Correct — it's a monitoring daemon | Correct — it's a task runner |
skip_remaining_if — the Triage gate
This is the most common "exit" in practice. Most iterations of a continuous loop find nothing actionable:
steps:
- id: discover
skill_ref: continuous-eval
skip_remaining_if: "no_regression_detected" # ← 90% of iterations end here
- id: triage
skill_ref: self-improving-loop
depends_on: [discover]
skip_remaining_if: "no_actionable_proposal" # ← most of the rest end here
- id: modify
...
This means the full Modify → Verify cycle only runs when there's genuinely something to fix. The loop stays cheap and fast in the common case.