Build an AGIMiddleLesson 637 min read

The OODA loop and the four pillars

The architecture. Four software components in a continuous cycle — and the reason it is a cycle rather than a pipeline.

Lesson in motion

In 60 seconds

The OODA loop and the four pillars

The architecture. Four software components in a continuous cycle — and the reason it is a cycle rather than a pipeline.

1/5
In simple words
Look. Understand. Decide. Do. Then look again to see what happened. That is how you ride a bicycle, and it is how an AGI runs.
A pipeline runs once and stops. A loop keeps going until the goal is met. Everything that makes an autonomous system autonomous comes from that difference.
The framing is borrowed from a fighter pilot: Observe, Orient, Decide, Act. It has survived because it is the shape of any system operating in a world that talks back.

Tap any box in the diagram

① OBSERVEPerception layer② ORIENTWorking memory③ DECIDECognitive core④ ACTTool loopuntil the goal is metor a limit stops itacting changes what there is to observe
① Observe — the perception layer

Ingests whatever the system can see: text, code, files, API responses, screen pixels, logs, tool output. Its only job is to turn the world into tokens the core can read. Security note: this is also the single place untrusted content enters your system. Everything in Module 8 attaches right here.

Click each stage. Note where the danger is concentrated: untrusted input arrives at ①, and irreversible consequences happen at ④. The two stages in between are where you get to put controls.

Why it must be a loop

  1. 1

    Acting changes the world

    After step one, the situation is different. A plan made before acting is stale the moment it starts executing.
  2. 2

    Errors are information

    A pipeline treats a failure as an ending. A loop treats it as the most useful thing it has learned so far.
  3. 3

    Goals decompose as you go

    You cannot fully plan a task you do not yet understand. The loop lets the system discover the sub-goals by attempting the work.
  4. 4

    Stopping needs a decision

    A pipeline stops when it runs out of steps. A loop stops when the goal is met, the budget is spent, or a human intervenes — and you must implement all three.
Watch out
That last row is not a detail. A loop with no stopping condition is an infinite bill and an unbounded blast radius. Write the exit conditions before you write the loop body — steps, wall-clock time, spend, and an external kill switch that the agent itself cannot reach (Module 33).

The four pillars as actual software

PillarWhat it is in codeCommon mistake
PerceptionParsers, loaders, API clients, OCRTrusting what it ingests
Working memoryPostgres for state, pgvector for retrievalOnly building retrieval, no state
Cognitive coreModel call + verifier + parserAssuming this is the whole system
Action loopTool registry, executor, sandbox, budgetNo limits, no logs, no undo
Do this
If you build only one of the four well, build the fourth. A brilliant core with a careless action layer is how incidents happen; a modest core with a disciplined action layer is a system you can actually deploy.

Watch and read more

Lab

An OODA loop where you can point at every stage in the code.

~20 min

The problem

Refactor an agent so the four stages are four named functions with explicit interfaces. Then instrument each stage with timing and token counts and find where the loop actually spends its budget.
Starter codepython
def observe(env) -> Observation: ...
def orient(obs, state) -> Context: ...
def decide(ctx) -> Action: ...
def act(action) -> Result: ...

You are done when

Hard questions

Try to answer before you reveal. If you can answer these, you understood the lesson.

Q1Which of the four stages should be hardest to change in production, and why?Reveal
Act. Decide changes constantly — prompts, models, planners — and should be easy to iterate. Act is where irreversible things happen, so it should be the most reviewed, most tested, most locked-down code in the system, changed deliberately and rarely. Teams invert this: they freeze the prompt because it is scary and iterate on tools because it is easy, which is exactly backwards.

Please sign in to continue.

Questions people ask

Is OODA better than ReAct or Plan-and-Execute?

They are the same shape with different emphasis. ReAct interleaves reasoning and acting turn by turn; Plan-and-Execute plans first then runs; OODA names the orient stage explicitly, which is its real contribution — it forces you to ask where state lives.

Where does planning fit?

Inside Decide. Long plans are fragile because of the compounding-error problem (Module 30), so the durable pattern is: plan a few steps, execute one, observe, re-plan. Commit to the next action, not to the whole route.

How is this different from a normal program?

A normal program's decide step is code you wrote and can read. Here it is a model whose next decision you cannot predict. Everything else — the loop, the state, the tools — is ordinary software, which is precisely why that is where your controls belong.

Do I need a vector database?

Not to start. Begin with a plain state table and a list. Add retrieval when you can point at the specific thing the system forgot. Vector stores are frequently the first thing built and the last thing needed.

Lesson test

5 questions. Get 3 right (60%) to pass and complete this lesson.

Sign in with your phone number to take the test and save your progress