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
Fix Code tool placement for ChatGPT subscriptions (#11628)
lorenzozane8d632de715c0
diff --git a/studio/backend/core/inference/providers.py b/studio/backend/core/inference/providers.pyindex 8e0233083b0..161eb0fea91 100644--- a/studio/backend/core/inference/providers.py+++ b/studio/backend/core/inference/providers.py@@ -25,6 +25,8 @@ PROVIDER_REGISTRY: dict[str, dict[str, Any]] = {"gpt-5.6-sol","gpt-5.6-terra","gpt-6-astra",+ "gpt-6-luna",+ "gpt-6-sol",],"model_capabilities": {"gpt-5.4": {"vision": True, "studio_tools": True},@@ -34,6 +36,8 @@ PROVIDER_REGISTRY: dict[str, dict[str, Any]] = {"gpt-5.6-sol": {"vision": True, "studio_tools": True},"gpt-5.6-terra": {"vision": True, "studio_tools": True},"gpt-6-astra": {"vision": True, "studio_tools": True},+ "gpt-6-luna": {"vision": True, "studio_tools": True},+ "gpt-6-sol": {"vision": True, "studio_tools": True},},"supports_streaming": True,"supports_vision": True,diff --git a/studio/backend/tests/test_openai_codex_subscription.py b/studio/backend/tests/test_openai_codex_subscription.pyindex df29d836acb..303f1093939 100644--- a/studio/backend/tests/test_openai_codex_subscription.py+++ b/studio/backend/tests/test_openai_codex_subscription.py@@ -88,7 +88,11 @@ def test_protocol_constants_and_curated_provider_contract():"gpt-5.6-sol","gpt-5.6-terra","gpt-6-astra",+ "gpt-6-luna",+ "gpt-6-sol",]+ for model in ("gpt-6-luna", "gpt-6-sol"):+ assert info["model_capabilities"][model] == {"vision": True, "studio_tools": True}assert OPENAI_CODEX_DEVICE_REDIRECT_URI == ("https://auth.openai.com/deviceauth/callback")row = next(item for item in list_available_providers() if item["provider_type"] == "openai_codex"diff --git a/studio/frontend/src/features/chat/api/chat-adapter.ts b/studio/frontend/src/features/chat/api/chat-adapter.tsindex 46c8cb2fb9e..78efb1a410f 100644--- a/studio/frontend/src/features/chat/api/chat-adapter.ts+++ b/studio/frontend/src/features/chat/api/chat-adapter.ts@@ -6051,8 +6051,9 @@ export function createOpenAIStreamAdapter((!isExternalRequest && supportsTools && toolsEnabled),fetch: webFetchEnabledForThisTurn,code:- codeExecEnabledForThisTurn ||- (!isExternalRequest && supportsTools && codeToolsEnabled),+ hostedCodeToolsForThisTurn.length > 0 ||+ (supportsStudioToolsForThisTurn &&+ studioLocalCodeTools.length > 0),images: imageGenerationEnabledForThisTurn,mcp: supportsStudioToolsForThisTurn && mcpEnabledForChat,docs:diff --git a/studio/frontend/src/features/chat/provider-capabilities.ts b/studio/frontend/src/features/chat/provider-capabilities.tsindex 2dec9527046..447fe9a9f29 100644--- a/studio/frontend/src/features/chat/provider-capabilities.ts+++ b/studio/frontend/src/features/chat/provider-capabilities.ts@@ -484,10 +484,6 @@ export function providerSupportsBuiltinCodeExecution(normalized.startsWith(prefix),);}- if (providerType === "openai_codex") {- return providerModelSupportsStudioTools(providerType, modelId) === true;- }-if (providerType === "openai") {if (!isOpenAICloudBaseUrl(baseUrl)) return false;return OPENAI_CODE_EXECUTION_MODEL_PREFIXES.some((prefix) =>diff --git a/studio/frontend/src/features/chat/shared-composer.tsx b/studio/frontend/src/features/chat/shared-composer.tsxindex 790eb5b2aea..dc60868be6f 100644--- a/studio/frontend/src/features/chat/shared-composer.tsx+++ b/studio/frontend/src/features/chat/shared-composer.tsx@@ -811,9 +811,8 @@ export function SharedComposer({? reasoningLockedOn || (effectiveReasoningVisualEnabled && !reasoningDisabled): reasoningLockedOn || (effectiveReasoningEnabled && !reasoningDisabled);// Two-pill gating. Search: supportsTools (Code/python plus local web_search) OR- // supportsBuiltinWebSearch (OpenAI/Anthropic/OpenRouter/Kimi). Code: the local runtime OR- // Anthropic with a model taking code_execution_20250825, the only external code-execution tool- // today, per providerSupportsBuiltinCodeExecution.+ // supportsBuiltinWebSearch (OpenAI/Anthropic/OpenRouter/Kimi). Code: supportsTools OR the+ // provider's own sandbox, per providerSupportsBuiltinCodeExecution.const supportsBuiltinCodeExecution = providerSupportsBuiltinCodeExecution(selectedExternalProvider?.providerType,effectiveExternalModelId,diff --git a/studio/frontend/tests/code-tool-placement.test.ts b/studio/frontend/tests/code-tool-placement.test.tsindex 7667682b59d..805062ffd9a 100644--- a/studio/frontend/tests/code-tool-placement.test.ts+++ b/studio/frontend/tests/code-tool-placement.test.ts@@ -143,6 +143,18 @@ test("the branch is only taken when a tool Unsloth itself can run is on", () =>assert.match(gate, /studioLocalCodeTools\.length > 0/);});+test("response details record Code from the placement, local or hosted", () => {+ // An external connection with no sandbox (openai_codex, vLLM, ...) sends the local+ // names, so keying on the hosted flag or a local model reported Code as off.+ const start = SOURCE.indexOf("const buildResponseDetails = (");+ const tools = SOURCE.slice(start, SOURCE.indexOf("images:", start));+ assert.match(tools, /code:\s*hostedCodeToolsForThisTurn\.length > 0 \|\|/);+ assert.match(+ tools,+ /\(supportsStudioToolsForThisTurn &&\s*studioLocalCodeTools\.length > 0\)/,+ );+});+// ── Whether the pill is offered at all ─────────────────────────────// Until Unsloth's loop reached the general external providers, the composerdiff --git a/studio/frontend/tests/provider-capabilities-current-models.test.ts b/studio/frontend/tests/provider-capabilities-current-models.test.tsindex bf18b60af34..5f9f47d54d7 100644--- a/studio/frontend/tests/provider-capabilities-current-models.test.ts+++ b/studio/frontend/tests/provider-capabilities-current-models.test.ts@@ -15,14 +15,21 @@ const {clampReasoningEffortToLevels,getExternalMaxOutputTokens,getExternalReasoningCapabilities,+ providerHostsCodeExecution,providerSupportsBuiltinCodeExecution,providerSupportsBuiltinWebSearch,providerSupportsFastMode,} = await import("../src/features/chat/provider-capabilities.ts");-const { providerModelSupportsVision, setProviderModelCapabilities } = await import(- "../src/features/chat/external-providers.ts"+const {+ providerModelSupportsStudioTools,+ providerModelSupportsVision,+ setProviderModelCapabilities,+} = await import("../src/features/chat/external-providers.ts");++const { codeToolCanRun, selectCodeToolNames } = await import(+ "../src/features/chat/api/code-tool-placement.ts");// Every capability table is prefix-based, so an un-widened prefix silently drops a@@ -280,7 +287,24 @@ test("the chat-latest aliases advertise no reasoning at all", () => {);});-test("ChatGPT subscription models expose Unsloth-owned search and code tools", () => {+test("GPT-6 Sol and Luna subscription models use local Code tools", () => {+ setProviderModelCapabilities("openai_codex", {+ "gpt-6-sol": { vision: true, studio_tools: true },+ "gpt-6-luna": { vision: true, studio_tools: true },+ });+ for (const model of ["gpt-6-sol", "gpt-6-luna"]) {+ assert.equal(providerModelSupportsStudioTools("openai_codex", model), true);+ assert.equal(providerModelSupportsVision("openai_codex", model), true);+ assert.deepEqual(selectCodeToolNames({+ codeToolsEnabled: true,+ hostedCodeExecutionForThisTurn: providerSupportsBuiltinCodeExecution("openai_codex", model),+ providerHostsCodeExecution: providerHostsCodeExecution("openai_codex"),+ }), { local: ["python", "terminal", "edit_file"], hosted: [] });+ }+});+++test("ChatGPT subscription models expose Unsloth-owned search and local code tools", () => {setProviderModelCapabilities("openai_codex", {"gpt-5.3-codex-spark": { vision: false, studio_tools: true },@@ -294,7 +318,29 @@ test("ChatGPT subscription models expose Unsloth-owned search and code tools", (assert.equal(caps.reasoningStyle, "reasoning_effort", model);assert.equal(getExternalMaxOutputTokens("openai_codex", model), 128000, model);assert.equal(providerSupportsBuiltinWebSearch("openai_codex", model), true, model);- assert.equal(providerSupportsBuiltinCodeExecution("openai_codex", model), true, model);+ const hostedCodeExecutionForThisTurn = providerSupportsBuiltinCodeExecution(+ "openai_codex",+ model,+ );+ const sandbox = providerHostsCodeExecution("openai_codex");+ assert.deepEqual(+ selectCodeToolNames({+ codeToolsEnabled: true,+ hostedCodeExecutionForThisTurn,+ providerHostsCodeExecution: sandbox,+ }),+ { local: ["python", "terminal", "edit_file"], hosted: [] },+ model,+ );+ assert.equal(+ codeToolCanRun({+ hostedCodeExecutionForThisTurn,+ providerHostsCodeExecution: sandbox,+ supportsStudioTools: providerModelSupportsStudioTools("openai_codex", model) === true,+ }),+ true,+ model,+ );}});@@ -401,3 +447,50 @@ test("earlier Claude 4 and 3.7 Sonnet keep a Thinking control the backend can se["none", "low", "medium", "high", "max"],);});++// #11557: claiming a sandbox the backend registry lacks sends `code_execution` to a connection that runs nothing.+test("hosted Code is only claimed where the backend registry hosts code_execution", () => {+ const here = path.dirname(fileURLToPath(import.meta.url));+ const source = readFileSync(+ path.join(here, "../../backend/core/inference/providers.py"),+ "utf8",+ );+ const start = source.indexOf("PROVIDER_REGISTRY");+ const registry = source.slice(start, source.indexOf("\n}\n", start));+ const entries = [...registry.matchAll(/^ {4}"([a-z0-9_]+)": \{/gm)];+ assert.ok(entries.length > 5, "PROVIDER_REGISTRY moved");+ const backendSandboxes = new Set<string>();+ for (const [i, entry] of entries.entries()) {+ const body = registry.slice(entry.index, entries[i + 1]?.index);+ const hosted = /"hosted_tools":\s*\(([^)]*)\)/.exec(body)?.[1] ?? "";+ if (/"code_execution"/.test(hosted)) backendSandboxes.add(entry[1]);+ }+ assert.ok(backendSandboxes.size > 0, "no provider hosts code_execution");++ const models = [+ "gpt-6-astra",+ "gpt-5.6-sol",+ "gpt-5.5-pro",+ "gpt-5.5",+ "gpt-5.4",+ "claude-opus-4-8",+ "gemini-3-pro",+ ];+ for (const [, providerType] of entries) {+ // studio_tools on: what the removed openai_codex branch keyed on.+ setProviderModelCapabilities(+ providerType,+ Object.fromEntries(models.map((m) => [m, { studio_tools: true }])),+ );+ assert.equal(+ providerHostsCodeExecution(providerType),+ backendSandboxes.has(providerType),+ providerType,+ );+ for (const model of models) {+ if (providerSupportsBuiltinCodeExecution(providerType, model)) {+ assert.ok(backendSandboxes.has(providerType), `${providerType} ${model}`);+ }+ }+ }+});