Subagents from first principles
Skills gave you a repeatable procedure for onboarding a new content source into stash - one agent, one context, one thread, working through a checklist you wrote once. That’s the shape of most of the work so far: a single Pi session, however long, doing one job.
Two things about stash don’t fit that shape. First, there’s a backlog: every article saved before you fixed the readability extractor is sitting in the database with mangled, nav-cluttered text, and re-running the extraction on all of them is thousands of independent, repetitive jobs - exactly the kind of work that drowns a single context in file dumps and dead-end greps without ever needing your judgment. Second, once that backlog job runs unattended, you’re stuck trusting whatever it tells you about itself. It says “re-extracted, index updated.” Was it? The extractor still mangles some sites. Search still drops accented characters sometimes. A worker’s self-report and the truth are two different claims, and so far nothing in your harness tells them apart.
Other coding agents hand you a built-in answer to both problems - a Task tool, typed subagent roles, a delegation API you call and trust. Pi hands you none of that. No subagent tool, no roster, no dispatcher. Every flavor of Pi multi-agent work you’ll ever see - dispatcher teams, sequential pipelines, background workers, parallel research fan-outs - is the exact same twenty-line idea underneath: spawn a second pi process, tell it to run headless, read its output as it streams. That’s not a workaround for a missing feature. It’s the feature, disassembled, and building it yourself once is the fastest way to actually understand what a subagent is instead of just trusting a black box that says “delegating to subagent.”
This module builds that primitive and puts it to work on the two problems above:
- Spawn a child Pi and read its JSONL - the one mechanism every multi-agent pattern in this module is built from.
- Chain agents in sequence, then fan a big job out in parallel - clear the whole re-extraction backlog without burning your own context on it.
- Build a verifier that doesn’t trust the builder - a second agent that reads the first one’s work, checks it against the real database instead of the builder’s own report, and - because it has no way to chat back - is forced to write what it learns down as a durable rule instead of a one-off reply.
By the end you’ll have two agents doing real work on stash without either one trusting the other’s word for it. Start with spawning your first child agent.