@nanoverflow/spia1.0.1
Brain & Hands model routing for the pi coding agent: the strong model stays in the driver's seat, mechanical work goes to cheap-model subagents
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
spia
Brain & Hands model routing for pi coding agent.
English | 中文
The main model is the brain: it stays in the driver's seat of the main loop and never downgrades — prompt cache stays warm for the whole session and reasoning quality never drops. Mechanical work goes to hands: a delegate tool spawns cheap-model subagents in isolated pi processes with their own context windows, then reports back.
How it works
you
│
┌───────▼────────────────────────┐
│ Brain (strong model) │ thinking, decisions, plans,
│ prompt cache always warm │ verifying worker output
└───────┬────────────────────────┘
│ delegate(task) ┌────────────────────────┐
├────────────────────────▶│ Hands (cheap subagent) │ bulk rewrites, boilerplate,
│◀────── result report ───│ isolated process/ctx │ batch retrieval, migrations
│ └────────────────────────┘
- The brain never downgrades: every main-loop request routes to the strong model — zero cache misses, stable reasoning quality
- Mechanical work is outsourced: a
delegatetool dispatches self-contained mechanical tasks to a cheap-model worker (the worker has read/edit/write/bash tools and runs in this repository's working tree) - Isolated context: the worker is a separate pi process and cannot see the main conversation; the task description must carry everything it needs
- Live progress: worker activity streams back in real time; the final report (with cost) returns to the brain
- Background requests: compaction summaries always go to the cheap model
- Manual override:
/spia:plan//spia:buildcan still pin the main-loop model
Install
# Option 1: git (recommended)
pi install git:github.com/nanoverflow/spia
# Option 2: npm
pi install npm:@nanoverflow/spia
# Option 3: try once without touching settings
pi -e git:github.com/nanoverflow/spia
# Option 4: copy spia.ts manually into
# ~/.pi/agent/extensions/ (global)
# .pi/extensions/ (project-local)
Restart pi or run /reload afterwards.
Usage
/model # pick spia/auto
Then just work normally — the brain delegates when appropriate. You can also say explicitly: "use delegate to hand X to a worker".
| Command | Effect |
|---|---|
/spia:plan |
main loop on the strong model (brain mode, default) |
/spia:build |
pin the main loop to the cheap model (money-saving mode) |
Configuration
Override the model pair via environment variables (format provider/model; model IDs must match what /model shows):
export PI_SPIA_PLANNER=zai-coding-cn/glm-5.4 # brain
export PI_SPIA_EXECUTOR=deepseek/deepseek-flash # hands
export PI_SPIA_WORKER_THINKING=high # worker default thinking level
export PI_SPIA_MAX_WORKER_CHARS=30000 # delegate result truncation
Defaults can also be edited at the top of spia.ts.
Subagent thinking level
The worker's thinking level is controlled on two layers:
- Global default:
PI_SPIA_WORKER_THINKING(one ofoff/minimal/low/medium/high/xhigh/max, defaulthigh) — the brain can lower it per call; - Per-call override: the brain can pass a
thinkingparameter todelegate— lower it (e.g.low/off) for trivial bulk work to save tokens.
Model pair ideas
| Brain (strong) | Hands (cheap) | Notes |
|---|---|---|
zai-coding-cn/glm-5.4 |
zai-coding-cn/glm-5.3-flash |
default |
deepseek/deepseek-v4-pro |
deepseek/deepseek-flash |
example |
opencode-go/kimi-k3 |
opencode-go/glm-5.3-flash |
same-provider mix |
FAQ
Why does the brain never downgrade? Switching physical models busts the prompt cache and re-bills the whole context. Keeping the brain on one strong model = warm cache + stable decision quality. This is the key difference from "plan-then-switch" routers: spia doesn't save money on the main loop, it spends small money in isolated outsourced contexts.
Can the worker see the conversation?
No. It runs in a separate process with its own context and only knows what you put in task. Write exact file paths, requirements, and acceptance criteria — the brain's system-prompt guidelines remind it of this.
Will delegate be overused? The tool's prompt guidelines tell the model: design decisions, subtle debugging, and anything needing conversation context stay with the brain; only bulk mechanical work is outsourced; and the brain must verify the worker's diff itself.
Security note The worker process has full tool permissions (file read/write, shell), same as the main agent. Make sure you trust the task being run; project trust applies as usual.
中文
English | 中文
pi 编码代理的"大脑 + 双手"模型分工。
主模型是大脑:主循环永远路由到强模型,从不降级——prompt cache 整个会话保持温热,推理质量不打折。机械活交给双手:delegate 工具把任务派给便宜模型的子代理(独立 pi 进程、独立上下文窗口),完成后把结果报告回传。
工作方式
- 大脑不降级:主循环每个请求都路由到强模型,零 cache miss
- 机械活外包:worker 有 read/edit/write/bash 等工具,跑在本仓库工作区
- 隔离上下文:worker 看不到主对话,任务描述自带一切所需信息
- 进度可见:worker 执行进度实时流式回显,最终报告(含成本)回传大脑
- 后台请求:compaction 摘要固定走便宜模型
- 手动兜底:
/spia:plan(大脑模式,默认)//spia:build(省钱模式)
安装
pi install git:github.com/nanoverflow/spia # 推荐
pi install npm:@nanoverflow/spia # npm
pi -e git:github.com/nanoverflow/spia # 临时试用
安装后重启 pi 或执行 /reload,/model 选择 spia/auto。
配置
export PI_SPIA_PLANNER=zai-coding-cn/glm-5.4 # 大脑(provider/model 格式)
export PI_SPIA_EXECUTOR=deepseek/deepseek-flash # 双手
export PI_SPIA_WORKER_THINKING=high # worker 默认思考等级
export PI_SPIA_MAX_WORKER_CHARS=30000 # delegate 结果截断长度
worker 思考等级两层控制:环境变量设全局默认(默认 high);大脑调用 delegate 时可用 thinking 参数单次覆盖——琐碎批量活可调低(low/off)省 token。
常见模型对
| 大脑 | 双手 | 备注 |
|---|---|---|
zai-coding-cn/glm-5.4 |
zai-coding-cn/glm-5.3-flash |
默认 |
deepseek/deepseek-v4-pro |
deepseek/deepseek-flash |
示例 |
opencode-go/kimi-k3 |
opencode-go/glm-5.3-flash |
同 provider 混搭 |
安全提示
worker 进程拥有完整工具权限(读写文件、跑命令),与主 agent 相同。delegate 的任务由大脑生成,请确保信任运行中的任务;项目级信任照常生效。
License
MIT