From 3b0b66cbd1d5ef517416136fdfc3fe92efd14f5a Mon Sep 17 00:00:00 2001 From: Alok Saboo Date: Tue, 25 Aug 2026 09:47:25 -0400 Subject: [PATCH] feat: extracting context window from llama.cpp metadata --- .../config/context_window_detection.py | 1 + .../config/test_context_window_detection.py | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/deeptutor/services/config/context_window_detection.py b/deeptutor/services/config/context_window_detection.py index a54a1d007..88e0ac910 100644 --- a/deeptutor/services/config/context_window_detection.py +++ b/deeptutor/services/config/context_window_detection.py @@ -32,6 +32,7 @@ _CONTEXT_WINDOW_KEYS = ( "max_prompt_tokens", "max_model_len", "max_sequence_length", + "n_ctx", ) _KNOWN_CONTEXT_WINDOWS: tuple[tuple[str, int], ...] = ( diff --git a/tests/services/config/test_context_window_detection.py b/tests/services/config/test_context_window_detection.py index 2ef9ee9ce..b965ca74b 100644 --- a/tests/services/config/test_context_window_detection.py +++ b/tests/services/config/test_context_window_detection.py @@ -99,6 +99,28 @@ def test_extract_context_window_reads_novita_context_size_key() -> None: ) +def test_extract_context_window_reads_llamacpp_n_ctx_meta() -> None: + """llama.cpp exposes the effective window as ``meta.n_ctx`` for loaded models.""" + payload = { + "data": [ + { + "id": "Qwen3.8-27B:Q6_K_XL", + "status": { + "value": "loaded", + "args": ["--alias", "Qwen3.8-27B:Q6_K_XL", "--ctx-size", "400000"], + }, + "preset": "ctx-size = 400000\n", + "meta": {"n_ctx": 200_192, "n_ctx_train": 262_144}, + }, + ] + } + + assert ( + detection_module._extract_context_window_from_payload(payload, "Qwen3.8-27B:Q6_K_XL") + == 200_192 + ) + + def test_models_endpoint_probe_honors_disable_ssl_verify(monkeypatch) -> None: captured: dict[str, object] = {}