docs/01-agent-loop.md

01 — Agent Loop

The plan-act-observe-reflect loop. Every turn the agent takes is one trip through this cycle. Depth and step caps prevent runaway loops. Error recovery is deterministic. Hooks fire at every transition. The same loop underlies interactive turns, plan-mode runs, subagent invocations, and long-horizon /goal runs.

Loop semantics

┌─────────┐     ┌─────────┐     ┌────────────┐     ┌──────────┐
│  plan   │ ──▶ │   act   │ ──▶ │  observe   │ ──▶ │ reflect  │
└─────────┘     └─────────┘     └────────────┘     └──────────┘
     ▲                                                   │
     └───────────────── next step, or the turn ends ─────┘

When the agent needs you

Runtime note

The engine adapter in packages/core (createDshAgentLoop) implements the run()/LoopEvent surface, projecting the engine's session log onto the LoopEvent union. The former in-repo AgentLoop was removed when Picasso adopted the engine (see architecture).