Skip to content

[Bug]: Multi-ollama provider routing still broken after #61776 — requests silently go to first provider #63775

@adamai26

Description

@adamai26

Follow-up to #61678 (locked)

#61678 was closed by @steipete after PR #61776 merged, but the fix is incomplete. The issue is locked so I cannot comment there.

Bug: Multi-ollama provider routing still broken

After upgrading to OpenClaw 2026.4.8 (which includes PR #61776), all requests to ollama2 are still silently routed to the first ollama provider (port 11434). Port 11435 receives zero API calls from OpenClaw.

Evidence

1. Zero traffic on ollama2 (port 11435)

Port 11434 (ollama):   828 /api/chat calls
Port 11435 (ollama2):    0 /api/chat calls  ← BUG
Port 11436 (ollama3):   working via /v1/chat/completions

Direct curl to port 11435 works correctly, confirming ollama2 is healthy.

2. "No API provider registered for api: ollama" on every restart

After every gateway restart, compaction fails:

[compaction] Full summarization failed: No API provider registered for api: ollama

Note: this says api: ollama, NOT api: ollama3, even though the affected agent uses ollama3/glm-5.1:cloud. This is because compaction uses the default model ollama/gemma4:e2b.

3. Gateway logs confirm single handler

[gateway] agent model: ollama/gemma4:e2b

All three providers use api: "ollama", but only one handler is registered — bound to port 11434.

Root Cause

PR #61776 fixed createStreamFn to resolve baseUrl per-provider at call time. However, the provider registration mechanism was not fixed:

  • ensureCustomApiRegistered("ollama", streamFn) registers one handler for api: "ollama"
  • When ollama2 and ollama3 initialize, they call ensureCustomApiRegistered with the same api: "ollama" key, which is a no-op (already registered)
  • The registered handler is bound to the first provider's baseUrl (port 11434)
  • Even though createStreamFn now resolves the correct providerBaseUrl, the registered stream function was captured with the first provider's connection, so requests still go to 11434

Suggested Fix

The provider registry needs to differentiate between ollama variants:

  • Option A: Register a separate handler per provider (ollama → 11434, ollama2 → 11435, ollama3 → 11436)
  • Option B: Change registry key from api type to providerId, so each provider gets its own registered stream function

Environment

  • OpenClaw: 2026.4.8 (9ece252)
  • macOS 26.3.1 (arm64), Apple M4
  • Ollama: v0.20.0 (three instances: ports 11434, 11435, 11436)
  • Config: three providers all with api: "ollama"

/cc @steipete (who closed #61678 and merged #61776)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions