Skip to content

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.

Tests: update two contract tests that #16953 and #16927 left red on main (#17040)

Daniel Hanc8f0ad11aeb8
diff --git a/studio/backend/tests/test_custom_provider_api_type.py b/studio/backend/tests/test_custom_provider_api_type.py
index 68b873d65e9..6b45fd1d890 100644
--- a/studio/backend/tests/test_custom_provider_api_type.py
+++ b/studio/backend/tests/test_custom_provider_api_type.py
@@ -169,6 +169,8 @@ def test_base_url_query_survives_native_provider_calls(monkeypatch):
async with httpx.AsyncClient(transport = httpx.MockTransport(handle)) as transport:
monkeypatch.setattr(ep, "_http_client", transport)
monkeypatch.setattr(ep, "_openrouter_catalog", {})
+ # Empty, so the Anthropic output-cap lookup is made here whatever ran before.
+ monkeypatch.setattr(ep, "_anthropic_output_caps", {})
await drain(
ExternalProviderClient("anthropic", "https://gw.example/v1?tenant=a", "k"),
"claude-sonnet-4-5",
@@ -185,6 +187,8 @@ def test_base_url_query_survives_native_provider_calls(monkeypatch):
asyncio.run(run())
assert [(r.url.path, r.url.query.decode()) for r in sent] == [
+ # The output-cap lookup before an Anthropic stream with no max_tokens (#16953).
+ ("/v1/models/claude-sonnet-4-5", "tenant=a"),
("/v1/messages", "tenant=a"),
("/v1beta/models/gemini-2.5-flash:streamGenerateContent", "tenant=a&alt=sse"),
("/api/v1/models", "tenant=a"),
diff --git a/tests/studio/test_model_picker_contracts.py b/tests/studio/test_model_picker_contracts.py
index 5a94ffb7d26..b876e5bfec6 100644
--- a/tests/studio/test_model_picker_contracts.py
+++ b/tests/studio/test_model_picker_contracts.py
@@ -216,6 +216,24 @@ def _override_lookup_candidates(*args, **kwargs) -> list[str]:
_pytest.skip(f"needs the studio backend environment: {missing.name} is not installed")
+def _override_load_kwargs(*args, **kwargs) -> dict:
+ """The real stored-override to load-kwargs builder, imported like the lookup ladder above:
+ #16927 refactored its flag stripping without changing what it strips."""
+ import sys
+
+ backend = str(WORKDIR / "studio" / "backend")
+ if backend not in sys.path:
+ sys.path.insert(0, backend)
+ try:
+ from utils.openai_auto_switch_settings import model_override_load_kwargs
+ return model_override_load_kwargs(*args, **kwargs)
+ except ModuleNotFoundError as missing:
+ if (missing.name or "").split(".")[0] in {"hub", "loggers", "utils", "core", "models"}:
+ raise
+ import pytest as _pytest
+ _pytest.skip(f"needs the studio backend environment: {missing.name} is not installed")
+
+
def test_models_api_sends_token_via_header_not_query():
"""getModelConfig / checkVisionModel / checkEmbeddingModel must pass the HF
token through hubTokenHeader, never as a ?hf_token= query param (which leaks
@@ -2458,9 +2476,18 @@ def test_batch_sizes_reach_an_api_load_through_the_server_mirror():
gguf_block = store.split(" if is_gguf:", 1)[1]
assert 'kwargs["n_batch"] = override["n_batch"]' in gguf_block
assert 'kwargs["n_ubatch"] = override["n_ubatch"]' in gguf_block
- # A stored pass-through -b / -ub must not outrank the first-class field.
- assert 'strip_batch = "n_batch" in kwargs,' in store
- assert 'strip_ubatch = "n_ubatch" in kwargs,' in store
+ # A stored pass-through -b / -ub must not outrank the first-class field, and survives without one.
+ build = _override_load_kwargs
+ stored = ["-b", "512", "-ub", "256", "--threads", "4"]
+ assert build({"n_batch": 1024, "llama_extra_args": stored}, is_gguf = True) == {
+ "n_batch": 1024,
+ "llama_extra_args": ["-ub", "256", "--threads", "4"],
+ }
+ assert build({"n_ubatch": 128, "llama_extra_args": stored}, is_gguf = True) == {
+ "n_ubatch": 128,
+ "llama_extra_args": ["-b", "512", "--threads", "4"],
+ }
+ assert build({"llama_extra_args": stored}, is_gguf = True) == {"llama_extra_args": stored}
def test_hydration_clears_the_batch_baselines_for_a_batchless_model():