Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix(ollama): share one model-list timeout across LLM + embedding providers (#5182)

LearningCircuit1ecc9a0ed292
diff --git a/changelog.d/+ollama-model-list-timeout-shared.bugfix.md b/changelog.d/+ollama-model-list-timeout-shared.bugfix.md
new file mode 100644
index 0000000000..30bc977200
--- /dev/null
+++ b/changelog.d/+ollama-model-list-timeout-shared.bugfix.md
@@ -0,0 +1 @@
+Apply the same generous 5-second Ollama model-list timeout to embedding-model discovery as to LLM-model discovery. The embedding provider still used a 2→3-second timeout, so on a cold Ollama the embedding-model dropdown could come up empty for the same reason the language-model dropdown did. Both providers now share a single `OLLAMA_MODEL_LIST_TIMEOUT` constant so the value can't drift apart again.
diff --git a/src/local_deep_research/embeddings/providers/implementations/ollama.py b/src/local_deep_research/embeddings/providers/implementations/ollama.py
index 84447e793c..868dac9622 100644
--- a/src/local_deep_research/embeddings/providers/implementations/ollama.py
+++ b/src/local_deep_research/embeddings/providers/implementations/ollama.py
@@ -199,12 +199,18 @@ class OllamaEmbeddingsProvider(BaseEmbeddingProvider):
name. Older Ollama servers without capabilities → models are
returned untagged and the user decides.
"""
- from ....utilities.llm_utils import fetch_ollama_models
+ from ....utilities.llm_utils import (
+ OLLAMA_MODEL_LIST_TIMEOUT,
+ fetch_ollama_models,
+ )
base_url = get_ollama_base_url(settings_snapshot)
# fetch_ollama_models returns every installed model. We pass it
- # through unfiltered — no name heuristic, no exclusions.
- all_models = fetch_ollama_models(base_url, timeout=3.0)
+ # through unfiltered — no name heuristic, no exclusions. Same generous
+ # model-list timeout as the LLM provider (see OLLAMA_MODEL_LIST_TIMEOUT).
+ all_models = fetch_ollama_models(
+ base_url, timeout=OLLAMA_MODEL_LIST_TIMEOUT
+ )
if not all_models:
return []
diff --git a/src/local_deep_research/llm/providers/implementations/ollama.py b/src/local_deep_research/llm/providers/implementations/ollama.py
index 962f495ca0..0f774e7e45 100644
--- a/src/local_deep_research/llm/providers/implementations/ollama.py
+++ b/src/local_deep_research/llm/providers/implementations/ollama.py
@@ -59,7 +59,10 @@ class OllamaProvider(BaseLLMProvider):
Returns:
List of model dictionaries with 'value' and 'label' keys
"""
- from ....utilities.llm_utils import fetch_ollama_models
+ from ....utilities.llm_utils import (
+ OLLAMA_MODEL_LIST_TIMEOUT,
+ fetch_ollama_models,
+ )
if not base_url:
logger.warning("Ollama URL not configured")
@@ -80,14 +83,10 @@ class OllamaProvider(BaseLLMProvider):
# Get authentication headers
headers = cls._get_auth_headers(api_key=api_key)
- # Fetch models using centralized function.
- # 5s (not 2s) because a cold Ollama — process just started, connection
- # not yet warm, host busy right after a restart — regularly needs more
- # than 2 seconds to answer /api/tags. A timeout here is silently turned
- # into an empty model list, which surfaces to the user as an empty model
- # dropdown, so err on the side of waiting a little longer.
+ # Fetch models using centralized function. See OLLAMA_MODEL_LIST_TIMEOUT
+ # for why the timeout is generous rather than a couple seconds.
models = fetch_ollama_models(
- base_url, timeout=5.0, auth_headers=headers
+ base_url, timeout=OLLAMA_MODEL_LIST_TIMEOUT, auth_headers=headers
)
# Add provider info and format for LLM API
diff --git a/src/local_deep_research/utilities/llm_utils.py b/src/local_deep_research/utilities/llm_utils.py
index 87bc9b60ac..bb62da271a 100644
--- a/src/local_deep_research/utilities/llm_utils.py
+++ b/src/local_deep_research/utilities/llm_utils.py
@@ -293,9 +293,18 @@ def get_server_url(settings_snapshot: Optional[Dict[str, Any]] = None) -> str:
return server_url
+# Timeout (seconds) for listing installed Ollama models via /api/tags. A cold
+# Ollama — process just started, connection not yet warm, host busy right after
+# a restart — regularly needs more than a couple seconds, and a timeout here is
+# silently turned into an empty model list (which surfaces as an empty model
+# dropdown in the UI). Shared by the LLM and embedding Ollama providers so the
+# two can't drift back apart.
+OLLAMA_MODEL_LIST_TIMEOUT = 5.0
+
+
def fetch_ollama_models(
base_url: str,
- timeout: float = 3.0,
+ timeout: float = OLLAMA_MODEL_LIST_TIMEOUT,
auth_headers: Optional[Dict[str, str]] = None,
) -> list[Dict[str, str]]:
"""
diff --git a/tests/embeddings/test_ollama_embeddings.py b/tests/embeddings/test_ollama_embeddings.py
index 952b8f8dc3..8bf3abf0fd 100644
--- a/tests/embeddings/test_ollama_embeddings.py
+++ b/tests/embeddings/test_ollama_embeddings.py
@@ -858,3 +858,31 @@ class TestOllamaEmbeddingsValidateConfig:
assert is_valid is False
assert error is not None
assert "not available" in error
+
+
+# ── get_available_models ─────────────────────────────────────────────────
+class TestOllamaEmbeddingsAvailableModels:
+ """Tests for get_available_models."""
+
+ def test_uses_generous_model_list_timeout(self):
+ """Lists models with a >=5s timeout so a cold Ollama isn't cut off.
+
+ A too-tight timeout is silently turned into an empty model list — the
+ same empty-dropdown symptom fixed for the LLM provider. Guard against
+ the two Ollama providers drifting apart on this value again.
+ """
+ with (
+ patch(f"{_LLM_UTILS}.fetch_ollama_models") as mock_fetch,
+ patch(
+ f"{_OLLAMA_MODULE}.get_ollama_base_url",
+ return_value="http://localhost:11434",
+ ),
+ ):
+ mock_fetch.return_value = []
+
+ OllamaEmbeddingsProvider.get_available_models()
+
+ assert mock_fetch.call_count == 1
+ _, kwargs = mock_fetch.call_args
+ assert kwargs.get("timeout") is not None
+ assert kwargs["timeout"] >= 5.0