Course · Part 0, How we got here · Lesson 0.10 · 10 min
Agents: the loop, and why most demos broke (2023 to 2024)
Auto-GPT put a model in a loop and let it go, the loop went in circles, and the agents that worked a year later had checkable results and stop conditions written in code.
Before you read: find the line
Read the run below once. Decide which line is the mistake. The lesson tells you.
- 1systemgoals: [find the cheapest YYZ to LIS flight in May 2023, save it to flights.txt]
- 2llmthought: I should search for flights. action: google(q="cheapest flight Toronto Lisbon May 2023")
- 3toolgoogle -> 10 results (kayak.com, skyscanner.com, ...)
- 4llmthought: I need prices. action: browse(url="kayak.com/flights/YYZ-LIS")
- 5toolbrowse -> page needs JavaScript, 0 prices found
- 6llmthought: I should search for flights. action: google(q="cheapest flight Toronto Lisbon May 2023")
- 7toolgoogle -> 10 results (kayak.com, skyscanner.com, ...)
- 8llmthought: I should search for flights. action: google(q="cheapest flight Toronto Lisbon May 2023")
- 9donestatus: stopped at the iteration cap, flights.txt not written
The loop
An agent is a model in a loop. Read the goal and the state. Pick an action. Run it. Read the result. Repeat until done. ReAct gave the format in 2022, function calling gave the plumbing in 2023, and by the spring of 2023 the loop was a few hundred lines of Python that anyone could write.
At the end of March 2023 Toran Bruce Richards put Auto-GPT on GitHub. Give it a name, a role and a list of goals, and it would plan, search the web, write files and spawn sub tasks on its own until it decided it was done. BabyAGI, from Yohei Nakajima, appeared days later with a task list the model added to and pulled from. Auto-GPT passed 100,000 GitHub stars within months. Social media filled with videos of it ordering pizza and starting businesses.
What actually happened when you ran it
It ran out of money. It looped. It searched the same query twelve times. It wrote a file, forgot it had written it, and wrote it again. It declared the task done without doing it. The demos that worked were the ones recorded in the first ten minutes. The trace below is the shape of the next six hours.
The reasons are not mysterious, and an interviewer wants to hear them in order. First, compounding error. If each step succeeds 95 percent of the time, twenty steps in a row succeed 36 percent of the time. That is arithmetic, not a study, and most real tasks took more than twenty steps. Second, no stop condition. The model decided when it was done, and a model that writes text will write that it is done. Third, no state outside the prompt. Everything the agent knew was in a window that was filling up, so it forgot. Fourth, no gates. A failed tool result was fed into the next step with the same weight as a good one. Fifth, cost. Every iteration was a full model call carrying the whole history.
The honest counter example
Reflexion, from Noah Shinn and colleagues in March 2023, had the agent write a short note to itself after each failed try and keep it for the next. On the HumanEval coding benchmark it reached 91 percent pass at one, above the 80 percent reported for GPT-4 at the time. The difference from Auto-GPT was not the model. It was a task with a checkable result, a loop that stopped on success, and a memory that held one thing: the lesson from the last failure.
SWE-bench, in October 2023, made the gap measurable. It takes real GitHub issues from twelve Python repositories and asks the system for a patch that passes the repository's tests. The best model at launch, Claude 2, solved 1.96 percent. By April 2024 SWE-agent, an agent with a purpose built interface for reading, searching and editing files, solved 12.5 percent of the same set with GPT-4. The interface and the loop made the difference.
What a working engineer took from 2023
Anthropic's Building effective agents, from December 2024, says it plainly: the most successful implementations use simple, composable patterns rather than frameworks, and most tasks are better served by a workflow, where code decides the steps, than by an agent, where the model decides. Use an agent when the number of steps cannot be known in advance and the cost is worth it. Give it tools with good descriptions, a stop condition that code checks, and a person in the loop for anything that cannot be undone. Part 1 of this course is five of these loops, each broken in a different place.
What to say in the interview
List the five reasons in order, then give the counter example with its numbers. Then name the next step. One agent with ten tools works. One agent with a hundred tools gets confused, and every team was writing the same wrappers for the same ten services. The next step was to split the work across agents and to standardise how a model reaches a tool. That is lesson 0.11.
The line
- 1systemgoals: [find the cheapest YYZ to LIS flight in May 2023, save it to flights.txt]
- 2llmthought: I should search for flights. action: google(q="cheapest flight Toronto Lisbon May 2023")
- 3toolgoogle -> 10 results (kayak.com, skyscanner.com, ...)
- 4llmthought: I need prices. action: browse(url="kayak.com/flights/YYZ-LIS")
- 5toolbrowse -> page needs JavaScript, 0 prices found
- 6llmthought: I should search for flights. action: google(q="cheapest flight Toronto Lisbon May 2023")
- 7toolgoogle -> 10 results (kayak.com, skyscanner.com, ...)
- 8llmthought: I should search for flights. action: google(q="cheapest flight Toronto Lisbon May 2023")
- 9donestatus: stopped at the iteration cap, flights.txt not written
Line 6. The browse failed at line 5 and nothing recorded that. The model saw the same state it had at line 2 and chose the same action. No code checked for a repeated action, no memory held the failure, and the only stop was the iteration cap. The goal was never checked against the file system.
The pause
In the trace, what single piece of code would have stopped the loop at line 6?
In the interview
“Why did Auto-GPT fail in 2023 while coding agents worked a year later?”
Say your answer out loud, in under a minute. Then compare.
Notes
- Significant-Gravitas, Auto-GPT on GitHub (release, stars) (March 2023)
- Shinn et al., Reflexion: Language Agents with Verbal Reinforcement Learning (March 2023)
- Jimenez et al., SWE-bench: Can Language Models Resolve Real-World GitHub Issues? (October 2023)
- Yang et al., SWE-agent: Agent-Computer Interfaces Enable Automated Software Engineering (April 2024)
- Anthropic, Building effective agents (December 2024)