r/PiCodingAgent • • 1d 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?

0 Upvotes

8 comments sorted by

3

u/johnfkngzoidberg 1d ago

But why?

Not being pedantic, but it seems like any savings you get from switching models is wasted with the cache bust. Both models are really close in capability, so only 1/20 tasks would actually benefit from the better model, and even then the overhead and translation might make the whole thing a net negative.

-1

u/Born_Initiative3338 1d ago

Did you measure it?

3

u/vitamin_thc 1d ago

Couldn’t this negatively affect caching at the api level? If I’m reading this right it would be like swapping models mid conversation multiple times.

Whereas using subagents, and the main thread manages those subagents which use separate models, keeps the cache intact since each thread keeps the same model throughout.

I’d be interested in seeing cost comparisons with the different approaches.

Either way, cool project!

0

u/Born_Initiative3338 1d ago

Yes, this would impact the cache. I am accepting this trade-off for the time being, and yet I see myself using fewer tokens than my peers, while outputting roughly the same amount of PRs (although this is not scientific by any mean).
I will have some cost comparison in another post.

0

u/snow_schwartz 1d ago

Thanks for informing is. May I ask why though?

1

u/Born_Initiative3338 1d ago

For tinkering at first, and then I noticed that the output quality is better, since I like the reasoning of Opus better and the code produced by Sol better, I decided to keep it.

0

u/[deleted] 1d ago

[deleted] — view deleted comment

1

u/Born_Initiative3338 19h ago

Can you prove it?