Simple Pi Subagents — Deep Dive

Eero Alvar  ·  ~13:42  ·  Watch on YouTube ↗

Overview

This video presents a minimal, extensible sub-agents framework for Pi (a coding agent). The author explains the philosophy behind giving AI coding agents their own sub-agents, demonstrates three agent types (Scout, Researcher, Worker), and shows nested sub-agent spawning up to 6 levels deep.

1 The Problem — Context Bloat ▶ 0:00 ▶ 1:30

Core problem: as task complexity grows, agents read too many files during planning and exploration, bloating the context window into the "dumb zone" before execution can begin. Most file reading is exploratory — finding where things are, how pieces connect. Full file contents don't need to stay in context.

Solution: give your agent its own agents to outsource mechanical, context-heavy work. Bonus: since this work is mechanical, you can use cheaper models (Haiku instead of Opus/Sonnet), saving money while keeping the master agent's context lean and effective.

2 Design Philosophy — Three Values ▶ 2:02 ▶ 3:25

  1. Capability — Sub-agents should be as capable as needed for their role
  2. Observability — Full visibility into what every agent is doing at all times, especially important when sub-agents spawn their own sub-agents. Two reasons: improving agent prompts/functionality, and maintaining a feeling of control
  3. Extensibility — Two layers: (a) trivial to add/modify agents via markdown files, (b) the extension itself is minimal and easy to hack on

3 Agent Architecture — Markdown-Defined Agents ▶ 3:06 ▶ 5:11

Each agent is entirely defined by a markdown file with YAML front matter:

Agents are auto-discovered by the extension. Three ship by default:

4 Live Demo — Scout & Researcher ▶ 5:12 ▶ 7:12

Demonstration of the Pi interface with the sub-agents extension:

5 Live Demo — Worker Sub-Agent ▶ 7:13 ▶ 10:07

Real task: build a web UI (FastAPI + React) for an app that takes audio, removes silences, and outputs FCPXML.

"Use worker sub-agents. Cut the planning to phases and delegate each phase to a worker sub-agent to actually build it out. Don't write the code yourself. Delegate everything to workers."

6 Stress Test — 6 Levels Deep ▶ 10:08 ▶ 12:27

Experiment: allowing workers to spawn their own workers by adding worker to the sub-agents front matter field.

7 Limitations & Future Work ▶ 12:27 ▶ 13:42

🔑 Key Takeaways

  1. Context bloat is the primary barrier to complex, long-running AI agent tasks
  2. Sub-agents solve this by isolating context-heavy work (exploration, research) in separate processes
  3. Cheaper models can handle mechanical sub-tasks, reducing costs significantly
  4. Markdown-based agent definitions make the system trivially extensible
  5. Observability (live thinking, token metrics, nested indentation) is essential for debugging and trust
  6. The delegation pattern (plan → phase → worker) mirrors human team management
  7. Infinite nesting depth works but practical setups limit to 2–3 levels
  8. Interactivity (human-in-the-loop for sub-agents) is the key missing feature

⏱ Timestamp Index