b5-fusion
Multi-model B5 fusion ensemble for pi — every turn runs all candidates, the aggregator fuses the best answer
Package details
Install b5-fusion from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:b5-fusion- Package
b5-fusion- Version
0.2.0- Published
- Jul 18, 2026
- Downloads
- 109/mo · 30/wk
- Author
- lunwhale
- License
- MIT
- Types
- extension
- Size
- 134.4 KB
- Dependencies
- 2 dependencies · 2 peers
Pi manifest JSON
{
"extensions": [
"./extensions/b5-fusion/index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
B5 Fusion for pi
Multi-model aggregation ensemble for pi coding agent. Every turn runs all enabled candidates in parallel; a single aggregator fuses their drafts into one best answer.
Not a router. Not a tier gate. All enabled candidates run on every turn. The aggregator sees every draft (reasoning + text) and synthesizes.
┌── candidate 1 (deepseek-v4-flash, thinking: minimal) ──┐
├── candidate 2 (MiniMax-M3, thinking: low) ──┤
turn ──├── candidate 3 (deepseek-v4-pro, thinking: high) ──├─→ aggregator
├── candidate 4 (qwen3.7-plus, thinking: medium) ──┤ (deepseek-v4-flash)
└── candidate 5 (GLM-5.1, thinking: medium) ──┘
Inspired by Anthropic's Claude Fable 5 research direction (mid-tier models fused at modest budget can match one frontier model).
Highlights
- True aggregation — every candidate runs every turn, no role/tier routing
- Self-contained config — each candidate provides its own
baseUrl + apiKey + model - OpenAI-compatible — works with OpenRouter, vLLM, LM Studio, Anthropic-via-proxy, custom gateways
- Tool calling — the aggregator can call all of pi's tools (
read,bash,edit, MCP, …) - 7 languages — UI is fully translated:
zh-CN,en-US,de-DE,ru-RU,ko-KR,ja-JP,sa-Deva(Sanskrit/IAS) - Smart abort — once the quorum of candidates succeeds, slow ones are aborted to save latency
- Reasoning forwarding —
<THINKING>blocks from each candidate flow to the aggregator
Install
Requires pi ≥ v0.80 and Node ≥ 20.
From npm (when published):
pi install npm:b5-fusion
From this repo (clone + local install):
git clone https://github.com/<your-org>/b5-fusion-pi
pi install ./b5-fusion-pi
Or try without installing (ephemeral, current run only):
pi -e ./b5-fusion-pi
The extension will register a virtual provider. After install, switch to it with /model b5-ensemble/b5-fusion.
Looking for the user-facing config sample? See
config.example.json. The runtime settings file lives at~/.pi/b5-fusion-settings.json.
Quick start
Install (one of the methods above).
Edit config with at least one candidate and one aggregator:
// ~/.pi/b5-fusion-settings.json { "version": 6, "enabled": true, "language": "auto", // or "zh-CN" / "de-DE" / … "candidates": [ { "label": "fast", "enabled": true, "baseUrl": "https://api.openrouter.ai/v1", "apiKey": "$OPENROUTER_API_KEY", "model": "deepseek/deepseek-chat", "thinking": "minimal" }, { "label": "code", "enabled": true, "baseUrl": "https://api.openrouter.ai/v1", "apiKey": "$OPENROUTER_API_KEY", "model": "anthropic/claude-3.5-sonnet", "thinking": "low" }, { "label": "reason", "enabled": true, "baseUrl": "https://api.openrouter.ai/v1", "apiKey": "$OPENROUTER_API_KEY", "model": "deepseek/deepseek-reasoner", "thinking": "high" } ], "aggregator": { "baseUrl": "https://api.openrouter.ai/v1", "apiKey": "$OPENROUTER_API_KEY", "model": "anthropic/claude-3.5-sonnet", "thinking": "low" }, "minSuccessfulProposers": 2, "quorumGraceSeconds": 10, "proposerTimeoutSeconds": 1200, "aggregatorTimeoutSeconds": 1800, "draftMaxChars": 8000, "shuffleCandidates": true }$OPENROUTER_API_KEYis read from the environment — or paste the key directly.Reload pi (or press
/reload).Pick the model with
/model b5-ensemble/b5-fusion.Chat — the status bar shows live candidates, then the panel shows results.
Commands
| Command | Description |
|---|---|
/b5-status |
Show current lineup + aggregator + UI language |
/b5-reload |
Reload config from disk |
/b5-lang [locale] |
Show / switch UI language. auto clears the override |
Examples:
/b5-lang # list supported locales
/b5-lang zh-CN # switch to Simplified Chinese
/b5-lang auto # follow the OS locale again
Supported locales: zh-CN 简体中文 · en-US English · de-DE Deutsch · ru-RU Русский · ko-KR 한국어 · ja-JP 日本語 · sa-Deva संस्कृतम्.
How it works
User prompt
│
▼ (every turn)
┌────────── proposer fan-out ──────────┐
│ candidate 1 ─────────► draft │
│ candidate 2 ─────────► draft │
│ ... │
│ candidate N ─────────► draft + 🧠 │
└────────── (when quorum met) ──────────┘
│
▼
┌── aggregator (single model, tool-capable) ──┐
│ sees: original prompt + every draft │
│ + every thinking/reasoning block │
│ produces: one fused answer (may call tools) │
└──────────────────────────────────────────────┘
│
▼
User
Latency optimisation: as soon as minSuccessfulProposers drafts arrive, B5 Fusion waits quorumGraceSeconds (default 10s) then aborts the still-running slow candidates. The aggregator starts immediately, so wall time ≈ slowest fast candidate, not slowest candidate.
Quorum failure: if fewer than minSuccessfulProposers succeed, the aggregator is told to run anyway but warned that draft references are reduced.
Config reference
See docs/configuration.md for the full schema, default values, and per-field semantics.
Highlights:
| Field | Default | Meaning |
|---|---|---|
enabled |
false |
Master switch |
language |
"auto" |
"auto" follows OS locale; otherwise a supported locale code |
candidates[] |
[] |
Enabled candidates run on every turn |
aggregator |
(empty) | Single fusion model — should support tool calling |
minSuccessfulProposers |
2 |
Required quorum for fusion to proceed |
quorumGraceSeconds |
30 |
Wait this long after quorum, then abort slow candidates |
proposerTimeoutSeconds |
300 |
Hard per-request timeout for proposers |
aggregatorTimeoutSeconds |
480 |
Hard per-request timeout for aggregator |
draftMaxChars |
8000 |
Per-candidate truncation sent to aggregator |
shuffleCandidates |
true |
Randomize order to remove position bias |
API keys can be inline strings or $ENV_VAR references resolved from process.env.
Architecture
extensions/b5-fusion/
├── index.ts # Extension entry: provider + commands + prompt hook
├── config.ts # Settings types, persistence, validation
├── ensemble-engine.ts # Proposer fan-out, quorum, aggregator streaming
├── openai-client.ts # OpenAI-compatible HTTP + SSE streaming
├── aggregator-prompt.ts # Multilingual user-message builder
├── b5-fusion-prompt.ts # Multilingual system prompt dispatcher
├── i18n.ts # Translation core (detect + override + fallback)
└── locales/
├── zh-CN.ts # 简体中文
├── en-US.ts # English (reference)
├── de-DE.ts # Deutsch
├── ru-RU.ts # Русский
├── ko-KR.ts # 한국어
├── ja-JP.ts # 日本語
└── sa-Deva.ts # संस्कृतम् (IAST transliteration)
See docs/architecture.md for the per-module contract.
Limitations
- Each
enabled: truecandidate must be reachable. There is no in-built retry across endpoints. - The aggregator decides whether to use tools. Proposers are reference-draft only and never get tool definitions.
- Reasoning budget. Different vendors expose reasoning differently. The extension transparently forwards
reasoning_content(DeepSeek-style) and<THINKING>blocks; other vendor-specific formats will land as plain text. - The interface is an OpenAI-compatible
/v1/chat/completionsendpoint. Anthropic-Native / Gemini-Native is not auto-translated; route through OpenRouter (or any compatible proxy) to use those models.
Development
# Install bun (used for the locale smoke test)
curl -fsSL https://bun.sh/install | bash
# Run all checks
bun run test
# Validate key coverage across locales
bun run test:locales
# Validate the npm package shape
npm run test:package
License
MIT © 2026 B5 Fusion Contributors.