Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Answer /status the runtime fields a backend double cannot invent (#11076)
Daniel Hanb5f26f69271b
diff --git a/studio/backend/tests/llama_backend_double.py b/studio/backend/tests/llama_backend_double.pyindex 50730c025a0..37e7f167298 100644--- a/studio/backend/tests/llama_backend_double.py+++ b/studio/backend/tests/llama_backend_double.py@@ -17,6 +17,12 @@ from __future__ import annotationsfrom typing import Optional+from models.inference import _InferenceRuntimeFields++# Taken from the model, not listed: an Optional field added there needs no edit here, and a+# required one is named by the canary.+_RUNTIME_FIELDS = frozenset(_InferenceRuntimeFields.model_fields)+class FakeLlamaCppBackend:"""The attributes ``routes/inference.py`` reads off a loaded GGUF backend.@@ -27,9 +33,59 @@ class FakeLlamaCppBackend:is_loaded = Truemodel_identifier = "test/model.gguf"- _is_audio = Falseis_vision = Falsesupports_tools = False# Read unguarded on the chat-completions path for the monitor's context-usage readout. None is# what the real property answers before a model is loaded; context-usage tests set a number.context_length: Optional[int] = None++ # Runtime fields /status mirrors, at LlamaCppBackend.__init__'s values. None is not one of+ # them: the response rejects it. Re-declared by hand in the per-test fakes until now, which+ # is how four reasoning fields added in one place reached CI as three red tests naming none.+ is_diffusion = False+ supports_reasoning = False+ reasoning_always_on = False+ reasoning_style = "enable_thinking"+ reasoning_effort_levels: list = []+ reasoning_budget = -1+ reasoning_budget_message = ""+ supports_preserve_thinking = False+ tensor_parallel = False+ gpu_memory_mode = "auto"+ gpu_layers = -1+ n_cpu_moe = 0+ n_moe_layers = 0+ # Private: the only name the real backend has for these, so the one production falls back to.+ _is_audio = False+ _has_audio_input = False+ _has_video_input = False+ _disable_vision = False+ _vision_disabled_by_user = False+ _requested_reasoning_budget = -1+ _requested_reasoning_budget_message = ""+ # Read straight off the backend, not through the model-field loop, so an absent one is an+ # AttributeError before the drift check can name it.+ requested_spec_mode = None+ requested_parallel_slots = 1+ effective_parallel_slots = 1+ requested_n_ctx = 0+ requested_extra_args = None+ spec_fallback_reason = None+ spec_drafter_kind = None++ def __getattr__(self, name):+ """Runtime fields answer as the real backend does; anything else raises.++ Scoped on purpose. A blanket None reads right until a caller defaults an absent+ capability to something else: the route falls back to ``supports_tools`` for+ ``supports_tool_passthrough``, and None is not absent, so the default never runs.++ The private slot comes first, since ``_llama_runtime_fields`` falls back to ``_name``+ and a public None would hide the slot holding the value.+ """+ if name not in _RUNTIME_FIELDS:+ raise AttributeError(name)+ try:+ return object.__getattribute__(self, f"_{name}")+ except AttributeError:+ return Nonediff --git a/studio/backend/tests/multi_account/test_chat_shared_resident.py b/studio/backend/tests/multi_account/test_chat_shared_resident.pyindex 5c30c9e171c..e22e284ff4f 100644--- a/studio/backend/tests/multi_account/test_chat_shared_resident.py+++ b/studio/backend/tests/multi_account/test_chat_shared_resident.py@@ -77,12 +77,6 @@ class FakeLlama(FakeLlamaCppBackend):self._openai_gguf_companion_state = ()self.unloaded = False- def __getattr__(self, name):- # Status reads many optional runtime fields; an unset one reads as the real backend's None.- if name.startswith("__"):- raise AttributeError(name)- return None-def adopt_load_intent_if_matched(self, intent):return Truediff --git a/studio/backend/tests/test_llama_backend_double.py b/studio/backend/tests/test_llama_backend_double.pyindex 9cbde1357e0..3dad759fd10 100644--- a/studio/backend/tests/test_llama_backend_double.py+++ b/studio/backend/tests/test_llama_backend_double.py@@ -8,22 +8,49 @@ a backend that cannot exist.Upward, the one that bit: the route must still serve a request driven by a bare double. #8700 addedan unguarded ``context_length`` read and updated five of eight test files, giving 19 failures split-between ``AttributeError`` and 20-second timeouts, neither naming the attribute. The canary below-fails in one place instead, with the attribute in the message.+between ``AttributeError`` and 20-second timeouts, neither naming the attribute. The canaries below+fail in one place instead, with the attribute in the message: one drives /chat/completions, and one+checks that /status can answer every runtime field it mirrors off the backend."""from __future__ import annotationsimport pytestfrom fastapi import FastAPI+from pydantic import ValidationErrorfrom fastapi.testclient import TestClientfrom auth.authentication import get_current_subject+from models.inference import _InferenceRuntimeFieldsimport routes.inference as inference_routefrom .llama_backend_double import FakeLlamaCppBackend+def test_status_runtime_fields_survive_a_double_that_answers_none():+ """A runtime field that rejects None needs a real value on the shared double.++ The chat-completions canary does not reach /status, the one route that mirrors every+ `_InferenceRuntimeFields` name off the backend, so a field added to that model and nowhere+ else is served as None and rejected by its own response. That arrived as three red+ multi-account tests asserting `{"detail":"Failed to get status"}`, naming neither the field+ nor the double. This fails here instead, with the field in the message.+ """+ fields = inference_route._llama_runtime_fields(FakeLlamaCppBackend())+ # Supplied by the route, not the backend; _llama_runtime_fields excuses it for that reason.+ fields["requires_trust_remote_code"] = False++ try:+ _InferenceRuntimeFields(**fields)+ except ValidationError as error:+ rejected = sorted({str(item["loc"][0]) for item in error.errors()})+ raise AssertionError(+ f"/status cannot answer {rejected} from a backend double: the field is not Optional, "+ "so None is not a value it accepts. Give it the value LlamaCppBackend.__init__ uses "+ "in FakeLlamaCppBackend, rather than to one test's fake."+ ) from None++def test_the_double_claims_nothing_the_real_backend_lacks():"""Every attribute the double declares exists on the real backend."""from core.inference.llama_cpp import LlamaCppBackend