s01 — The Agent Loop
~84 LOC · 1 tool“One loop & Bash is all you need”
The kernel: call the model, execute tools when stop_reason === tool_use, append tool results, repeat. Everything else in the course stacks on this loop.
Developers · Track A
Twelve progressive sessions covering the agent loop through worktrees. Read each lesson on Zeus—full text below.
Sign in to save progress on your account.
Scroll for all sessions →
“One loop & Bash is all you need”
The kernel: call the model, execute tools when stop_reason === tool_use, append tool results, repeat. Everything else in the course stacks on this loop.
“Adding a tool means adding one handler”
Keep the loop fixed; register new capabilities in a name→handler table. Same pattern every production harness uses.
“An agent without a plan drifts”
Structured steps before execution—planning as a first-class tool outcome.
“Each subtask gets a clean context”
Child runs get their own messages[]; the main thread stays readable.
“Load knowledge when you need it”
Inject domain text via tool results instead of bloating the system prompt up front.
“Make room for infinite sessions”
Three-layer compression so long jobs do not drown in history.
“Persist goals to disk with dependencies”
File-backed task graph—foundation for serious multi-step and multi-agent work.
“Run slow work without blocking the think loop”
Daemon-style execution with completion notifications fed back into the session.
“Delegate across persistent teammates”
Async mailboxes and roles when one context window is not enough.
“Shared rules for negotiation”
One request–response pattern for plan approval, shutdown, and handoffs.
“Teammates claim work from a shared board”
Lead does not have to assign every micro-task—workers pull when ready.
“Each worker owns a directory”
Bind task IDs to filesystem lanes so parallel runs do not stomp each other—production hygiene.
Capstone
After s01–s12, combine the patterns into one harness: an all-in-one agent loop with tasks, teams, and isolation—then ship it behind your own interface.