notes · 2026-09-13 · 2 min read · ai · agents

Agent loops: plan, tool, verify, repeat

Whether an AI agent works is decided by the loop, not the model. What I learned about loop design shipping ten apps solo and writing DevDNA.

"Agent" sounds like a lot of things but is one thing: a loop. Observe, plan, call a tool, verify the result, repeat until a stop condition. A better model does every step a little better; a bad loop makes the best model produce bad results. I call this loop engineering: designing the loop, not the prompt.

The four parts

  1. Observation. What can the agent look at? A file system, an API, a browser screenshot. It cannot manage what it cannot see. The biggest win while shipping apps was making the App Store Connect API the agent's eyes: version state, the review cart, price tables all became queryable.
  2. Plan. Short and reviewable. Long plans go stale with the first tool output.
  3. Tool. A good tool is narrow, deterministic, and fails honestly. "Submit" on its own is dangerous; it needs a gate in front of it. Ours is presubmit_gate.py: no IAP, a US-only price, an unpublished privacy label, all caught, and the agent cannot submit past them.
  4. Verification. The agent saying "done" is not enough. A screenshot, an HTTP 200, a counter going up. The second-source rule: before reporting a finding, see it another way. Most false alarms died there.

Memory

This is what I spent the most time on in DevDNA: an agent forgets when the conversation ends. For a team, decisions, standards and habits must live in written memory files, read at the start of every loop. Same in my own workflow: a project note per app, a reference note per trap. The agent's memory is files, not the conversation.

The stop condition

The most overlooked part. What does "complete" mean? Tests pass, the page returns 200, the user approved? A loop without a written stop condition either quits early or never stops. For hard-to-reverse work (deletion, publishing, money) the stop condition should be a human.

In short

The model is rented; the loop is yours. Widen the observation surface, narrow the tools and guard them with gates, verify every claim from a second source, write memory to files, write the stop condition first. I shipped ten apps with this loop; the model changed three times, the loop did not.