Skip to content

Dedup Ollama provider model-refresh fan-out by daemon base URL #4154

Description

@atomantic

refreshOllamaBackedProviders in server/services/localLlm.js (~line 818, added for the fix that pushes a live model-list refresh to every Ollama-backed provider after installModel/deleteModel succeeds) fans out with no dedup:

function refreshOllamaBackedProviders() {
  getAllProviders().then(({ providers }) => {
    const targets = (providers || []).filter(isOllamaBackedProvider)
    return Promise.all(targets.map((p) => refreshProviderModels(p.id).catch((err) => { ... })))
  })...
}

When N providers (the built-in ollama provider plus one or more Claude/Codex/Gemini-over-Ollama CLI/TUI providers) all resolve to the same Ollama daemon — commonly the shared http://localhost:11434 default, see ollamaBaseFromProvider in server/lib/aiToolkit/providers.js (~line 129) — this Promise.all calls refreshProviderModels(p.id) once per provider, each independently re-fetching /api/tags and re-running the full per-model /api/show tool-capability probe against the identical daemon/model set.

Fix shape

Group providers by normalized base URL (ollamaBaseFromProvider) before fanning out: compute the tool-capable model list once per unique base, then apply the same result to every provider sharing that base. This needs a "compute without persisting" variant exposed from server/lib/aiToolkit/providers.js (today refreshProviderModels(id) both fetches AND persists in one call — see the companion issue on batching writes, which shares this same "split compute from persist" prerequisite). Deferred because it's a larger surface change than a localLlm.js-only fix — needs a new toolkit-level export, not just a caller-side change.

Migrated from PLAN.md by /do:replan --issues.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions