Skip to content

Ch 1: Minimal Coding Loop

You have unlocked secret 0 of 20 about AI Agents
0%
The Genius Locked in a Room

Imagine you hired the smartest person in the world — but they are locked in a room with no windows and no hands. The only way you can talk to each other is by sliding notes under the door.

You slide a note in: "Write me a story and save it on my computer."

The genius reads it. They are incredibly smart, but they cannot touch your computer. They cannot open a browser or create a file. All they can do is think and write on paper.

So they slide a note back: "I have written the story! But I cannot save it myself. Please write this text into a file called story.txt."

Now it is your turn. You take the note, walk to your computer, create the file, type in the text, and save it. Then you slide a note back under the door: "Done! The file has been saved."

The genius reads your note, smiles, and slides one final note: "Mission accomplished."

This is exactly how many AI assistants work. The genius is the AI. The notes are messages. And you — the helper who can actually use the computer — are the agent.

The Note-Passing Loop

Every AI tool that can do things for you on a computer runs the same secret pattern under the hood. We call it The Loop:

  1. Send — You slide a note under the door (send a message to the AI)
  2. Check — The genius slides a note back. Does it ask you to do something? Or is it a final answer?
  3. Execute — If the genius asked you to do something (like "save this file"), you go do it. Then you slide a note back saying what happened.
  4. Repeat — The genius reads your update. Maybe they need another errand. Maybe they are done. If they need more, you go back to step 1.

That is it. That is the entire secret. Every "magical" AI coding assistant is just this loop running over and over.

Narrator

You are the helper outside the room. Someone has just asked for help. Let's walk through what happens.

Two Ways to Stop

The loop has exactly two ways to end:

Exit 1: The genius is done. The AI replies without asking you to run any errands. No more notes to pass, no more files to create. The conversation is over.

Exit 2: The safety limit. What if the genius keeps asking for errands forever? What if they get confused and keep saying "check that same thing again" in an endless circle? You need a safety net — a maximum number of rounds. After 10 rounds (or whatever limit you set), you stop the loop even if the genius is not done.

Without this safety limit, a confused AI could burn through your entire API budget in seconds. Think of it like a budget alarm on your credit card.

Put the loop steps in the correct order

Drag to reorder, or use Tab + Enter + Arrow keys.

  1. Execute the tool (run the errand)
  2. Slide the note under the door to the genius
  3. Check: does the response ask for a tool call?
  4. Report the tool result back to the genius

Stop the runaway loop!

Press EMERGENCY STOP before the loop reaches the danger step!

1Slide a note to the genius
2The genius says: check whether the saved story is there
3You check and report back
4The genius says: check whether the saved story is there (again!)
5You check and report back (again!)
6The genius says: check whether the saved story is there (forever!)

What You Learned

You now understand the secret behind AI helpers like this: The Loop. A genius locked in a room, passing notes, asking for errands. Send, check, execute, repeat — until the genius is done or you hit a safety limit.

In Chapter 2, you will discover how the genius learns new skills. Right now they can only ask for one simple errand. What happens when they need to look something up, save something for you, or check whether their work succeeded? That is the Tool Registry.