On April 16, 2023, someone opened issue #1994 on the Auto-GPT repo with a five-word title: "\"Gets stuck in a loop.\" The agent had been asked to research setting up a company abroad. It ran the same Google search, got results, and ran the same search again. \"It loops the same queries although it successfully got the google results,\" the report says. The issue went stale and was closed as not planned that September."

That issue is a small fossil from a very loud month. Between March 28 and mid-April 2023, two open-source projects convinced a large part of the internet that GPT-4 plus a while loop was the first draft of AGI. Most of what got built that spring is gone. Three ideas from it are running inside the coding agent you used this morning.

Two weeks in spring 2023

On March 28, 2023, Yohei Nakajima posted a write-up of a "Task-Driven Autonomous Agent" built on GPT-4, Pinecone and LangChain. The code became BabyAGI, and its README later noted that the script had been cut down to "140 lines: 13 comments, 22 blanks, and 105 code."

Two days later, on March 30, Toran Bruce Richards of Significant Gravitas posted a demo of Auto-GPT, which his tweet called "an open-source experiment to make #GPT4 into a fully autonomous AI." According to the Know Your Meme timeline, which archives that tweet and the ones that followed, Andrej Karpathy tweeted on April 2 that the next frontier of prompt engineering was "AutoGPTs." Auto-GPT topped GitHub's global trending list on April 3 and passed 30,000 stars by April 12. The repo, now AutoGPT, shows about 188k stars today, and the original agent lives on in its classic/ directory.

The pitch for both was the same. You type a goal. The model breaks it into tasks, works through them, writes new tasks from what it learned, and keeps going until the goal is met. No human in the middle.

What these agents did on each turn

BabyAGI had three prompts and one queue. The archived script pops the first task, sends it to an execution prompt with context pulled from a vector store, stores the result, asks a task-creation prompt for new tasks, then asks a prioritization prompt to reorder the whole list. Simplified, the shape looks like this:

from collections import deque def babyagi(objective, first_task, llm, memory): tasks = deque([first_task]) while tasks: # the only exit: an empty queue  task = tasks.popleft() context = memory.search(objective, k=5) result = llm(f"Objective: {objective}\n" f"Context: {context}\nTask: {task}") memory.add(task, result) new = llm(f"Result: {result}\n" f"List new tasks for: {objective}") tasks.extend(new.splitlines()) ranked = llm("Reprioritise:\n" + "\n".join(tasks)) tasks = deque(ranked.splitlines()) 

Read the while condition. The loop ends when the task list is empty, and the thing that refills the list is the same model being asked what to do next. The real script has no iteration cap and no spend cap, and its README warns that "running this script continuously can result in high API usage."

Look at what result is, too. In BabyAGI the execution step was a completion call. It had no tools. The "result" of researching something was the model's own text about researching it, which then fed the next round of task creation. Nothing from the outside world ever entered the loop.

Auto-GPT went further. Its v0.2.0 README listed internet search, file storage, and "Long-Term and Short-Term memory management" backed by Pinecone, Redis or a local JSON file. So it did touch the real world. It still looped. The Wikipedia article sums up the developers' explanation: the agent was unaware of what it had already done, so it repeated the same subtask without end.

A snake made of paper task cards swallowing its own tail
A task list the model writes, ranks and marks done has no way out except running dry.

Why task-list self-prompting failed

Three failures showed up over and over in the issue trackers and write-ups that spring.

The first was no ground truth. A task list that the model writes, ranks and marks done is a closed system. If the model believes a task went well, it went well. Anthropic's December 2024 essay Building effective agents names the fix in one line: agents need to "gain 'ground truth' from the environment at each step." BabyAGI had no environment to ask.

The second was forgetting. Auto-GPT ran on GPT-4's 8K context window, and Han Xiao's April 13, 2023 opinion piece for Jina AI priced each step on the assumption that every action filled it. Memory existed, but it was a similarity search over past results, and in BabyAGI the query was the objective rather than the current task. An agent that cannot see its last ten actions will happily take the same action an eleventh time, which is exactly what issue #1994 describes.

The third was cost. Auto-GPT's README, asking for sponsors, said a full day of developing the project could cost its maintainers "as much as $20 in API costs," and its disclaimer told users to check their OpenAI usage regularly and set limits or alerts. Xiao's piece did the arithmetic at the GPT-4 prices of the time, $0.03 per 1K prompt tokens and $0.06 per 1K output tokens: about $0.29 per step and roughly $14 for a small task that needed around 50 steps. It also quoted a user complaint that Auto-GPT "never completes a task. It just always finds reasons to dig deeper and do more research."

Idea 1: the tool loop, with a hard stop

The loop itself survived. What changed is what goes into it and what gets it out.

The pattern predates the craze. The ReAct paper from October 2022 had a model alternate between reasoning and actions such as Wikipedia lookups, so each step rested on something it had retrieved. By December 2024 Anthropic's definition of an agent had settled on "LLMs using tools based on environmental feedback in a loop," with the advice to "include stopping conditions (such as a maximum number of iterations) to maintain control."

Claude Code's docs describe its agentic loop as gather context, take action, verify results, where "each tool use returns information that feeds back into the loop." For a failing test, that means run the suite, read the error, edit, run the suite again. The test runner is the ground truth BabyAGI never had. For unattended runs the CLI reference adds hard stops: --max-turns exits with an error at a turn limit, and --max-budget-usd stops the run once estimated spend reaches a cap.

Here is the 2026 shape next to the 2023 one. It is a sketch: you supply llm, the tools dict and approve.

def agent(goal, llm, tools, approve, max_turns=30): messages = [{"role": "user", "content": goal}] for _ in range(max_turns): reply = llm(messages, tools=list(tools)) messages.append(reply) call = reply.get("tool_call") if call is None: return reply["content"] name, args = call if approve(name, args): obs = tools[name](**args) else: obs = "denied by the user" messages.append({"role": "tool", "content": str(obs)}) raise RuntimeError("turn limit reached") 

The model still decides when it is done. The difference is that every step feeds back a real observation, and the loop cannot outlive max_turns.

Idea 2: external memory, as plain files

Auto-GPT and BabyAGI were right that an agent needs memory outside the context window. They reached for vector databases. Xiao's piece argued at the time that this was overkill: memory rarely ran past ten thousand entries, and each GPT-4 call took about ten seconds, so the database was never the bottleneck.

The version that stuck in coding agents is much plainer. Claude Code's memory docs describe CLAUDE.md files you write and an auto memory Claude writes itself, both "loaded at the start of every conversation." Anthropic's September 2025 post on context engineering calls the pattern structured note-taking: "the agent regularly writes notes persisted to memory outside of the context window," with Claude Code's to-do lists and a NOTES.md file as examples.

The task list survived too, in a changed role. In BabyAGI the list drove the agent. In a modern coding agent the to-do list is a note the agent keeps for itself and for you, while the tool results drive what happens next.

Three objects on museum pedestals: a looping arrow, an open notebook, a hand resting on a switch
What survived 2023: the tool loop, memory on disk, and a human with a hand on the switch.

Idea 3: a human checkpoint

This one was in Auto-GPT from the start, behind a flag that let you skip it. The v0.2.0 README told you to enter "'y' to authorise command, 'y -N' to run N continuous commands." The same README said continuous mode "is not recommended. It is potentially dangerous and may cause your AI to run forever or carry out actions you would not usually authorise."

That y prompt is the direct ancestor of the permission system in today's coding agents. Claude Code's how-it-works page says that from v2.1.283 interactive sessions start in Auto mode, where a background classifier reviews most actions and blocks the risky ones instead of asking you. Manual mode asks before file edits and most shell commands. acceptEdits lets edits through without asking, and plan explores without editing your source files.

File edits are snapshotted so you can rewind, and you can press Esc at any point to stop the loop and steer. Anthropic's essay frames the same idea for any agent: they "can pause for human feedback at checkpoints or when encountering blockers."

If this was useful

The tool loop, memory outside the context window, and where to put the human are three of the core patterns the AI Agents Pocket Guide works through, along with the failure modes that made 2023's agents loop. I build Hermes IDE, so weigh this with that in mind: it runs Claude Code, Codex and other agents side by side, each in its own worktree, shows which session needs approval, and never answers a permission prompt for you. It is free and source-available on GitHub.

AI Agents Pocket Guide: Patterns for Building Autonomous Systems with LLMs