You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ListModels inherits remote-endpoint latency: no caching on the catalog read path #1807
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
malibio commentedon Jul 31, 2026
Frontend baseline: 171 test files passed, 4113 tests passed (45.85s)
Cache OpenAI-compat model discovery with a 30s TTL (#1860)