s01 — The Agent Loop
while True + stop_reason“An agent is just while True + stop_reason.”
Establish the loop before adding I/O. messages[] is the state; stop_reason decides tool use vs. end turn.
Developers · Track B
Ten progressive sections — the agent loop through gateway routing, heartbeat, delivery, and concurrency. Read each session on Zeus (full markdown below). When a session includes exercises, run the sample code locally alongside the text.
Sign in to save progress on your account.
Scroll for all sessions →
“An agent is just while True + stop_reason.”
Establish the loop before adding I/O. messages[] is the state; stop_reason decides tool use vs. end turn.
“Tools are data + a handler map.”
The model names a tool; you dispatch to a registered handler and feed results back into the loop.
“Sessions are JSONL files.”
Append, replay, and summarize when context grows too large — conversations that survive restarts.
“Every platform produces the same InboundMessage.”
Normalize Telegram, Feishu, and friends into one shape before the gateway sees them.
“(channel, peer) → agent_id; most specific wins.”
Multi-tenant isolation: route inbound events to the right agent instance.
“Swap files, change personality.”
Soul, memory, skills — layered prompts assembled from files instead of one giant string.
“Should I run?” alongside user messages.
Proactive agent work: scheduled checks without waiting for chat input.
“Write to disk first, then try to send.”
Outbound queues with backoff so messages survive crashes and flaky networks.
“When one call fails, rotate and retry.”
Profile rotation, cooldowns, and fallback chains when APIs misbehave.
“Named lanes serialize the chaos.”
FIFO per lane, generation counters, and bounded parallelism without a single global lock.
Prefer explicit step folders over one growing file? The “build your own OpenClaw-style stack” tutorial (numbered READMEs + code) and other curated links are on AI learning resources.
Capstone
After s01–s10, you have the gateway stack: same loop as Claude Code, plus routing, persistence, delivery, and production concurrency. Combine with the Claude Code track for deep harness skills on the unit agent.