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.

Studio: pin which rejection site the confirm-stream tests assert (#10284)

Daniel Han0bb033e3877c
diff --git a/studio/backend/tests/test_openai_tool_passthrough.py b/studio/backend/tests/test_openai_tool_passthrough.py
index fe7d0a0292c..382d71d022c 100644
--- a/studio/backend/tests/test_openai_tool_passthrough.py
+++ b/studio/backend/tests/test_openai_tool_passthrough.py
@@ -2341,7 +2341,11 @@ class TestChatCompletionRequestToolFields:
)
self._assert_unsupported_param(resp, param)
- def test_confirm_tool_calls_requires_streaming_for_safetensors_tools(self, monkeypatch):
+ # Same two rejection sites, and same reason to pin one, as the GGUF case below.
+ @pytest.mark.parametrize("validate_before_switch", [False, True])
+ def test_confirm_tool_calls_requires_streaming_for_safetensors_tools(
+ self, monkeypatch, validate_before_switch
+ ):
import routes.inference as inference_route
class _NoGGUFBackend:
@@ -2363,6 +2367,9 @@ class TestChatCompletionRequestToolFields:
"_detect_safetensors_features",
lambda backend, chat_template, tools = None: {"supports_tools": True},
)
+ monkeypatch.setattr(
+ inference_route, "_should_validate_before_switch", lambda: validate_before_switch
+ )
monitor = ApiMonitor(max_entries = 3)
monkeypatch.setattr(inference_route, "api_monitor", monitor)
client = self._v1_client(monkeypatch, _NoGGUFBackend(), _InferenceBackend())
@@ -2381,9 +2388,13 @@ class TestChatCompletionRequestToolFields:
body = resp.json()
assert body["error"]["param"] == "confirm_tool_calls"
assert "requires stream=true" in body["error"]["message"]
- [entry] = monitor.snapshot()
- assert entry["status"] == "error"
- assert "confirm_tool_calls requires stream=true" in entry["error"]
+ if validate_before_switch:
+ # Early site rejects before the monitor row is opened.
+ assert monitor.snapshot() == []
+ else:
+ [entry] = monitor.snapshot()
+ assert entry["status"] == "error"
+ assert "confirm_tool_calls requires stream=true" in entry["error"]
assert monitor.active_count() == 0
def test_multiturn_tool_loop_messages(self):
@@ -4195,7 +4206,14 @@ class TestGgufVisionToolRouting:
assert exc.value.status_code == 400
assert exc.value.detail["error"]["param"] == "tool_choice"
- def test_confirm_tool_calls_requires_streaming_for_gguf_tools(self, monkeypatch):
+ # Two sites reject this shape and `_should_validate_before_switch()` picks
+ # which; the early one runs before the api_monitor row is opened. It reads
+ # process-wide state, so unpinned this asserted whichever site the xdist
+ # worker happened to leave reachable. Pinned, both sites are covered.
+ @pytest.mark.parametrize("validate_before_switch", [False, True])
+ def test_confirm_tool_calls_requires_streaming_for_gguf_tools(
+ self, monkeypatch, validate_before_switch
+ ):
import routes.inference as inf_mod
def _plain(**kwargs):
@@ -4214,6 +4232,9 @@ class TestGgufVisionToolRouting:
generate_chat_completion_with_tools = _tools,
)
monkeypatch.setattr(inf_mod, "get_llama_cpp_backend", lambda: backend)
+ monkeypatch.setattr(
+ inf_mod, "_should_validate_before_switch", lambda: validate_before_switch
+ )
monitor = ApiMonitor(max_entries = 3)
monkeypatch.setattr(inf_mod, "api_monitor", monitor)
@@ -4236,9 +4257,15 @@ class TestGgufVisionToolRouting:
)
assert exc.value.status_code == 400
assert "requires stream=true" in exc.value.detail["error"]["message"]
- [entry] = monitor.snapshot()
- assert entry["status"] == "error"
- assert "confirm_tool_calls requires stream=true" in entry["error"]
+ if validate_before_switch:
+ # Early site rejects before the monitor row is opened, so there is no
+ # row to fail; opening one here would be a behaviour change, not a fix.
+ assert monitor.snapshot() == []
+ else:
+ [entry] = monitor.snapshot()
+ assert entry["status"] == "error"
+ assert "confirm_tool_calls requires stream=true" in entry["error"]
+ # Neither site may leave a row running.
assert monitor.active_count() == 0
def test_standard_gguf_stream_splits_reasoning_content(self, monkeypatch):