Skip to content

ListModels inherits remote-endpoint latency: no caching on the catalog read path #1807

Closed

Description

@malibio

Context

Raised in review of PR #1806, which added OpenAI-compat model discovery. Non-blocking there; filed as follow-up.

Problem

ListModels used to be a fast local read. It now queries every configured OpenAI-compatible endpoint's /models on each call (packages/daemon/src/services/local_agent_service.rs, discover_openai_compat_models).

The fan-out itself is right: endpoints run concurrently in a JoinSet, so total latency is the slowest endpoint rather than the sum, and discover_models_or_empty degrades per-endpoint so one dead provider cannot blank the catalog.

What is missing is caching:

  • Every ListModels RPC can pay up to DISCOVERY_TIMEOUT (5s) before returning.
  • Three frontend call sites hit it on mount (model-store, agent-store, ai-chat-model-selector), so a single misconfigured endpoint makes the model selector spin for ~5s on every chat open.
  • Nothing bounds the number of configured endpoints, so N configs spawn N concurrent tasks. Small in practice, unenforced.

This is still strictly better than the path it replaced — the native Ollama client had no timeout at all — so it is not a regression.

Suggested direction

A short-TTL cache (~30s) over the discovery result turns a repeated stall into a one-time one.

The real design question is invalidation: a user who runs ollama pull expects the new model to appear without restarting. Options worth weighing — TTL alone, explicit refresh from the settings/selector refresh buttons that already exist, or invalidate on config write.

Acceptance criteria

  • Repeated ListModels calls within the TTL do not re-query endpoints
  • A newly available model still appears without an app restart; the mechanism is documented
  • A slow or dead endpoint does not stall the selector on every mount

Activity

  1. malibio commented on Jul 31, 2026

    @malibio
    CollaboratorAuthor

    Frontend baseline: 171 test files passed, 4113 tests passed (45.85s)

  2. self-assigned this
    on Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions