A plan-act-observe loop makes an AI coding agent iterative and interruptible: it forms a plan, takes an explicit tool action, observes the result, and adjusts the next action. In a payment-validation migration, the plan may cover library discovery, repository inspection, and proposed changes; execution then requests permission to read files or search the codebase. The human remains responsible for approving each operation. section 5.2.1
Use the loop as an operational control rather than treating an agent as an unrestricted code generator:
- Separate planning from implementation when the task needs review; Plan Mode establishes what should happen before execution begins. section 5.2.1
- Treat permissions as part of the workflow: Architect mode can inspect and propose, Code mode can edit within boundaries, and Ask mode answers questions. section 5.2.1
- Expect exploration to consume substantial time and tokens; live search follows references more flexibly than indexed retrieval but costs more latency and may still miss coverage. section 3.5.1
Repository migration with explicit approvals
An agent first proposes migrating payment validation, then asks to read PaymentService.py, search for currency validation, and inspect currency.py. Each approval advances the loop while preserving a human checkpoint. The same pattern can assign planning, implementation, and testing to agents with different permissions. section 5.2.1
Figure 3.7 Context-aware assistance flow. The developer's query is converted into an embedding, matched against the indexed codebase, and the most relevant chunks are injected into the prompt before the model generates its response.

Contrast the loop's live, reasoning-driven repository exploration with embedding-based retrieval, which injects indexed chunks before generation. section 3.5.1
