🧹 Sweeper Agent
Multi-threaded code maintenance with resource isolated subagents and swappable AI providers.
Sweeper dispatches parallel AI agents to fix lint issues across your codebase, each running in its own isolated environment. Providers are swappable: use the pi coding agent (default — one driver, any model in pi's registry), Claude Code, OpenAI Codex, or local models via Ollama. It groups issues by file, fans out concurrent fixes, escalates strategy when fixes stall, and records outcomes so it learns what works. With VM isolation enabled, each sub-agent runs inside a dedicated stereOS virtual machine with its own CPU, memory, and secrets boundary, safe to scale to 10+ concurrent agents.
sweeper run --vm -c 5
│
┌─────────┼─────────┐
▼ ▼ ▼
┌──────────────────────────────┐
│ Worker Pool │
│ (rate-limited, max N=5) │
└──┬───┬───┬───┬───┬──────────┘
│ │ │ │ │
▼ ▼ ▼ ▼ ▼
┌───┐┌───┐┌───┐┌───┐┌───┐
│VM ││VM ││VM ││VM ││VM │ ◄── stereOS isolation
│ 1 ││ 2 ││ 3 ││ 4 ││ 5 │ (secrets, CPU, memory)
└─┬─┘└─┬─┘└─┬─┘└─┬─┘└─┬─┘
│ │ │ │ │
▼ ▼ ▼ ▼ ▼
claude claude claude claude claude
--print --print --print --print --print
│ │ │ │ │
└─────┴──┬──┴─────┴─────┘
│
┌─────┼───────────┐
▼ ▼ ▼
streaming telemetry paper
progress (.jsonl) (capture)
Each sub-agent works on a single file. Results stream back as they complete, giving real-time progress instead of blocking until the entire round finishes.
Why Sub-Agents
The main thread never reads or edits source files. It runs the linter, builds prompts, dispatches work, and collects results. All file-level reasoning happens inside sub-agents via claude --print, which are stateless, single-shot processes.
This matters because the orchestrator's context window stays small and predictable. It holds lint output, task metadata, and result summaries, not the contents of every file being fixed. A run that touches 50 files uses roughly the same orchestrator context as one that touches 5. The complexity scales in parallelism, not in context size.
Orchestrator (main thread) Sub-agents (disposable)
┌────────────────────────┐
│ lint output │ ┌──────────────────────┐
│ file groupings │ ──dispatch──▶ claude --print │
│ strategy decisions │ │ reads auth.go │
│ result summaries │ ◀──result── │ writes fix │
│ │ └──────────────────────┘
│ (never sees file │ ┌──────────────────────┐
│ contents directly) │ ──dispatch──▶ claude --print │
│ │ │ reads router.go │
│ │ ◀──result── │ writes fix │
└────────────────────────┘ └──────────────────────┘
Sub-agents are fire-and-forget. Each one gets a prompt with the lint issues for its file, does the work, and exits. If it fails, the orchestrator knows from the exit code and can retry with an escalated strategy on the next round. No conversation state carries over between rounds, which keeps each attempt clean.
Advisor Phase
With an advisor configured, each round starts with a one-shot planning call to a frontier model. The advisor receives the lint output and per-file round history — never file contents — and returns a structured plan: task ordering, per-file difficulty, and strategy hints. Workers then execute fixes in the planned order on whatever (cheaper) provider/model you configured. If the advisor fails, times out, or returns an unparseable plan, the round falls back to the mechanical file grouping and continues.
Every advisor call is recorded as an advisor_plan telemetry event, so sweeper observe can compare advised runs against mechanical ones.
Model Escalation
With a [worker.escalation] ladder configured, files that stop improving climb to stronger models instead of just stronger prompts. The first round runs everything on the base worker (cheap, often local). When a file stagnates for stale_threshold rounds, sweeper switches it to the exploration prompt and moves it up one rung — e.g. qwen2.5-coder:7b → claude-haiku-4-5 → claude-sonnet-5. A file is only abandoned after exploration has been tried at the top rung.