Loop Engineering: Designing AI's Self-Driving Systems

What Is Loop Engineering?

Definition (Addy Osmani, June 2026): Loop engineering is replacing yourself as the person who prompts the agent. You design the system that does it instead. The loop is a recursive goal where you define a purpose and the AI iterates until complete.

Simply put: Loop Engineering = letting the system start its own workflows.

Example:

  • Traditional way: You discover bug → You say “fix this bug” → AI fixes it
  • Loop Engineering: System automatically discovers bug → System says “fix this bug” → AI fixes it

Origins

The evolution of this concept:

ReAct (Foundation)

  • Yao et al. 2022, ICLR 2023
  • Reasoning + Action framework, laid the foundation for loop thinking

Peter Steinberger’s Viral Tweet

  • June 5, 2026, 5M+ views
  • First明确提出 “should design loops, not prompt agents”

Addy Osmani’s Blog Post

  • June 7, 2026, addyosmani.com
  • Officially named and structured the complete framework

Mature Tool Ecosystem

  • Claude Code 2.0 (Boris, June 2026)
  • OpenHands
  • Other loop engineering tools

Five Building Blocks (Addy Osmani’s Framework)

1. Automations

Purpose: Scheduled discovery and triage Core: /loop, /goal primitives Example: Scheduled GitHub issue scanning, categorized by priority

Why it matters:

  • Automated discovery is where loops begin
  • Without auto-discovery, humans still need to “find work”

2. Worktrees

Purpose: Parallel agent isolation Core: Use git worktrees for parallel processing Example: Simultaneously handle 3 different bugs, each with independent environments

Why it matters:

  • Prevents AI from “polluting” each other’s context
  • True parallel processing, not simulated

3. Skills

Purpose: Codifying project knowledge Core: SKILL.md files Example: Each project has its own skill documentation telling AI the project’s rules

Why it matters:

  • Project knowledge isn’t lost when conversations end
  • AI understands project-specific rules and conventions

4. Plugins/Connectors

Purpose: External world connection Core: MCP protocol, issue trackers, CI/CD integration Example: Auto-create PRs, run CI, update project documentation

Why it matters:

  • Loops aren’t closed; they interact with the real world
  • Complete “from problem to deployment"闭环

5. Sub-agents

Purpose: Specialized agents Core: Separate maker and checker agents Example:

  • Maker: Write code, modify files
  • Checker: Validate output, test safety

Why it matters:

  • Specialized division of labor is more reliable than single agents
  • Checker agents prevent maker errors

+ State

Not an independent block, but crucial: Purpose: Persistent memory Core: Markdown files, Linear boards, persistent storage outside conversations Example: Project status, task progress, list of resolved issues

Why it matters:

  • Loops have memory and don’t repeat the same work
  • State makes loops predictable and reliable

Classic Loop Patterns

OODA Loop (Observe → Orient → Decide → Act)

Use case: Quick response decision making Example:

  • Observe: Monitor code changes
  • Orient: Analyze impact of changes
  • Decide: Decide if testing is needed
  • Act: Run relevant tests

Advantage: Fast iteration, suitable for dynamic environments

PDCA Loop (Plan → Do → Check → Act)

Use case: Quality assurance workflows Example:

  • Plan: Create code review plan
  • Do: Execute code review
  • Check: Check for issues
  • Act: Fix discovered issues

Advantage: Quality-oriented, suitable for formal development

Reflection Loop (Execute → Evaluate → Reflect → Improve)

Use case: Systems needing continuous optimization Example:

  • Execute: Run AI coding tasks
  • Evaluate: Assess output quality
  • Reflect: Analyze why it succeeded/failed
  • Improve: Optimize strategies and methods

Advantage: Continuous learning, suitable for long-term improvement

Explore-Exploit Loop (New paths vs known optimizations)

Use case: Balance between innovation and efficiency Example:

  • Explore: Try new algorithm implementations
  • Exploit: Optimize proven algorithms
  • Explore again: Explore new optimization directions

Advantage: Balances innovation and stability

Getting Started

Simple loop example: A script that checks GitHub issues, assigns them to agents, runs fixes, opens PRs, and reports results

bash
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash
# 1. Discover new issues
issues=$(gh issue list --state open --limit 5)

# 2. Assign to agents
for issue in $issues; do
  # Create git worktree
  git worktree add ../fix-$issue
  
  # Run agent
  oh-my-opencode --goal "Fix issue #$issue" --worktree ../fix-$issue
  
  # Commit PR
  cd ../fix-$issue
  git commit -m "Fix #$issue"
  gh pr create --title "Fix #$issue"
  cd ..
  
  # Cleanup
  git worktree remove ../fix-$issue
done

Current Challenges

Termination Problem

Challenge: How to avoid infinite loops Example: AI keeps trying to fix the same bug with wrong approaches Solution: Set maximum iterations, timeout mechanisms

Resource Consumption

Challenge: Token cost control Example: Long-running loops may consume大量 tokens Solution: Smart caching, batch processing, limit loop depth

Drift Control

Challenge: Maintain alignment with original goals Example: AI deviates from original goal, doing related but incorrect things Solution: Regular goal consistency checks, set constraints

Interpretability

Challenge: Debugging black-box loops Example: When loops fail, it’s hard to know which part failed Solution: Detailed logs, state snapshots, visualization tools

Future Outlook

This is the newest paradigm (June 2026), still in early stages with no standard practices yet.

The next evolution might be Swarm Engineering—multiple agents collaborating in networks.

Benefits of starting Loop Engineering practice now:

  • 2026 is still early, tech stack is rapidly evolving
  • Can influence standard formation
  • Gain competitive advantage early

Remember: Loop Engineering is not the endpoint, but a new starting point in AI engineering evolution.


This is post 8 in the “AI Engineering Paradigms” series. Reading in sequence (weights 10→20→30→40→50→60→70→80→90…) provides the best experience.