Phase 14: Agent Engineering

The Agent Loop: Observe, Think, Act

Every agent in 2026 is a variant of the ReAct loop from 2022 — Claude Code, Cursor, Devin, Operator included. Reasoning tokens interleave with tool calls and observations until a stop condition fires. Learn this loop cold before touching any framework. Name the three parts of the ReAct loop — Thought, Action, Observation — and explain why each one is load-bearing. Implement a stdlib agent loop with a toy LLM, tool registry, and stop condition under 200 lines. Identify the 2026 shift from prompt-based thought tokens to native model reasoning (Responses API, encrypted reasoning passthrough). Explain why modern harnesses (Claude Agent SDK, OpenAI Agents SDK, LangGraph, AutoGen v0.4) still build on this loop under the hood. An LLM on its own is an autocomplete. You ask a question, you get a string back. It cannot read a file, run a query, open a browser, or verify a claim. If the model has outdated or wrong information it will say the wrong thing confidently and stop. Agents fix this with one pattern: a loop that lets the model decide to pause, call a tool, read the result, and continue thinking. That is the entire idea. Every additional capability in Phase 14 — memory, planning, subagents, debate, evals — is scaffolding around this loop. Yao et al. (ICLR 2023, arXiv:2210.03629) introduced Reason…

The Agent Loop: Observe, Think, Act: Every agent in 2026 is a variant of the ReAct loop from 2022 — Claude Code, Cursor, Devin, Operator included. Reasoning…

This free lesson is part of the AI Engineering from Scratch curriculum. Read the full explanation, run the lesson code, and verify the result in the interactive reader or from the repository source.

Browse the complete course catalog or open this lesson on GitHub.