# How to Implement the Fusion Strategy in OmniRoute: A Complete Developer Guide

> Learn to implement the Fusion strategy in OmniRoute. This guide details how to fan out requests to multiple model instances and synthesize a single answer with a judge model. Enhance your routing capabilities.

- Repository: [Diego Rodrigues de Sa e Souza/OmniRoute](https://github.com/diegosouzapw/OmniRoute)
- Tags: how-to-guide
- Published: 2026-08-23

---

**The Fusion strategy is a combo routing mode that fans out requests to a panel of multiple model instances in parallel and synthesizes a single authoritative answer through a designated judge model.**

The `diegosouzapw/OmniRoute` repository implements this advanced aggregation pattern to improve response quality through consensus-driven synthesis. By configuring a combo with `strategy: "fusion"`, developers can leverage multi-model redundancy while maintaining clean, unified output for end users.

## What Is the Fusion Strategy in OmniRoute?

**Fusion** operates as a special combo routing strategy that transforms a single incoming request into a distributed computation across multiple model instances. Unlike simple load balancing, Fusion actively collects responses from all participating models—referred to as the **panel**—and delegates final answer synthesis to a **judge** model. This approach captures diverse reasoning patterns while filtering out individual model hallucinations through cross-referencing.

The strategy resides primarily in [`open-sse/services/fusion.ts`](https://github.com/diegosouzapw/OmniRoute/blob/main/open-sse/services/fusion.ts), with panel construction logic abstracted into [`open-sse/services/combo/fusionPanel.ts`](https://github.com/diegosouzapw/OmniRoute/blob/main/open-sse/services/combo/fusionPanel.ts). When enabled, Fusion intercepts incoming chat requests, strips tool definitions for the panel phase (to preserve semantic integrity), and orchestrates parallel execution with configurable timeout and quorum behaviors.

## Step-by-Step Implementation Workflow

### Panel Construction and Resolution

The first phase resolves the combo's `models` list into a fixed-size panel. Each entry can be either a literal model string (e.g., `"gpt-4o"`) or a `combo-ref` that recursively dispatches another combo as a single panel voice. According to [`open-sse/services/combo/fusionPanel.ts`](https://github.com/diegosouzapw/OmniRoute/blob/main/open-sse/services/combo/fusionPanel.ts), the system enforces a hard maximum of **40 panel members** to prevent memory exhaustion—oversized panels trigger an immediate 400 error response.

Panel members are deduplicated and validated before the fan-out phase begins.

### Parameter Tuning and Configuration

Default timing parameters can be overridden per-combo via the `fusionTuning` configuration object. As defined in [`open-sse/services/fusion.ts`](https://github.com/diegosouzapw/OmniRoute/blob/main/open-sse/services/fusion.ts) (lines 26-38), the tunable fields include:

- **`minPanel`**: Minimum successful responses required before the grace timer starts
- **`stragglerGraceMs`**: Duration to wait after quorum is reached for slower panel members
- **`panelHardTimeoutMs`**: Absolute ceiling for panel collection attempts
- **`maxPanel`**: Maximum allowable panel size (default 40)

These parameters control the trade-off between response quality (more answers) and latency (shorter timeouts).

### Tool-Bearing Request Bypass

Fusion implements a critical safety mechanism for tool-bearing requests. If the client supplies tools and does not explicitly set `tool_choice: "none"`, the strategy skips panel synthesis entirely. As implemented in [`open-sse/services/fusion.ts`](https://github.com/diegosouzapw/OmniRoute/blob/main/open-sse/services/fusion.ts) (lines 58-69), the request routes directly to the judge model with tools intact. This prevents the semantic degradation that would occur if tool schemas were stripped from panel members.

### Fan-Out Execution with Quorum-Grace

All panel members receive **non-streaming** calls with tools temporarily removed. The `collectPanel` helper manages execution flow:

1. Dispatch requests to all panel members simultaneously
2. Wait until `minPanel` successes are gathered
3. Start a grace timer (`stragglerGraceMs`) for pending responses
4. Enforce a hard cutoff at `panelHardTimeoutMs`

Timeouts and errors are wrapped in sentinel objects (`{ __timeout?: true, __error?: ... }`) so the collector can distinguish between late results and catastrophic failures without aborting the entire operation.

### Answer Extraction and Normalization

Each successful panel response passes through `extractPanelText`, which handles format variations across OpenAI, Claude, Gemini, and OpenAI Responses APIs. Empty or unparsable responses are recorded as failures rather than empty strings, ensuring the judge only considers substantiated answers. This logic spans lines 49-97 in [`open-sse/services/fusion.ts`](https://github.com/diegosouzapw/OmniRoute/blob/main/open-sse/services/fusion.ts).

### Graceful Degradation Paths

The strategy implements sensible fallback behavior when panel consensus fails:

- **Zero valid answers**: Returns a 503 Service Unavailable error
- **Exactly one valid answer**: Returns the answer directly unless an explicit `judgeModel` is configured in the combo definition

These shortcuts eliminate unnecessary judge latency when synthesis provides no value.

### Judge Prompt Construction and Final Synthesis

When multiple valid answers exist, Fusion constructs a specialized system prompt in `buildJudgePrompt`. The surviving panel answers are anonymized with `[Source N]` markers and embedded in instructions directing the judge to analyze consensus, contradictions, and blind spots. The original request body is extended with a synthetic user turn containing this prompt via `appendUserTurn`.

The judge model—either explicitly configured via `judgeModel` or defaulting to the first surviving panel member—receives this augmented body and streams the final synthesized answer back to the client (lines 84-91 in [`open-sse/services/fusion.ts`](https://github.com/diegosouzapw/OmniRoute/blob/main/open-sse/services/fusion.ts)).

## Practical Implementation Examples

### Basic Fusion Combo Configuration

Define a combo that aggregates three models with custom timing parameters:

```typescript
const myFusionCombo = {
  name: "my-fusion-combo",
  strategy: "fusion",
  models: [
    "gpt-4o",
    "claude-3-sonnet-20240229", 
    "gemini-1.5-flash"
  ],
  // Optional tuning overrides
  fusionTuning: {
    minPanel: 3,               // require at least 3 answers before grace timer
    stragglerGraceMs: 6000,    // wait 6s for slower members
    panelHardTimeoutMs: 45000  // abort after 45s total
  },
  // Optional explicit judge (defaults to first surviving panel member)
  judgeModel: "gpt-4o-mini"
};

```

### Dispatching Requests Through the Combo Router

Integrate Fusion into your request pipeline using the combo handler:

```typescript
import { handleComboChat } from "@/open-sse/services/combo.ts";

const response = await handleComboChat({
  body: { 
    messages: [{ role: "user", content: "Explain quantum tunneling." }], 
    stream: false 
  },
  comboName: "my-fusion-combo",
  // Core functions injected by the runtime
  handleSingleModel,
  log,
  // Optional admission hook, combo registry, etc.
});

```

### Debugging Judge Prompts

Inspect the synthetic prompt sent to the judge for transparency:

```typescript
import { buildJudgePrompt } from "@/open-sse/services/fusion.ts";

const prompt = buildJudgePrompt([
  { text: "Quantum tunneling is a quantum-mechanical phenomenon..." },
  { text: "In quantum physics, particles can penetrate barriers..." }
]);
// prompt contains the full system instruction that the judge receives

```

## Advanced Configuration Patterns

### Per-Target Admission Control

Fusion couples with `perTargetAdmission` hooks to drop panel members whose admission lanes are saturated before dispatch. This prevents head-of-line blocking when specific model providers experience congestion. Configure this in [`open-sse/services/combo.ts`](https://github.com/diegosouzapw/OmniRoute/blob/main/open-sse/services/combo.ts) where the `panelToDispatch` logic filters members based on real-time capacity.

### Customizing the Judge Model Selection

While the default judge selection uses the first successful panel member, production deployments should explicitly define `judgeModel` to ensure consistent reasoning styles. The judge should typically be a capable reasoning model (e.g., GPT-4o or Claude Opus) rather than the fastest available panel member.

## Summary

- **Fusion strategy** fans out requests to up to 40 panel members and synthesizes consensus through a judge model, implemented primarily in [`open-sse/services/fusion.ts`](https://github.com/diegosouzapw/OmniRoute/blob/main/open-sse/services/fusion.ts).
- **Tool-bearing requests** bypass panel synthesis automatically to preserve function-calling semantics, routing directly to the judge with tools intact.
- **Tunable parameters** (`minPanel`, `stragglerGraceMs`, `panelHardTimeoutMs`) control the latency-quality trade-off during parallel execution.
- **Graceful degradation** returns single answers directly when only one panel succeeds, or returns 503 errors when all panels fail.
- **Panel composition** supports literal model strings and recursive `combo-ref` entries for nested aggregation strategies.

## Frequently Asked Questions

### How does Fusion handle oversized panel requests?

OmniRoute rejects panel configurations exceeding 40 members with a 400 Bad Request error before dispatch begins. This hard limit, defined by the `maxPanel` parameter in `fusionTuning`, prevents out-of-memory crashes during high-concurrency scenarios. For larger ensembles, nest combos using `combo-ref` entries to create hierarchical fusion layers.

### Can I use Fusion with function calling and tools?

Yes, but with specific constraints. When tools are present and `tool_choice` is not explicitly set to `"none"`, Fusion bypasses the panel phase entirely and routes the request directly to the configured judge model. This behavior—implemented in [`open-sse/services/fusion.ts`](https://github.com/diegosouzapw/OmniRoute/blob/main/open-sse/services/fusion.ts) (lines 58-69)—preserves tool schema integrity by avoiding the tool-stripping phase required for panel consensus.

### What happens if only one panel member responds successfully?

OmniRoute implements a single-answer shortcut: if exactly one panel member returns a valid response and no explicit `judgeModel` is configured, Fusion returns that answer directly without judge synthesis. This eliminates latency overhead when consensus is impossible. When a `judgeModel` is explicitly defined, the system still routes the single answer through the judge for consistency.

### How are panel timeouts and partial failures handled?

The `collectPanel` function implements a two-stage timeout mechanism. First, it waits for `minPanel` successful responses to establish quorum. Then it starts a `stragglerGraceMs` timer to capture additional responses before the absolute `panelHardTimeoutMs` deadline expires. Failed or slow responses are captured as sentinel objects (`{ __timeout: true }`) and excluded from the judge prompt, allowing partial panels to proceed with synthesis rather than failing the entire request.