fix(model_metadata): cache detect_local_server_type result for process lifetime - #29988
fix(model_metadata): cache detect_local_server_type result for process lifetime#29988uzaylisak wants to merge 1 commit into
Conversation
…s lifetime Every 5 minutes fetch_endpoint_model_metadata() re-runs the full server-type waterfall (LM Studio -> Ollama -> llama.cpp -> vLLM), spraying 404s at endpoints the server never exposes (e.g. /api/v1/models and /api/tags on a vllm backend). Add _endpoint_probe_path_cache (base_url -> server type) so the first successful probe's result is reused for the lifetime of the process. Subsequent refreshes skip straight to the known-good path. Fixes NousResearch#29971.
|
Note: closed PR #29986 was the first attempt at this same fix. |
|
Thanks @uzaylisak — your fix landed! The probe-cache cluster has now landed on main via PR #61368 (merge commit f556edc), which salvaged this cluster of PRs onto current main with structured review, live smoke tests, and full test gates. Your commit was cherry-picked with Closing since this is now merged with your authorship intact. |
Problem
Every 5 minutes
fetch_endpoint_model_metadata()is called (TTL =_ENDPOINT_MODEL_CACHE_TTL = 300). Each time it callsdetect_local_server_type(), which blindly re-runs the full probe waterfall:GET /api/v1/models→ 404 (LM Studio check)GET /api/tags→ 404 (Ollama check)GET /v1/props→ 404 (llama.cpp check)GET /version→ 200 (vLLM — found)On a vllm backend the first three always 404, polluting server logs every 5 minutes. Reported in #29971.
Fix
Add
_endpoint_probe_path_cache: Dict[str, str] = {}at module level.detect_local_server_type()checks this cache on entry; on a hit it returns immediately without making any HTTP requests. On the first call the waterfall runs as before, and if a server type is identified it is stored for the lifetime of the process.The probe stages also use
if result is Noneguards so each step is skipped once an earlier one succeeds — reducing requests even on the very first call.Impact
Closes #29971.