From 29d0541ac9e8aad8b51c7a3a84fc279d76a0a2f2 Mon Sep 17 00:00:00 2001 From: Teknium Date: Sat, 21 Mar 2026 18:07:18 -0700 Subject: [PATCH] fix(model_metadata): use /v1/props endpoint for llama.cpp context detection Recent versions of llama.cpp moved the server properties endpoint from /props to /v1/props (consistent with the /v1 API prefix convention). The server-type detection path and the n_ctx reading path both used the old /props URL, which returns 404 on current builds. This caused the allocated context window size to fall back to a hardcoded default, resulting in an incorrect (too small) value being displayed in the TUI context bar. Fix: try /v1/props first, fall back to /props for backward compatibility with older llama.cpp builds. Both paths are now handled gracefully. --- agent/model_metadata.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/agent/model_metadata.py b/agent/model_metadata.py index e3636b6fe..8fb7d6f71 100644 --- a/agent/model_metadata.py +++ b/agent/model_metadata.py @@ -260,9 +260,11 @@ def detect_local_server_type(base_url: str) -> Optional[str]: pass except Exception: pass - # llama.cpp exposes /props + # llama.cpp exposes /v1/props (older builds used /props without the /v1 prefix) try: - r = client.get(f"{server_url}/props") + r = client.get(f"{server_url}/v1/props") + if r.status_code != 200: + r = client.get(f"{server_url}/props") # fallback for older builds if r.status_code == 200 and "default_generation_settings" in r.text: return "llamacpp" except Exception: @@ -455,8 +457,11 @@ def fetch_endpoint_model_metadata( ) if is_llamacpp: try: - props_url = candidate.rstrip("/").replace("/v1", "") + "/props" - props_resp = requests.get(props_url, headers=headers, timeout=5) + # Try /v1/props first (current llama.cpp); fall back to /props for older builds + base = candidate.rstrip("/").replace("/v1", "") + props_resp = requests.get(base + "/v1/props", headers=headers, timeout=5) + if not props_resp.ok: + props_resp = requests.get(base + "/props", headers=headers, timeout=5) if props_resp.ok: props = props_resp.json() gen_settings = props.get("default_generation_settings", {})