<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Loop Engineering on AI Vault</title><link>https://namphuongtran.github.io/ai-vault/building/loop-engineering/</link><description>Recent content in Loop Engineering on AI Vault</description><generator>Hugo</generator><language>en</language><atom:link href="https://namphuongtran.github.io/ai-vault/building/loop-engineering/index.xml" rel="self" type="application/rss+xml"/><item><title>The Parts of a Loop</title><link>https://namphuongtran.github.io/ai-vault/building/loop-engineering/anatomy/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://namphuongtran.github.io/ai-vault/building/loop-engineering/anatomy/</guid><description>&lt;p&gt;&lt;em&gt;What&amp;rsquo;s inside a production loop.&lt;/em&gt;&lt;/p&gt;&#10;&lt;h2 id="what-it-is"&gt;What it is&lt;/h2&gt;&#10;&lt;p&gt;A production loop has six parts. The worker — the agent doing the task — is the &lt;em&gt;least&lt;/em&gt;&#10;interesting one; the parts around it are what turn a demo into something you can trust&#10;unattended.&lt;/p&gt;&#10;&lt;pre class="mermaid"&gt;flowchart LR&#10; D[Discovery - finds work] --&amp;gt; B[Backlog and decomposition]&#10; B --&amp;gt; W[Worker loop - does the task]&#10; W --&amp;gt; V[Validator - checks the result]&#10; V --&amp;gt;|pass| Done[Merge and record]&#10; V --&amp;gt;|fail, with feedback| W&#10; S[Stop conditions - rounds, tokens, time] -.-&amp;gt; W&#10; M[Memory and anchors - skills, project rules] -.-&amp;gt; W&lt;/pre&gt;&#10;&lt;h2 id="the-six-parts"&gt;The six parts&lt;/h2&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Discovery / automations&lt;/strong&gt; — finds work without a human trigger: a schedule, a webhook, a&#10;scanner. This is what lets a loop run &lt;em&gt;unattended&lt;/em&gt;; see&#10;&lt;a href="https://namphuongtran.github.io/ai-vault/building/loop-engineering/levels/"&gt;the four levels&lt;/a&gt; for the trigger types and where to put them.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Decomposition&lt;/strong&gt; — an orchestrator breaks the goal into tasks a worker can own. See&#10;&lt;a href="https://namphuongtran.github.io/ai-vault/building/loop-engineering/fleet-looping/"&gt;fleet looping&lt;/a&gt; when this goes multi-level.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Worker&lt;/strong&gt; — an agent with &lt;a href="https://namphuongtran.github.io/ai-vault/foundations/make-it-act/tool-function-calling/"&gt;tools&lt;/a&gt; and&#10;&lt;a href="https://namphuongtran.github.io/ai-vault/foundations/make-it-act/mcp/"&gt;MCP connectors&lt;/a&gt;; parallel workers get &lt;strong&gt;git worktrees&lt;/strong&gt;&#10;so they don&amp;rsquo;t overwrite each other.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Validator&lt;/strong&gt; — a second judgment (&lt;a href="https://namphuongtran.github.io/ai-vault/deep-dives/evaluation-in-practice/"&gt;LLM-as-judge&lt;/a&gt;,&#10;a test suite, or both) that decides pass/fail — never the worker grading itself.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Stop conditions&lt;/strong&gt; — max rounds, token budget, loop detection: the AutoGPT lesson,&#10;inherited from the &lt;a href="https://namphuongtran.github.io/ai-vault/building/agent-harness/"&gt;harness&lt;/a&gt;.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Memory &amp;amp; anchors&lt;/strong&gt; — &lt;a href="https://namphuongtran.github.io/ai-vault/building/agent-harness/"&gt;skills&lt;/a&gt;, project rules,&#10;and &lt;a href="https://namphuongtran.github.io/ai-vault/deep-dives/agent-memory/"&gt;agent memory&lt;/a&gt; so each round builds on the&#10;last instead of rediscovering it.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 id="example"&gt;Example&lt;/h2&gt;&#10;&lt;p&gt;A nightly dependency-update loop: &lt;strong&gt;discovery&lt;/strong&gt; is the cron trigger; &lt;strong&gt;decomposition&lt;/strong&gt; splits&#10;&amp;ldquo;update all packages&amp;rdquo; into one task per package; the &lt;strong&gt;worker&lt;/strong&gt; bumps a version and runs the&#10;build; the &lt;strong&gt;validator&lt;/strong&gt; is the test suite; &lt;strong&gt;stop conditions&lt;/strong&gt; cap it at three fix attempts&#10;per package; &lt;strong&gt;anchors&lt;/strong&gt; are the project&amp;rsquo;s upgrade notes so it doesn&amp;rsquo;t re-learn known&#10;breakages. Only the worker is an &amp;ldquo;agent&amp;rdquo; — the other five are what make it safe to leave&#10;running overnight.&lt;/p&gt;</description></item><item><title>The Four Levels of Loops</title><link>https://namphuongtran.github.io/ai-vault/building/loop-engineering/levels/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://namphuongtran.github.io/ai-vault/building/loop-engineering/levels/</guid><description>&lt;p&gt;&lt;em&gt;How many loops you need, and what each one buys.&lt;/em&gt;&lt;/p&gt;&#10;&lt;h2 id="what-it-is"&gt;What it is&lt;/h2&gt;&#10;&lt;p&gt;The four levels are not four kinds of loop. They are &lt;strong&gt;one loop wrapped four times&lt;/strong&gt; — each&#10;level surrounds the level below it and adds a property the inner loop cannot produce on its&#10;own. So the question is never &amp;ldquo;which loop is this?&amp;rdquo; but &lt;strong&gt;how many do I need?&lt;/strong&gt;&lt;/p&gt;&#10;&lt;pre class="mermaid"&gt;flowchart TB&#10; subgraph L4[&amp;#34;Level 4 · Hill climbing — the harness gets better&amp;#34;]&#10; subgraph L3[&amp;#34;Level 3 · Event-driven — something starts the run&amp;#34;]&#10; EV[Event - chat message, schedule, repo hook] --&amp;gt; M&#10; subgraph L2[&amp;#34;Level 2 · Verification — a grader decides what done means&amp;#34;]&#10; subgraph L1[&amp;#34;Level 1 · Agent loop — the work gets done&amp;#34;]&#10; M[Model] --&amp;gt; T[Tool call] --&amp;gt; O[Observation] --&amp;gt; M&#10; end&#10; M --&amp;gt; R[Agent output]&#10; R --&amp;gt; G{Meets the rubric}&#10; G --&amp;gt;|no, with feedback| M&#10; end&#10; G --&amp;gt;|yes| OUT[Result posted back to the system]&#10; end&#10; OUT --&amp;gt; TR[Traces of past runs]&#10; TR --&amp;gt; AN[Analysis agent - finds the repeating failure]&#10; AN --&amp;gt; UP[Better prompts, skills, memory]&#10; UP -.-&amp;gt; M&#10; end&lt;/pre&gt;&#10;&lt;h2 id="the-four-levels"&gt;The four levels&lt;/h2&gt;&#10;&lt;table&gt;&#10;&#9;&lt;thead&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;Level&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;What it adds&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;What it costs&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;Detailed in&lt;/th&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/thead&gt;&#10;&#9;&lt;tbody&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;1 · Agent loop&lt;/strong&gt; — the model calls tools until it decides the task is done&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Automation&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;A model call per step&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;a href="https://namphuongtran.github.io/ai-vault/building/agent-harness/"&gt;The agent harness&lt;/a&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;2 · Verification loop&lt;/strong&gt; — a grader scores the result against a rubric and sends failures back with feedback&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Reliability&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Latency and tokens on every retry&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;a href="https://namphuongtran.github.io/ai-vault/building/loop-engineering/open-vs-closed/"&gt;Open vs. closed loops&lt;/a&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;3 · Event-driven loop&lt;/strong&gt; — a signal from outside starts the run&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Reach — the agent lives where the work already happens&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Infrastructure, and the risk of firing on the wrong thing&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;This page&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;4 · Hill-climbing loop&lt;/strong&gt; — traces from past runs feed an agent that improves the harness&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Improvement over time&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;An &lt;a href="https://namphuongtran.github.io/ai-vault/deep-dives/evaluation-in-practice/"&gt;eval set&lt;/a&gt; you trust&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;a href="https://namphuongtran.github.io/ai-vault/deep-dives/self-improving-agents/"&gt;Self-improving agents&lt;/a&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;p&gt;Level 2 also changes the &lt;em&gt;economics&lt;/em&gt; of level 1. A grader that keeps sending work back is a&#10;correctness budget you can spend elsewhere: a cheaper model plus a strict grader often beats&#10;the strongest model alone, because the grader catches what the cheap model got wrong and the&#10;retries still cost less. You are trading latency for money. See&#10;&lt;a href="https://namphuongtran.github.io/ai-vault/foundations/work-with-models/choosing-a-model/"&gt;choosing a model&lt;/a&gt; for the tier ladder that trade runs on.&lt;/p&gt;</description></item><item><title>Open vs. Closed Loops</title><link>https://namphuongtran.github.io/ai-vault/building/loop-engineering/open-vs-closed/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://namphuongtran.github.io/ai-vault/building/loop-engineering/open-vs-closed/</guid><description>&lt;p&gt;&lt;em&gt;The architecture axis — which shape to choose, and when.&lt;/em&gt;&lt;/p&gt;&#10;&lt;h2 id="what-it-is"&gt;What it is&lt;/h2&gt;&#10;&lt;p&gt;The names come from control theory: a &lt;strong&gt;closed&lt;/strong&gt; loop feeds its output back and corrects&#10;against a reference; an &lt;strong&gt;open&lt;/strong&gt; loop runs without that feedback path. For agents:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Open loop&lt;/strong&gt; — the agent gets a goal and freedom: it explores, reasons, and decides its&#10;own next steps. There are no predefined success criteria; the run ends when the agent&#10;declares itself done or the budget runs out, and a &lt;em&gt;human&lt;/em&gt; judges the output afterwards.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Closed loop&lt;/strong&gt; — the goal ships with &lt;strong&gt;explicit success criteria and a validator&lt;/strong&gt; defined&#10;&lt;em&gt;before&lt;/em&gt; the run. Every iteration is measured against them; failures feed back into the&#10;next round; &amp;ldquo;done&amp;rdquo; means &lt;em&gt;the threshold was passed&lt;/em&gt;, not &amp;ldquo;the agent felt finished&amp;rdquo;.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;pre class="mermaid"&gt;flowchart LR&#10; subgraph O[&amp;#34;Open loop&amp;#34;]&#10; G1[Goal] --&amp;gt; A1[Agent explores and decides] --&amp;gt; R1[Output]&#10; R1 --&amp;gt; H1[Human judges afterwards]&#10; end&#10; subgraph C[&amp;#34;Closed loop&amp;#34;]&#10; G2[Goal &amp;#43; criteria] --&amp;gt; W2[Worker] --&amp;gt; V2[Validator]&#10; V2 --&amp;gt;|pass threshold| D2[Done]&#10; V2 --&amp;gt;|fail &amp;#43; feedback| W2&#10; end&lt;/pre&gt;&#10;&lt;table&gt;&#10;&#9;&lt;thead&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;Question&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;Open loop&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;Closed loop&lt;/th&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/thead&gt;&#10;&#9;&lt;tbody&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Who decides the next step?&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;The model, at runtime&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;The process, designed upfront&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;What does &amp;ldquo;done&amp;rdquo; mean?&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Agent self-declares, or budget dies&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Validator passes a threshold&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Cost per run&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Unpredictable&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Bounded (rounds × budget)&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Result across runs&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Varies&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Repeatable&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Can it improve?&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Hard — nothing is measured&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Run over run — every run is scored&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Main risk&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Token burn, drift, quality by luck&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;A wrong rubric gets enforced at machine speed; solutions outside the frame get missed&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;h2 id="when-to-choose-which"&gt;When to choose which&lt;/h2&gt;&#10;&lt;p&gt;&lt;strong&gt;Choose open when&lt;/strong&gt; the problem itself is unexplored: you don&amp;rsquo;t yet know what &amp;ldquo;good&amp;rdquo; looks&#10;like, it&amp;rsquo;s a one-off spike (&amp;ldquo;figure out why these tests are flaky&amp;rdquo;, &amp;ldquo;map this legacy&#10;codebase&amp;rdquo;), and a human will read the output directly. Exploration is the one thing a closed&#10;loop &lt;em&gt;can&amp;rsquo;t&lt;/em&gt; do — its criteria would have to exist already.&lt;/p&gt;</description></item><item><title>Fleet Looping</title><link>https://namphuongtran.github.io/ai-vault/building/loop-engineering/fleet-looping/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://namphuongtran.github.io/ai-vault/building/loop-engineering/fleet-looping/</guid><description>&lt;p&gt;&lt;em&gt;The topology and oversight axes — scaling looping up.&lt;/em&gt;&lt;/p&gt;&#10;&lt;h2 id="what-it-is"&gt;What it is&lt;/h2&gt;&#10;&lt;p&gt;At the simplest level, one agent loops on its own work: research → draft → evaluate against&#10;the goal → fix the weak spots → repeat until it&amp;rsquo;s good enough. You no longer prompt each step;&#10;the agent runs the loop for you.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Fleet looping&lt;/strong&gt; is that same idea at scale. An &lt;strong&gt;orchestrator&lt;/strong&gt; takes the overall goal and&#10;breaks it into parts; it hands each part to a &lt;strong&gt;specialist agent&lt;/strong&gt;; each specialist can&#10;further delegate narrower work to its own &lt;strong&gt;sub-agents&lt;/strong&gt;. The whole task tree keeps cycling&#10;through four phases until the goal is met:&lt;/p&gt;</description></item><item><title>Building a Loop</title><link>https://namphuongtran.github.io/ai-vault/building/loop-engineering/building-a-loop/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://namphuongtran.github.io/ai-vault/building/loop-engineering/building-a-loop/</guid><description>&lt;p&gt;&lt;em&gt;How you actually build one — and a worked example.&lt;/em&gt;&lt;/p&gt;&#10;&lt;h2 id="sdk-or-claude-code--codex-off-the-shelf"&gt;SDK, or Claude Code / Codex off the shelf?&lt;/h2&gt;&#10;&lt;p&gt;The honest answer: &lt;strong&gt;start with the tools — you already own a production-grade loop.&lt;/strong&gt;&#10;Claude Code and Codex &lt;em&gt;are&lt;/em&gt; loop products: harness, tools, skills, MCP, stop conditions all&#10;built in. There&amp;rsquo;s a ladder, and each rung must be earned:&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;&lt;strong&gt;Use the tool interactively&lt;/strong&gt; — you are the orchestrator. Fine for daily work.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Script the tool&lt;/strong&gt; — run it headless in CI on a schedule with a fixed prompt, skills, and&#10;MCP servers. This is already loop engineering — no SDK, and it covers most closed-loop&#10;automation (nightly triage, lint-fix sweeps, doc updates).&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Code on an SDK&lt;/strong&gt; (&lt;a href="https://namphuongtran.github.io/ai-vault/building/tooling-and-frameworks/"&gt;Agent SDK, LangGraph, Microsoft Agent Framework&lt;/a&gt;)&#10;only when the loop needs what a tool can&amp;rsquo;t give you: &lt;strong&gt;custom topology&lt;/strong&gt; (a fixer and a&#10;reviewer with different models talking to each other), &lt;strong&gt;your own validator logic and&#10;thresholds&lt;/strong&gt;, or the loop &lt;em&gt;is your product&lt;/em&gt; and needs its own UI, state, and versioning.&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;Rule of thumb: if your loop is &lt;em&gt;one worker + a schedule&lt;/em&gt;, script the tool you have. If it&amp;rsquo;s&#10;&lt;em&gt;several roles negotiating&lt;/em&gt;, that&amp;rsquo;s when an SDK earns its complexity.&lt;/p&gt;</description></item></channel></rss>