Back to directory

learn-agent

A set of Chinese-language notes that rebuild the internal mechanisms of coding agents such as Claude Code, Codex and OpenCode as small, dependency-free, runnable Node.js programs, one mechanism per chapter.

learn-agent

learn-agent documents mechanisms observed while building a desktop coding agent, reducing each one to a single-file Node.js program with no dependencies that a reader can run directly, rather than only describing the mechanism in prose or inferring it from an API's own documentation. The first twelve chapters build a working agent from nothing: the main agent loop, a tool system, loop-budget correction, tool-output budgeting, streaming output and interruption handling, context compression, prompt caching, session persistence and recovery, subagents and a watchdog, system-prompt assembly, provider compatibility, and putting all of the pieces back into one loop.

Later chapters, numbered thirteen through twenty-three, cover permissions and approval before a destructive command runs, progressive tool disclosure, multi-model consultation, self-review loops, completion gating, the conflict between compaction and prompt-cache reuse, automatic long-term memory across projects, comparing how different agents answer the same question, and handling image input. A companion self-test script runs every chapter's key-free examples in roughly ten seconds, and a separate folder holds source-code research notes on other agents that fed into the write-ups.

More in Tutorials

See all 478
  • BootLife

    github.com

    Conway's Game of Life implemented to run directly from a 512-byte x86 boot sector in assembly, using VGA memory itself as the simulation grid.

  • A technical blog post deriving the Y combinator as a composition of combinator birds in an array language, and examining how eager evaluation changes fixed-point recursion compared with the usual lazy telling.

  • System Design Atlas

    atlas-sysdes.vercel.app

    A free reference of worked system design problems with interactive architecture diagrams, covering ranked designs such as a feed, a chat app, a URL shortener, and a rate limiter, plus pages on the technologies behind them.