router-for-me/CLIProxyAPI · error

model stream bridge is unavailable

Error message

model stream bridge is unavailable

What it means

modelStreamBridge.read() guards b == nil, so calling read on a nil bridge (one that was never constructed or whose owner failed to initialize) yields this error. The bridge mediates streaming model execution chunks between the host and plugins; a nil bridge means the streaming bridge feature was not wired up in this build or code path.

Source

Thrown at internal/pluginhost/model_stream_bridge.go:49

		if cancel != nil {
			cancel()
		}
		return ""
	}
	id := strconv.FormatUint(b.next.Add(1), 10)
	b.mu.Lock()
	b.streams[id] = modelStreamEntry{
		ownerCallbackID: ownerCallbackID,
		chunks:          chunks,
		cancel:          cancel,
	}
	b.mu.Unlock()
	return id
}

func (b *modelStreamBridge) read(ctx context.Context, id string) (handlers.ModelExecutionChunk, bool, error) {
	if b == nil {
		return handlers.ModelExecutionChunk{}, true, fmt.Errorf("model stream bridge is unavailable")
	}
	if id == "" {
		return handlers.ModelExecutionChunk{}, true, fmt.Errorf("model stream id is required")
	}
	b.mu.Lock()
	entry, ok := b.streams[id]
	b.mu.Unlock()
	if !ok || entry.chunks == nil {
		return handlers.ModelExecutionChunk{}, true, nil
	}
	if ctx == nil {
		ctx = context.Background()
	}
	select {
	case <-ctx.Done():
		b.close(id)
		return handlers.ModelExecutionChunk{}, true, ctx.Err()
	case chunk, okRead := <-entry.chunks:

View on GitHub (pinned to 78f0c4079e)

Solutions

  1. Construct the Host via its normal builder/constructor so the model stream bridge is initialized
  2. Check for a nil bridge before issuing streaming model calls and return a clearer error
  3. In tests, provide a real (or stub non-nil) bridge

Example fix

// before
var b *modelStreamBridge
chunk, done, err := b.read(ctx, id)

// after
if b == nil {
    return handlers.ModelExecutionChunk{}, true, errors.New("model streaming is not initialized")
}
chunk, done, err := b.read(ctx, id)
Defensive patterns

Strategy: validation

Validate before calling

if b == nil {
    return handlers.ModelExecutionChunk{}, true, errors.New("model streaming is not initialized")
}

Prevention

When it happens

Trigger: Invoking Host streaming-model APIs that route through the bridge before the bridge was created; embedding the SDK without initializing the model stream bridge; a host code path constructing Host partially in tests/mocks.

Common situations: Unit tests with a hand-built Host struct that skips bridge initialization; SDK embedding that bypasses the normal constructor.

Related errors


AI-assisted analysis of router-for-me/CLIProxyAPI@78f0c4079e (2026-08-15). Data as JSON: /api/errors/fc912a62ce79fa0e. Report an issue: GitHub.