Loop and Graph Engineering: The Dual Topologies of Agentic Systems
Modern AI engineering has moved past simple completion prompts into autonomous agent architectures. As practitioners scale these systems from prototype scripts to long-horizon enterprise engines, two foundational paradigms have crystallized: Loop Engineering and Graph Engineering.
Understanding when to run in a tight execution loop versus when to structure execution as an explicit state graph is the difference between an agent that reliably ships code and one that burns tokens into context rot.
1. Loop Engineering: Tools in a Bounded Iteration
At its simplest, an LLM agent is defined as an LLM running tools in a loop to achieve a goal (as articulated by Simon Willison).
flowchart LR
UO["User Objective"] --> LLM["LLM Decides Action"]
LLM --> TE["Tool Execution"]
TE --> TO["Tool Output"]
TO --> LLM
In Loop Engineering, the core focus is local mechanical feedback:
- Tight Tool Feedback: The agent exercises its own code immediately via terminal test runners or linters (TDD with agents).
- Brute Force Problem-Solving: Given clear terminal error messages and deterministic constraints, the agent iterates until green without requiring human steering on every turn.
- The Smart Zone Limit: Loops excel within the model’s peak reasoning window — the smart zone, typically the first ~150k tokens of a session on frontier models. Once execution transcripts accumulate dozens of intermediate bash runs and stack traces, the loop suffers from prompt bloat and degrades.
2. Graph Engineering: Partitioned Topologies and State Separation
When a task exceeds a single context window or requires multi-disciplinary exploration (such as large codebase refactors or open-ended literature synthesis), running a single loop is a recipe for catastrophic context decay.
This is where Graph Engineering takes over. Anthropic’s production Research system describes this as “a multi-agent architecture with an orchestrator-worker pattern, where a lead agent coordinates the process while delegating to specialized subagents that operate in parallel” (source):
flowchart LR
LO["Lead Orchestrator"] --> SA["Subagent A: Web Explorer"]
LO --> SB["Subagent B: Code Inspector"]
LO --> SC["Subagent C: Eval Runner"]
SA -->|Artifact / Summary| SYN["Synthesizer / Critic"]
SB -->|Artifact / Summary| SYN
SC -->|Artifact / Summary| SYN
- Topological Separation of Concerns: Rather than forcing one agent to hold the full state, work is delegated across dedicated worker nodes with isolated context windows (multi-agent orchestration).
- Artifacts over Telephone Games: Subagents do not stream raw tokens back to the coordinator. They write structured markdown artifacts or files to disk and return concise summaries (handoff artifacts).
- Deterministic Gates: Transition edges between graph nodes are guarded by programmatic assertions, schema validators, or automated fitness functions (conformance suites as fitness functions).
3. The Synthesis: Composing Loops Inside Graph Nodes
Production AI architectures do not choose between loops and graphs—they nest them.
- The Graph defines the macro workflow: High-level state transitions, specification drafting, ticket decomposition, and consensus gates.
- The Loop executes the micro task: Inside an individual graph node (e.g., implementing a single ticket), a focused worker agent operates in a rapid, uninhibited tool loop until its verifiable test passes.
By isolating the execution loop to a clean subagent and returning only verified diffs and test results to the parent graph, you maintain zero context leakage while harnessing full agentic autonomy.