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: stop offering Claude sampling settings that are silently ignored (#12383)

Nilayf8eb9bace6ca
diff --git a/studio/backend/tests/test_anthropic_thinking_translation.py b/studio/backend/tests/test_anthropic_thinking_translation.py
index 221be85d627..075c09a158c 100644
--- a/studio/backend/tests/test_anthropic_thinking_translation.py
+++ b/studio/backend/tests/test_anthropic_thinking_translation.py
@@ -14,7 +14,10 @@ Covers:
"""
import asyncio
+import itertools
import json
+import re
+from pathlib import Path
import httpx
import pytest
@@ -550,3 +553,33 @@ def test_model_capability_tables_cover_claude_5(model, web, code, compaction, fa
)
def test_sampling_capability_handles_alternate_id_spellings(model, sampling_removed):
assert ep_mod._anthropic_sampling_params_removed(model) is sampling_removed
+
+
+def test_frontend_hides_claude_sampling_exactly_where_the_request_strips_it():
+ """A shown slider the request strips does nothing; a hidden one drops a value it would send."""
+ source = (
+ Path(__file__).resolve().parents[2] / "frontend/src/features/chat/provider-capabilities.ts"
+ ).read_text(encoding = "utf-8")
+ literal = re.search(r"const ANTHROPIC_SAMPLING_REMOVED_MODEL =\s*/(.+)/;", source)
+ assert literal, "ANTHROPIC_SAMPLING_REMOVED_MODEL moved"
+ frontend = re.compile(literal.group(1))
+ models = [
+ f"claude-{family}-{major}{minor}{suffix}"
+ for family, major, minor, suffix in itertools.product(
+ ("opus", "sonnet", "haiku", "fable", "mythos", "nova"),
+ ("1", "3", "4", "5", "6", "7", "9", "10"),
+ ("", "-0", "-00", "-1", "-6", "-06", "-7", "-07", "-8", "-10", ".6", ".7"),
+ ("", "-20250514", "-latest"),
+ )
+ ] + [
+ "claude-mythos-preview",
+ "claude-mythos-preview-1",
+ "claude-mythos-previewer",
+ "claude-3-5-sonnet-20241022",
+ "claude-3-7-sonnet-20250219",
+ "claude-opus-latest",
+ ]
+ for model in models:
+ assert bool(frontend.match(model)) is ep_mod._anthropic_sampling_params_removed(
+ model
+ ), model
diff --git a/studio/frontend/src/features/chat/provider-capabilities.ts b/studio/frontend/src/features/chat/provider-capabilities.ts
index 79171e81608..f52ec12bbce 100644
--- a/studio/frontend/src/features/chat/provider-capabilities.ts
+++ b/studio/frontend/src/features/chat/provider-capabilities.ts
@@ -685,13 +685,10 @@ const PROVIDER_CAPABILITIES: Record<string, ProviderCapabilities> = {
repetitionPenalty: false,
presencePenalty: false,
},
- // Anthropic accepts top_k on 3.x and 4.5/4.6, but 4.7 400s on it, so the panel surfaces it
- // and the backend strips per-model. Presence/frequency penalty is not in the Messages API.
- // Claude 4.7 is Opus, Sonnet and Haiku alike. Stripping lives in _stream_anthropic in
- // core/inference/external_provider.py.
+ // _stream_anthropic never sends top_p. Presence/frequency penalty is not in the Messages API.
anthropic: {
temperature: true,
- topP: true,
+ topP: false,
topK: true,
minP: false,
repetitionPenalty: false,
@@ -746,6 +743,10 @@ const PROVIDER_CAPABILITIES: Record<string, ProviderCapabilities> = {
const DEFAULT_EXTERNAL_CAPABILITIES = OPENAI_COMPAT_BASE;
+// Mirrors _anthropic_sampling_params_removed in external_provider.py; a backend test checks they agree.
+const ANTHROPIC_SAMPLING_REMOVED_MODEL =
+ /^claude-(?:mythos-preview(?:-|$)|[a-z]+-(?:[5-9]|\d{2,})(?:[-.]|$)|opus-4[-.](?:0?[7-9]|[1-9]\d)(?:[-.]|$))/;
+
const OPENAI_RESPONSES_FIXED_SAMPLING_MODEL =
/^(?:gpt-5(?:[.-]|$)|gpt-4\.5(?:[.-]|$)|o\d+(?:[.-]|$)|codex-mini(?:[.-]|$)|gpt-6-astra(?:[.-]|$))/;
@@ -773,6 +774,16 @@ export function getProviderCapabilities(
}
return CUSTOM_RESPONSES_CAPABILITIES;
}
+ if (
+ providerType === "anthropic" &&
+ ANTHROPIC_SAMPLING_REMOVED_MODEL.test(modelId?.trim().toLowerCase() ?? "")
+ ) {
+ return {
+ ...PROVIDER_CAPABILITIES.anthropic,
+ temperature: false,
+ topK: false,
+ };
+ }
return PROVIDER_CAPABILITIES[providerType] ?? DEFAULT_EXTERNAL_CAPABILITIES;
}
diff --git a/studio/frontend/tests/provider-capabilities-current-models.test.ts b/studio/frontend/tests/provider-capabilities-current-models.test.ts
index 78992561b23..c765eedd4f0 100644
--- a/studio/frontend/tests/provider-capabilities-current-models.test.ts
+++ b/studio/frontend/tests/provider-capabilities-current-models.test.ts
@@ -15,6 +15,7 @@ const {
clampReasoningEffortToLevels,
getExternalMaxOutputTokens,
getExternalReasoningCapabilities,
+ getProviderCapabilities,
providerHostsCodeExecution,
providerSupportsBuiltinCodeExecution,
providerSupportsBuiltinImageGeneration,
@@ -463,6 +464,37 @@ test("earlier Claude 4 and 3.7 Sonnet keep a Thinking control the backend can se
);
});
+test("the Claude sampling panel offers only what the backend sends Anthropic", () => {
+ for (const id of [
+ "claude-sonnet-4-6",
+ "claude-haiku-4-5-20251001",
+ "claude-3-5-sonnet-20241022",
+ "claude-opus-4-20250514",
+ ]) {
+ const caps = getProviderCapabilities("anthropic", undefined, id);
+ assert.equal(caps?.topP, false, id);
+ assert.equal(caps?.temperature, true, id);
+ assert.equal(caps?.topK, true, id);
+ }
+ for (const id of [
+ "claude-opus-4-7",
+ "claude-opus-4-8",
+ "claude-sonnet-5",
+ "claude-fable-5",
+ "claude-mythos-preview",
+ " Claude-Opus-4.7-20260414 ",
+ ]) {
+ const caps = getProviderCapabilities("anthropic", undefined, id);
+ assert.equal(caps?.temperature, false, id);
+ assert.equal(caps?.topP, false, id);
+ assert.equal(caps?.topK, false, id);
+ }
+ assert.equal(
+ getProviderCapabilities("custom", "chat_completions", "claude-opus-4-7")?.temperature,
+ true,
+ );
+});
+
// #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));