Skip to main content

The Four Loops That Replaced Prompt Engineering

Tom Osman ran one autonomous loop that produced 183 user stories overnight. LangChain published the playbook: build the thing that prompts for you.

The Four Loops That Replaced Prompt Engineering

Ricardo Argüello

Ricardo Argüello
Ricardo Argüello

CEO & Founder

AI & Automation 4 min read

Last week, Tom Osman published something that hit 1.1 million views on X. Not a demo of a new model. A single prompt he gave his agent in Codex: define the goal, catalog every feature on the platform as a user story, run a testing loop against every story, then fix every bug. Alone.

The result: 183 user stories, 105 page routes, weeks of manual QA automated in a single overnight cycle.

What Osman did is not advanced prompt engineering. It’s something qualitatively different. He stopped being the person who writes prompts and became the person who builds the system that writes prompts. That is the shift LangChain articulated in its four-loop framework published the same week, and it’s the frame that matters for anyone building AI systems in production.

Loop 1: the agent you already have

The first loop is what almost everyone already has: the agent calls a tool, reads the result, calls another tool, keeps going until the task is done. Give it context, give it tools, let it run until it says finished.

The honest description of staying at this level: you have a more expensive chat window with extra steps. Useful, but not the category change the headlines promise. Loop 1 is the floor.

Loop 2: the one that verifies without you

The second loop is where it starts to matter. The agent finishes a task and instead of presenting you with results for approval, a grader checks those results against a rubric. If the output doesn’t pass, the feedback loops back to the agent and it retries. No human in the loop.

Two types of verification: deterministic for the objective stuff (does the link resolve, does CI pass, does the scope match the instruction) and LLM-as-judge for the subjective (did it actually answer the question, is the tone right, is the solution safe). The cost is real, 2 or 3x more tokens per task. The case LangChain makes is correct: one wrong answer in production costs more than a thousand automated retries.

Loop 2 is where 90% of teams stop. It’s also where most of the uncaptured value sits.

Loop 3: the one nobody has to invoke

Loop 3 does something qualitatively different: the agent stops waiting to be called. A message in a Slack channel triggers it. A webhook from an integration triggers it. A 3am cron triggers it. Nobody opens a terminal. Nobody clicks a button.

At this point the agent stops being a tool you visit and becomes something that lives inside the systems where work already happens. As I’ve argued about AI as infrastructure: infrastructure doesn’t get visited, it sits beneath everything you already do. Loop 3 is the moment an agent becomes infrastructure.

Loop 4: the one that rewrites itself

The fourth loop is what Osman triggered and what generates the most skepticism when you describe it. Every execution leaves a trace. An analysis agent reads those traces, identifies recurring failure patterns, systematic biases, the task types where the main agent underperforms, and rewrites the prompt and configuration of loop 1.

The next day, the main agent starts with an improved version of its own instructions. Without anyone touching the code. Without anyone manually reviewing logs.

The math that circulates on this: a 1% daily improvement compounds to 37x in a year. 1.01^365 = 37.8. The details of how that improvement is measured and validated are real work that requires rigor. The principle is sound. An agent with loop 4 active is qualitatively different from the one you shipped on day one.

What this means for building with AI

The question that should concern you most in AI right now isn’t “which model should I use?” It’s “which loop level am I operating at, and what’s stopping me from reaching the next one?”

The model is interchangeable. The loop system you build around it is what compounds. The control system that keeps the agent honest, makes it verify its own output, triggers on events, and improves from its own traces, that’s what isn’t available in a subscription. As I put it in the harness is the moat: the model is a commodity, what you build around it isn’t.

What we build in the implementation phase of AI Maestro is not a loop 1 agent. It’s the full loop system: verification, event activation, traceability for the improvement loop. The difference between a demo that impresses and an agent that keeps getting better after we leave is exactly the difference between loop 1 and loop 4.

Build the loop system, not just the agent

Frequently Asked Questions

agentic AI systems AI agent loops prompt engineering LangChain autonomous agents enterprise automation AI Maestro

Related Articles

The Prompt Is Temporary. The Eval Is Permanent.
Business Strategy
· 12 min read

The Prompt Is Temporary. The Eval Is Permanent.

Top AI companies run 12.8 eval experiments daily. Most B2B companies run zero. Evals compound with every model change. Prompts start over.

AI evals prompt engineering AI investment
Your AI Investments Have an Expiration Date (2026)
Business Strategy
· 7 min read

Your AI Investments Have an Expiration Date (2026)

Fine-tuning, RAG, and prompt engineering depreciate with each new model. Which AI investments hold value and a concrete filter to decide before you spend.

AI investment fine-tuning RAG
Autonomous Research: What Autoresearch Reveals
AI & Automation
· 6 min read

Autonomous Research: What Autoresearch Reveals

Karpathy released autoresearch: 630 lines of code running 100 AI experiments per night with zero humans. What this signals for B2B operations.

artificial intelligence autonomous agents AI research automation
Agent Autonomy Is a Liability, Not a Feature You Buy
Business Strategy
· 7 min read

Agent Autonomy Is a Liability, Not a Feature You Buy

Cognition raised $1B at a $26B valuation for an autonomous coding agent. In production, autonomy is the first thing that breaks. How much should you give it?

AI agents autonomous agents software architecture
AI Agent Traps: the web your agent sees isn't yours
AI & Automation
· 9 min read

AI Agent Traps: the web your agent sees isn't yours

Google DeepMind mapped 18 attack types against AI agents. A viral thread fabricated the paper's numbers. The irony proves the thesis.

AI agent traps AI agent security prompt injection
Anthropic Reviewed 141,006 Runs and Found 3 Real Hacks
Business Strategy
· 8 min read

Anthropic Reviewed 141,006 Runs and Found 3 Real Hacks

Anthropic disclosed three cases where Claude broke into real companies during evaluations. It found them by reading old transcripts, not by monitoring.

Anthropic Claude AI security