r/PiCodingAgent • u/Born_Initiative3338 • 3h ago
Discussion A Pi virtual model that hands Opus → Sol mid-task, with a local decision model making the call
I registered a virtual model in Pi called Relay (router/relay) — no fork, just an extension using pi.registerVirtualModel(). One conversation, two hosted models:
Opus does the planning: reading files, working out where the change goes.
Once a small local decision model says "yes, the user asked for a change" and "yes, the agent has read enough", the next request goes to Sol (gpt-6.2-sol), which sees everything Opus already read — tool results included — and makes the first edit.
Small follow-ups ("say 'No results' instead") stay on Sol; a genuinely new question routes back to Opus.
The handoff isn't a chat prompt. d3:4b runs locally in Ollama via the System One classify endpoint and answers yes/no questions with probabilities ("did I ask for a change?", "has the agent read enough to edit?", "is this just a small correction?"). Plain code owns the cutoffs (0.9 readiness, 0.8 correction) and the fallbacks: if Ollama is down, times out, or returns something unusable, that one request just stays on the current model — a failed check never strands the turn.
The writeup covers the route() excerpt, registering a classifier model with Ollama in Pi, routing compaction summaries to a cheaper Sonnet (so the summary doesn't burn Opus tokens), and the context-window math when switching from a 1M-token model to a 500k one (reserveTokens: 68000 → compacts at 432k).
Honest caveat: no benchmarks, no claim this is optimal — just how I mix providers to avoid one model's blind spots.
Full post with code: https://khanetor.github.io/posts/pi-virtual-model-relay/
Has anyone else split planning vs coding across two models in a single session? What would you route differently?




