FIELD NOTE · AI & Agents · 2026.08.22

The Life of a User Message Inside Pi Agent — 26 Stations from Enter to JSONL

After you type «read README.md and tell me what this project does in one sentence», that string passes through 26 stations, crosses six npm packages, morphs across three message layers, and only then becomes scrolling tokens on screen and one JSONL line on disk. Cross-reading earendil-works/pi production source with hahhforest/pi-textbook's 15 checkpoints — every step's class hierarchy, event flow, owner roles, and diagrams laid bare.

AUTHOR Airing TOPIC Pi · Agent · Harness FORMAT Immersive · 2 min read

This is a long-form immersive article — read the full version on the dedicated page → Enter full version

Tenth in the Field Note series. Sister pieces: The Life of One LLM Inference (one prompt through 28 llama.cpp stations) and From Bytecode to Pixel (Chromium render pipeline). This one switches the «OS» to coding agent harness — same method: one through-line prompt, real source, station by station.

Through-line: read README.md and tell me what this project does in one sentence

The immersive article walks 26 chapters from harness philosophy through CLI boot, AgentSession orchestration, the twin-loop agent core, pi-ai streaming, differential TUI render, TypeScript extensions, JSONL session trees, compaction, and a comparison with Claude Code / Cursor.

What this edition goes deep on

  • Line-by-line real source: all 26 chapters map to concrete files in earendil-works/pi — agent-loop.ts · agent-session.ts · session-manager.ts · event-stream.ts · ExtensionRunner · TUI diff render.
  • One through-line prompt: same as pi-textbook prologue — seven-milestone table in early chapters.
  • Two-layer message model: AgentMessage (canonical transcript) vs Message[] (LLM projection) vs TUI render.
  • runLoop twin loops: outer follow-up · inner tool batch + steering.
  • JSONL session tree: parentId · leafId · fork — diagram in C22.
  • Compaction: history preserved · context rebuilt — C23.
  • vs Claude Code / Cursor: sealed product vs composable harness trade-offs in C24.

“A user message looks like one line in the terminal. What it really does: pass through 26 stations across six npm packages, leave a forkable node on the JSONL session tree, then get differential-rendered into the token stream you see via CSI 2026.”

Full read: The Life of a User Message Inside Pi Agent — 26-station source panorama

Comments

— Write a comment ↓

Loading comments…

Inline comment

Follow what matters

订阅 Airing

选择接收方式,再决定你真正想看的内容。

新一期编好后发送;周刊邮件中可切换语言或退订。