{"slug": "write-loops-not-prompts-why-ai-agents-work-better-when-they-iterate", "title": "Write Loops, Not Prompts: Why AI Agents Work Better When They Iterate", "summary": "OpenAI's technical post on Codex CLI and Philip Zeyliger's work at Sketch.dev demonstrate that AI agents using iterative loops outperform single-shot prompts for complex tasks. The agent loop, where the model repeatedly calls tools and accumulates context, enables error correction and parallel automation, though it introduces challenges like context window management. Octo has built a workspace around this loop-based model to further streamline agent work.", "body_md": "Most people using LLMs are still stuck in prompt mode. You craft a careful instruction, send it off, get something back, tweak the wording, try again. It works for single-shot questions but falls apart the moment you need anything that involves multiple steps, quality checks, or batch work.\n\nBack in January OpenAI published a technical post called \"Unrolling the Codex agent loop\" where they broke down how Codex CLI actually works internally. The core concept is what they call the agent loop. The model receives input, runs inference, and either returns a final answer or requests a tool call. If it requests a tool call, the agent executes it, appends the result back into the prompt, and loops back to inference. This repeats until the model signals it's done.\n\nA few months earlier Philip Zeyliger at Sketch.dev wrote \"The Unreasonable Effectiveness of an LLM Agent Loop with Tool Use,\" a post that hit 447 points on Hacker News. His core implementation was 9 lines of Python. A while loop. Call the LLM, if it returns tool calls execute them and feed results back in, if it returns text you're done. Zeyliger described being genuinely surprised at how much mileage he got out of this simple structure. Tasks he used to handle manually, obscure git operations, merge conflict resolution, type error chains, he now lets the agent work through iteratively.\n\nThe difference between prompting and looping is fundamental. A prompt is a single exchange. You say something, the model replies, end of story. A loop is a structured process where the model keeps working, each tool call result gets appended to its context, and it reasons over progressively richer information until the job is actually done. In OpenAI's post they note that a single conversation turn can involve hundreds of tool calls, each one adding new information to the prompt for the next inference step.\n\nLoops solve problems that single prompts can't touch because they give the model room to be wrong and correct itself. It doesn't need to nail everything on the first attempt. It can try a command, see that it failed, read the error message, adjust its approach, and try again. Zeyliger mentions agents installing missing tools on their own, adapting when grep flags differ across systems, working through failures without human intervention. A prompt can describe desired behavior but it can't react to what actually happens when that behavior meets reality.\n\nContext accumulation is another piece. Every tool call output becomes part of the prompt for subsequent iterations, so by iteration ten the model has access to everything that happened in iterations one through nine. OpenAI discusses this at length in their post, noting that prompts grow with each turn and that conversation history is always included. The model is effectively building up a working memory of what it has tried and what happened. A fresh prompt every time starts from zero. A loop keeps the record.\n\nThen there's automation. Once you have a working loop you can run it across multiple tasks independently. When we moved content generation and code review workflows from manual prompting to loop-based execution, processing time dropped significantly because agents could work in parallel instead of waiting for a human to feed them the next instruction.\n\nLoops aren't free though. OpenAI's post goes into the performance implications of growing prompts, including their use of prompt caching to avoid re-sending unchanged context. Context window management is a real engineering problem when an agent makes hundreds of tool calls in a single turn, and these are problems you simply don't face when you're doing single-shot prompts.\n\nThis is where Octo comes in. We've been building a workspace called Octo around exactly this loop-based model of agent work, but we've taken the concept further than a simple while loop in a terminal.\n\nIn Octo, the loop is called a Loop. A Loop is a unit of work that emerges naturally from conversation in a chat interface. Instead of filling out a form to create a ticket, you describe what you want in natural language and assign it to an agent. The agent picks it up, executes it through its own internal agent loop, and delivers results back for review. When you approve, the Loop closes. When you send it back with feedback, the agent takes another pass using that feedback as input.\n\nWhat makes this different from running agent loops in a terminal is that we've built the human review step into the loop itself. In Codex and similar tools the agent decides when it's done. In Octo the agent delivers and a person decides whether it's actually done. The feedback loop between human and agent is first-class, not an afterthought. Every approval or rejection gets captured as Preferences, learned patterns that the agent references on future tasks. If you keep sending back reports saying \"too verbose, make it shorter,\" after a few rounds the agent just writes shorter reports by default.\n\nAgents in Octo aren't generic assistants either. Each agent is a digital worker with specific skills, project context, and a persistent identity. You might have one agent that's good at documentation, another at code review, another at research. You route work based on what each agent is good at, the same way you'd pick the right person on a real team. We support multiple AI runtimes including OpenClaw, Codex, Claude Code, and Hermes, so you're not locked into a single model vendor. Everything runs on your own infrastructure; your data stays on your network.\n\nOcto also supports different orchestration patterns for different kinds of work. Roundtable mode for brainstorming where all agents see each other's output. Critic mode where a reviewer agent checks work without the producer seeing the critique. Pipeline mode for sequential multi-step work where each agent only sees the previous step's output. Split mode for dividing large tasks into independent chunks. Swarm mode for creative work where multiple agents tackle the same problem and you pick the best result. These patterns matter because collaboration isn't one-size-fits-all; different work needs different information flows.\n\nThe product includes a Loop workspace with list and kanban views, project grouping, automation for scheduled and event-triggered agent pipelines, and search across all Loops and projects. There's a web and desktop app for the full workspace, mobile for quick reviews and notifications, a browser extension for bringing Octo context into any webpage, a CLI for agents to interact natively, and IM integration so you can spin up a Loop by mentioning an agent in a group chat.\n\nIf you're still writing prompts one at a time and manually iterating, try turning the interaction into a loop. Let the model execute, see what happens, feed the result back, and let it try again. The core idea is genuinely just a few lines of code, but it changes the relationship between you and the model from question-and-answer to actual collaboration.\n\nOcto is opening early access soon. You can follow progress on our GitHub.", "url": "https://wpnews.pro/news/write-loops-not-prompts-why-ai-agents-work-better-when-they-iterate", "canonical_source": "https://dev.to/mininglamp/write-loops-not-prompts-why-ai-agents-work-better-when-they-iterate-o0l", "published_at": "2026-07-08 02:24:34+00:00", "updated_at": "2026-07-08 02:58:30.931940+00:00", "lang": "en", "topics": ["large-language-models", "ai-agents", "ai-research", "developer-tools"], "entities": ["OpenAI", "Codex CLI", "Philip Zeyliger", "Sketch.dev", "Octo"], "alternates": {"html": "https://wpnews.pro/news/write-loops-not-prompts-why-ai-agents-work-better-when-they-iterate", "markdown": "https://wpnews.pro/news/write-loops-not-prompts-why-ai-agents-work-better-when-they-iterate.md", "text": "https://wpnews.pro/news/write-loops-not-prompts-why-ai-agents-work-better-when-they-iterate.txt", "jsonld": "https://wpnews.pro/news/write-loops-not-prompts-why-ai-agents-work-better-when-they-iterate.jsonld"}}