Multi-Agent Framework
BabyAGI — Minimal Task-Queue Agent Pattern logo

BabyAGI — Minimal Task-Queue Agent Pattern

BabyAGI is a 150-line Python agent that demonstrated task-queue-based autonomy in 2023 — add tasks, execute with an LLM, create new tasks from results, prioritize, repeat. A touchstone reference implementation.

Why BabyAGI matters

Yohei Nakajima posted BabyAGI on Twitter in April 2023 as a 150-line demo of the task-queue pattern for autonomous agents: an execution agent runs the top task, a task-creation agent invents new tasks from the result, and a prioritization agent reorders the queue. It ran on ChatGPT + Pinecone and went viral alongside AutoGPT — together they seeded the "autonomous agent" category.

Unlike AutoGPT, BabyAGI stayed small on purpose. It was always presented as a pattern, not a framework. Yohei iterated it into newer versions (BabyAGI v2, BabyBeeAGI, BabyFoxAGI) that explored different ideas — function-based agents, self-building tools, chain-of-task reasoning. All maintained the "small, readable, a lesson in 200 lines" spirit.

In 2026 you don’t deploy BabyAGI — you read it. It’s the clearest single-file explanation of "why does an LLM need a task queue to reach a big goal?" Port the pattern to CrewAI tasks, LangGraph nodes, or AutoGen conversations as appropriate.

Quick Start — The Pattern in 60 Lines

This is a faithful 60-line port of the BabyAGI idea. Three LLM roles — execute, create, prioritize — on a shared task queue. For a real product, migrate each role to a CrewAI agent or a LangGraph node with memory and tools; BabyAGI’s value is making the pattern legible, not running in production.

# A minimal BabyAGI-style loop using the modern OpenAI SDK.
# This is the pattern — use CrewAI / LangGraph for production.

from collections import deque
from openai import OpenAI

client = OpenAI()
OBJECTIVE = "Write a 3-step plan to launch a small SaaS landing page."
task_list = deque([{"id": 1, "name": "Brainstorm the first task list for the objective."}])

def llm(prompt: str) -> str:
    r = client.chat.completions.create(
        model="gpt-4o-mini",
        messages=[{"role": "user", "content": prompt}],
        temperature=0.2,
    )
    return r.choices[0].message.content.strip()

def execute(task: str, context: str) -> str:
    return llm(f"Objective: {OBJECTIVE}\nPrior context: {context}\nTask: {task}\nExecute it now.")

def creation(task: str, result: str) -> list[str]:
    raw = llm(f"Objective: {OBJECTIVE}\nLast task: {task}\nResult: {result}\n"
              "Generate up to 3 NEW tasks (no duplicates). Return a bullet list, no preamble.")
    return [ln.lstrip("-•* ").strip() for ln in raw.splitlines() if ln.strip()]

def prioritize(tasks: list[dict]) -> list[dict]:
    raw = llm(f"Objective: {OBJECTIVE}\nUnordered tasks:\n"
              + "\n".join(f"- {t['name']}" for t in tasks)
              + "\nRe-order by importance toward the objective. Return a bullet list.")
    names = [ln.lstrip("-•* ").strip() for ln in raw.splitlines() if ln.strip()]
    return [{"id": i + 1, "name": n} for i, n in enumerate(names) if n]

context = ""
for _ in range(5):     # cap iterations
    if not task_list: break
    task = task_list.popleft()
    result = execute(task["name"], context)
    context += f"\n[TASK] {task['name']}\n[RESULT] {result[:300]}"
    print(f"\nDone: {task['name']}")
    new = creation(task["name"], result)
    current = list(task_list) + [{"id": t["id"] + i, "name": n} for i, n in enumerate(new, 1)]
    task_list = deque(prioritize(current))

print("\n=== FINAL CONTEXT ===")
print(context[-1200:])

Key Features

Three-role task loop

Execution / task-creation / prioritization — the simplest useful decomposition of an autonomous agent. Every modern framework implements the idea in some form.

Small codebase

The original was ~150 lines. Modern ports stay under 200. Anyone who reads it understands the core agent loop in an afternoon.

Pattern variants

BabyBeeAGI, BabyFoxAGI, BabyCatAGI — experiments on memory, tools, self-modification. Useful as a library of "here’s another way to structure the loop".

Pair with any vector DB

The original used Pinecone; reimplementations use Chroma, Weaviate, pgvector. Memory is just "embed task+result, retrieve related items on future turns".

Educational value

Easier to teach than AutoGPT’s 10K-line codebase. Used in many "intro to agents" tutorials and university courses.

Public domain lineage

Permissively licensed (MIT). Widely forked; incorporating the pattern into your own codebase is frictionless.

Comparison

 SizePurposeProduction UseWhy Still Relevant
BabyAGIthis~150 LOCPattern demoRareClearest loop explanation
AutoGPT (2023)~10K LOCAutonomous agent demoMigrated to PlatformHistorical
CrewAIProduction frameworkRole-based pipelinesWidespreadModern successor
LangGraphProduction frameworkGraph-based agentsWidespreadModern successor

Use Cases

01. Teaching the agent loop

The clearest single-file explanation of why "execute → create → prioritize" beats "prompt once and hope". Use in onboarding, classes, and talks.

02. Stealing the pattern

Lift the three-role loop into your own codebase on any framework. Most "agentic" features in modern libraries map back to some variation of it.

03. Research playground

Too small for production, but ideal for quick experiments on prioritization strategies, task-decomposition prompts, or memory integration — change 30 lines and compare results.

Pricing & License

BabyAGI: MIT open source, free. The original and all variants live on Yohei Nakajima’s GitHub.

No infra cost: a single Python file plus whatever vector DB (Pinecone/Chroma) you pick. LLM API calls dominate total spend.

Budget discipline: the loop is uncapped by default. Always add a max-iterations guard and a cost cap before leaving it running; this is a demo, not a careful production system.

Frequently Asked Questions

Should I deploy BabyAGI in production?+

No. Use CrewAI, LangGraph, or AutoGen for production agents. BabyAGI’s value is pedagogical — read it to understand the pattern, then use a framework that handles memory, error recovery, and reliability.

BabyAGI vs AutoGPT?+

Both went viral in April 2023. AutoGPT became a large project and a no-code platform. BabyAGI stayed small on purpose. Today AutoGPT is a platform; BabyAGI is a teaching example.

What are BabyBeeAGI / BabyFoxAGI / BabyCatAGI?+

Yohei’s evolutionary variants — each explores a different idea (tool use, self-modification, structured chain-of-task). Worth browsing for pattern ideas; don’t treat any as a framework to adopt.

How do modern frameworks improve on BabyAGI?+

Structured state (LangGraph), role modeling (CrewAI), conversation dynamics (AutoGen), reliability features (checkpointing, retries, HITL). BabyAGI does none of that — it’s the 1.0 everyone builds on.

Where can I read the explanation?+

Yohei’s original Twitter thread (April 2023), the README at github.com/yoheinakajima/babyagi, and many community tutorials. The README alone is a great 10-minute read.

Compare Alternatives