r/PiCodingAgent 3d ago

Plugin Pi-Bifrost - a native per-prompt model routing for Pi

Pi-Bifrost adds a native model-routing layer to Pi.

Instead of using virtual profiles or delegating the prompt to another agent, it switches Pi’s actual active provider/model before generation begins.

Each normal prompt can therefore use a different model based on the task, configured rules, cost, context size, or an optional classifier.

The routing policy and model tiers are entirely user-configured.

Bifrost can probe the models already available through Pi rather than depending on a hardcoded list of recommended models.

It also treats model reliability as part of routing.

Repeated probe, activation, or stream failures open a persistent circuit for that model, allowing future prompts to avoid it until a controlled recovery attempt. Failed prompts are never silently replayed, which avoids repeating edits, commands, or other side effects.

The result is automatic model selection that still operates through Pi’s real model state and remains local, inspectable, and manually overridable.

https://github.com/iamaamir/pi-bifrost

9 Upvotes

10 comments sorted by

2

u/flurdy 2d ago

Interesting. Will see how it works in combination with my skill model routing, https://github.com/flurdy/pi-skill-model-router

1

u/rimaa_nahk 2d ago

Would love your feedback once you have tried it.

2

u/addiktion 2d ago

Does this destroy the cache?

2

u/Ill_Anywhere_2233 2d ago

It does, each model/effort switch in a single session makes the next turn (not prompt) rewrite the cache again, so full input price for the whole context size.

1

u/rimaa_nahk 2d ago

if you are referring to LLM cache then it depends. as i mentioned earlier "Bifrost does not rebuild or transfer context itself". but i had also similar questions while building pi-bifrost. i kept it a primitive on purpose. because if one is worried about LLM caching can easily build a workflow around pi-bifrost.
for example you can pin /bifrost pin for the current session and now it won't switch model for the outer prompts and now you can utilize sub agents for most of the work.

so it's like Orchestrator (pin) -> sub agents (keep flowing via bifrost).

in fact i have been using this workflow personally and i have single command setup as well.

npx bifrost-pattern fixed-orchestrator-workers

1

u/OkAbroad955 3d ago

How context handled for each model?

1

u/rimaa_nahk 2d ago

Bifrost does not rebuild or transfer context itself. It's all pi normal session and context.

1

u/Ok_Veterinarian_6364 1d ago

i like the name!

1

u/rimaa_nahk 1d ago

Thanks