Agent loops
Agent loops
Agent loops turn one-shot AI agent work into bounded cycles with a trigger, objective, verifier, stop condition, budget, and safe output.

Answer-first definition
An agent loop is a reusable operating cycle around an AI agent. It defines what starts the work, what evidence the agent must check, what it may touch, how much budget it can spend, and what requires human approval.
The practical version is not open-ended autonomy. It is a leash with a verifier.
Agent loop anatomy
| Field | Question |
|---|---|
| Trigger | What starts the next run or turn? |
| Objective | What should be true when it is done? |
| State | Where does progress survive outside the chat window? |
| Verifier | What evidence proves success? |
| Budget | What hard cap prevents token bonfires? |
| Approval boundary | What must a human review first? |
DetailsUseful starting patterns
| Loop | Category | Difficulty | Cadence | Verification |
|---|---|---|---|---|
| API Contract Drift | Engineering | Intermediate | After API changes or SDK releases | Server behavior, client types, examples, and docs agree on request/response contracts. |
| Architecture Rubric Refactor | Engineering | Advanced | When architecture work has a defined scope | Scoped module meets the written rubric, tests pass, and unresolved objections are explicit. |
| CI Optimization | Engineering | Advanced | Monthly or when CI is painful | CI p50/p95 improves against the same workflow without weakening tests or hiding failures. |
| Claude Code Repo Readiness | Engineering | Beginner | Before major agent work | Repo has agent instructions, documented commands, architecture notes, risk areas, and a docs/loops scaffold. |
| Cold Load Trim | Engineering | Advanced | When first visit feels heavy | Initial screen downloads fewer bytes while screenshots and behavior remain unchanged. |
| Fresh Clone Onboarding | Engineering | Intermediate | Before onboarding | A clean machine reaches the documented ready state using only the README. |
| Project Docs Freshness | Engineering | Beginner | Nightly or after meaningful code changes | Changed behavior, APIs, CLI commands, config, and workflows are reflected in docs. Docs checks pass. |
| Test Flake Stabilizer | Engineering | Intermediate | When tests are inconsistent | The repaired test and full suite pass for the required consecutive-run streak. |
| Test and Logging Coverage | Engineering | Intermediate | Weekly or before release | Critical flows have useful tests and structured logs for representative success and failure paths. |
| Adversarial PR Review | Evaluation | Advanced | For meaningful PRs | An independent critic approves the unchanged version or only accepted findings remain. |
| Browser Quality Streak | Evaluation | Intermediate | Before release | N realistic scenarios pass consecutively, and earlier failures have regression coverage. |
| Open Loop and Stale Memory Cleanup | Knowledge | Beginner | Weekly | No current open loop is contradicted by recent daily or project notes. |
| Research to Artifact | Knowledge | Intermediate | Whenever research must support a decision | The artifact meets acceptance criteria, traces important claims to sources, and states uncertainty plainly. |
| Source Library Ingestion QA | Knowledge | Intermediate | After each source capture | Metadata complete, transcript/article state honest, useful takeaways present, and qmd retrieval verified or refreshed. |
| Agent Handoff Continuity | Operations | Intermediate | Before pausing or switching agents | A new agent can state goal, current state, proof, blockers, and next action without reading the whole transcript. |
| Agent Toolchain Health Check | Operations | Beginner | Weekly or before a heavy agent run | Critical tools authenticate, return sane output, and have a known fallback or blocker owner. |
| Living Story | Operations | Intermediate | Weekly or per project window | Every prior thread is carried forward, closed with evidence, or flagged stale/needs-review. |
| Production Error Sweep | Operations | Advanced | Daily or after incident | Actionable errors are fixed with reproduction or tests, or explicitly classified as noise. |