Back to directory

How Pi Agent Works: Building an AI Agent from Scratch

A Chinese-language tutorial site that breaks down the Pi coding agent's source code into core concepts, then walks through building a teaching version of an agent in TypeScript, React and Node.js.

Visit website (opens in a new tab)how-pi-agent-works.vercel.app
How Pi Agent Works: Building an AI Agent from Scratch

how-pi-agent-works is a runnable, Chinese-language VitePress tutorial that explains how the Pi coding agent works from an engineering perspective, based on the earendil-works/pi source and its official documentation, rather than translating the source file by file. It covers core concepts such as the agent loop, messages, streaming events, tool calls, the session tree and context compression, and walks through the layering of the pi-ai, pi-agent-core and pi-coding-agent packages.

Four progressive TypeScript demos build from a minimal loop up to one with tools, sessions and compression, with an optional fifth demo against a real model over an OpenAI-compatible endpoint. The final project implements a runnable teaching version of an agent using React, Node.js and TypeScript, with its own Express API and test, typecheck and build commands, deployed as a static documentation site to Vercel.

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.