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
Studio MCP: bound get_job wait_s with a fixed limit, not the patchable MAX_WAIT_S (#16033)
Daniel Han9d3caca3398c
diff --git a/studio/backend/studio_mcp/loading.py b/studio/backend/studio_mcp/loading.pyindex 056c137b6a2..b65893f667d 100644--- a/studio/backend/studio_mcp/loading.py+++ b/studio/backend/studio_mcp/loading.py@@ -30,6 +30,9 @@ from studio_mcp.tools import as_dict, number, opt_text, route_json, strings, tryPOLL_INTERVAL_S = 2.0# The longest a load_model or get_job call waits before returning (user decision); clients must allow more.MAX_WAIT_S = 240+# The schema bound for wait_s. Tests shorten MAX_WAIT_S to fractions of a second, and get_job's schema can be+# built while they do (its annotations are lazy), so the bound must not read the patchable value.+WAIT_S_LIMIT = 240# What a caller still waiting on a job is told to wait before its next get_job without wait_s.POLL_AFTER_S = 10# Forwarded reads have no HTTP timeout; a status or progress read taking longer counts as failed.diff --git a/studio/backend/studio_mcp/tools/jobs.py b/studio/backend/studio_mcp/tools/jobs.pyindex 3a70ccf81d4..d4877ea7c79 100644--- a/studio/backend/studio_mcp/tools/jobs.py+++ b/studio/backend/studio_mcp/tools/jobs.py@@ -342,7 +342,7 @@ async def get_job(int,Field(ge = 0,- le = loading.MAX_WAIT_S,+ le = loading.WAIT_S_LIMIT,description = ("Seconds to wait for the job to finish or move on, 0 to 240. ""50 stays under Codex's 60 s default tool timeout; above that, raise the client's timeout."diff --git a/studio/backend/tests/test_mcp_tools_jobs.py b/studio/backend/tests/test_mcp_tools_jobs.pyindex bf877c77aa1..19568378c54 100644--- a/studio/backend/tests/test_mcp_tools_jobs.py+++ b/studio/backend/tests/test_mcp_tools_jobs.py@@ -261,3 +261,19 @@ def test_a_first_read_that_stalls_ends_with_a_retry_hint(monkeypatch):assert time.monotonic() - started < 5assert result["isError"] is Trueassert "call get_job again" in result["content"][0]["text"]+++def test_the_wait_bound_holds_while_max_wait_is_shortened(monkeypatch):+ # get_job's annotations are lazy: the schema is built on first use, which can be inside a test that has+ # shortened MAX_WAIT_S to 0.1. An int field bounded by that float cannot be built at all.+ import typing++ from pydantic import TypeAdapter, ValidationError++ from studio_mcp.tools import jobs++ monkeypatch.setattr(loading, "MAX_WAIT_S", 0.1)+ wait_s = TypeAdapter(typing.get_type_hints(jobs.get_job, include_extras = True)["wait_s"])+ assert wait_s.validate_python(240) == 240+ with pytest.raises(ValidationError):+ wait_s.validate_python(241)