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.

Fix Claude 5 sampling and GPT-5.5 Pro Responses compatibility (#8372)

Lee Jacksoneebda056eae2
diff --git a/studio/backend/core/inference/external_provider.py b/studio/backend/core/inference/external_provider.py
index 6ce3dce5f31..019e157b901 100644
--- a/studio/backend/core/inference/external_provider.py
+++ b/studio/backend/core/inference/external_provider.py
@@ -45,10 +45,6 @@ _USAGE_STREAM_OPTION_PROVIDERS = frozenset({"vllm", "openrouter", "kimi"})
logger = structlog.get_logger(__name__)
-# Claude 4.7 (Opus/Sonnet/Haiku) removed temperature/top_p/top_k — the API
-# 400s "<param> is deprecated for this model" on a non-default value. 3.x and
-# 4.5/4.6 still accept them, so match the 4-7 line strictly. Ref:
-# https://platform.claude.com/docs/en/about-claude/models/whats-new-claude-4-7
def _is_openai_family_cloud(base_url: Optional[str]) -> bool:
"""True iff ``base_url`` points at OpenAI cloud or Azure OpenAI Foundry.
@@ -70,9 +66,71 @@ def _is_openai_family_cloud(base_url: Optional[str]) -> bool:
return host == "api.openai.com" or host.endswith(".openai.azure.com")
-_ANTHROPIC_4_7_SAMPLING_REMOVED = re.compile(r"^claude-(?:opus|sonnet|haiku)-4-7(?:[-.]|$)")
+# Claude Opus 4.7 and every Claude 5 family removed temperature/top_p/top_k;
+# Mythos Preview has the same restriction. The API 400s with "<param> is
+# deprecated for this model" on a non-default value. Ref:
+# https://platform.claude.com/docs/en/about-claude/model-deprecations
+# `[a-z]+` family (not `[a-z0-9]+`) so legacy version-first ids like
+# `claude-3-5-sonnet-...` don't parse as major=5. Minor accepts `-` or `.`, and
+# is capped at two digits so the release date in a snapshot id such as
+# `claude-opus-4-20250514` is not read as minor 20250514 (which would sort that
+# Opus 4.0 model above 4.7 and strip the caller's sampling params).
+_ANTHROPIC_MODEL_VERSION = re.compile(
+ r"^claude-(?P<family>[a-z]+)-(?P<major>\d+)(?:[-.](?P<minor>\d{1,2}))?(?:[-.]|$)",
+ re.IGNORECASE,
+)
_OPENAI_REASONING_SUMMARY_UNSUPPORTED = re.compile(r"^o3(?:[-.]|$)")
-_OPENAI_REASONING_STATUSES = {"in_progress", "completed", "incomplete"}
+# Gemini 3.x, dotted minor optional: gemini-3-, gemini-3.1-, gemini-3.6- ...
+_GEMINI3_FAMILY = re.compile(r"^gemini-3(?:\.\d+)?-")
+_GEMINI3_PRO = re.compile(r"^gemini-3(?:\.\d+)?-pro")
+
+
+def _anthropic_sampling_params_removed(model: str) -> bool:
+ """Whether Anthropic rejects non-default sampling params for ``model``."""
+ normalized = model.strip().lower()
+ if normalized == "claude-mythos-preview" or normalized.startswith("claude-mythos-preview-"):
+ return True
+
+ match = _ANTHROPIC_MODEL_VERSION.match(normalized)
+ if match is None:
+ return False
+
+ family = match.group("family")
+ version = (int(match.group("major")), int(match.group("minor") or 0))
+ return version[0] >= 5 or (family == "opus" and version >= (4, 7))
+
+
+def _openai_response_error_message(event: Any) -> str:
+ """Extract a useful message from a Responses failure event."""
+ if not isinstance(event, dict):
+ return "OpenAI response failed without error details."
+
+ response = event.get("response")
+ if not isinstance(response, dict):
+ response = {}
+ for candidate in (response.get("error"), event.get("error")):
+ if isinstance(candidate, str) and candidate.strip():
+ return candidate.strip()
+ if isinstance(candidate, dict):
+ message = candidate.get("message")
+ code = candidate.get("code") or candidate.get("type")
+ if isinstance(message, str) and message.strip():
+ return f"{message.strip()} ({code})" if code else message.strip()
+
+ message = event.get("message")
+ code = event.get("code")
+ if isinstance(message, str) and message.strip():
+ return f"{message.strip()} ({code})" if code else message.strip()
+
+ details = response.get("incomplete_details")
+ if isinstance(details, dict):
+ reason = details.get("reason") or details.get("message")
+ if isinstance(reason, str) and reason.strip():
+ return f"OpenAI response failed: {reason.strip()}"
+
+ response_id = response.get("id")
+ suffix = f" (response {response_id})" if isinstance(response_id, str) else ""
+ return f"OpenAI response failed without error details{suffix}."
def _openai_image_replay_requires_reasoning(model: str) -> bool:
@@ -104,15 +162,9 @@ def _sanitize_openai_reasoning_replay_item(item: Any) -> Optional[dict[str, Any]
text = part.get("text")
if isinstance(text, str):
summary_parts.append({"type": "summary_text", "text": text})
- replay_item: dict[str, Any] = {
- "type": "reasoning",
- "id": item_id,
- "summary": summary_parts,
- }
- status = item.get("status")
- if isinstance(status, str) and status in _OPENAI_REASONING_STATUSES:
- replay_item["status"] = status
- return replay_item
+ # `id` and `summary` only: Responses rejects `status` on an input item
+ # ("Unknown parameter: 'input[1].status'"), which 400d every replayed edit.
+ return {"type": "reasoning", "id": item_id, "summary": summary_parts}
# OpenAI Responses inline citation markers: `citeSOURCE_ID[id2...][LOCATOR]`
@@ -244,11 +296,28 @@ class _AnthropicThinkingSpec(NamedTuple):
prefixes: tuple[str, ...]
kind: Literal["adaptive", "manual"]
efforts: tuple[str, ...]
+ # Claude 5 thinks unless told otherwise, so "Thinking: off" must send an
+ # explicit disable. Fable/Mythos 5 400 on it (thinking is always on).
+ thinking_default_on: bool = False
+ can_disable: bool = True
_ANTHROPIC_THINKING_SPECS = (
_AnthropicThinkingSpec(
- prefixes = ("claude-opus-4-7",),
+ prefixes = ("claude-fable-5", "claude-mythos-5"),
+ kind = "adaptive",
+ efforts = ("none", "low", "medium", "high", "xhigh", "max"),
+ thinking_default_on = True,
+ can_disable = False,
+ ),
+ _AnthropicThinkingSpec(
+ prefixes = ("claude-opus-5", "claude-sonnet-5"),
+ kind = "adaptive",
+ efforts = ("none", "low", "medium", "high", "xhigh", "max"),
+ thinking_default_on = True,
+ ),
+ _AnthropicThinkingSpec(
+ prefixes = ("claude-opus-4-8", "claude-opus-4-7"),
kind = "adaptive",
efforts = ("none", "low", "medium", "high", "xhigh", "max"),
),
@@ -278,15 +347,19 @@ def _anthropic_thinking_spec(model: str) -> Optional[_AnthropicThinkingSpec]:
# filtering and free-with-search pricing. Pick the newest combo the model
# accepts, else the GA `_20250305`/`_20250910`/`_20250825` defaults. Ref:
# https://platform.claude.com/docs/en/agents-and-tools/tool-use/tool-reference
-_ANTHROPIC_NEW_WEB_PREFIXES = (
- "claude-opus-4-7",
- "claude-opus-4-6",
- "claude-sonnet-4-6",
+_ANTHROPIC_5_PREFIXES = (
+ "claude-opus-5",
+ "claude-sonnet-5",
+ "claude-fable-5",
+ "claude-mythos-5",
+ "claude-opus-4-8",
)
-_ANTHROPIC_NEW_CODE_EXEC_PREFIXES = (
+_ANTHROPIC_NEW_WEB_PREFIXES = _ANTHROPIC_5_PREFIXES + (
"claude-opus-4-7",
"claude-opus-4-6",
"claude-sonnet-4-6",
+)
+_ANTHROPIC_NEW_CODE_EXEC_PREFIXES = _ANTHROPIC_NEW_WEB_PREFIXES + (
"claude-opus-4-5",
"claude-sonnet-4-5",
)
@@ -323,10 +396,11 @@ _ANTHROPIC_CODE_EXECUTION_BETA = "code-execution-2025-08-25"
# Anthropic server-side context compaction (beta compact-2026-01-12), supported
-# on Opus 4.6/4.7, Sonnet 4.6 and Mythos Preview. Same beta header for all; the
-# dated `compact_20260112` type lives in body `context_management.edits`. Models
-# outside the prefix list are silently ignored so we don't 400 upstream.
-_ANTHROPIC_COMPACTION_PREFIXES = (
+# on Claude 5, Opus 4.6/4.7/4.8, Sonnet 4.6 and Mythos Preview. Same beta header
+# for all; the dated `compact_20260112` type lives in body
+# `context_management.edits`. Models outside the prefix list are silently
+# ignored so we don't 400 upstream.
+_ANTHROPIC_COMPACTION_PREFIXES = _ANTHROPIC_5_PREFIXES + (
"claude-opus-4-7",
"claude-opus-4-6",
"claude-sonnet-4-6",
@@ -339,13 +413,16 @@ _ANTHROPIC_COMPACTION_TYPE = "compact_20260112"
_ANTHROPIC_COMPACTION_MIN = 50_000
-# Anthropic fast-mode beta (Opus 4.6 / 4.7 only, per
+# Anthropic fast-mode beta (Opus 5 / Opus 4.8 only, per
# https://platform.claude.com/docs/en/build-with-claude/fast-mode).
+# Opus 4.7 400s on `speed`; Opus 4.6 accepts it but runs at standard speed and
+# reports `usage.speed: "standard"`, so exposing the toggle there promises a
+# speed-up that never happens. Sonnet 5 never had it.
# Mutually exclusive with the Priority service tier.
_ANTHROPIC_FAST_MODE_BETA = "fast-mode-2026-02-01"
_ANTHROPIC_FAST_MODE_PREFIXES = (
- "claude-opus-4-7",
- "claude-opus-4-6",
+ "claude-opus-5",
+ "claude-opus-4-8",
)
@@ -867,7 +944,7 @@ class ExternalProviderClient:
provider-capability map already filters these per provider, so they're
opt-in here.
- ``fast_mode`` only applies to Anthropic Opus 4.6 / 4.7 (silently
+ ``fast_mode`` only applies to Anthropic Opus 5 / Opus 4.8 (silently
dropped elsewhere); adds the beta header and ``speed: "fast"``.
"""
# tool_choice="none" hard-disables hosted/builtin tools across every
@@ -1951,10 +2028,10 @@ class ExternalProviderClient:
continue
filtered.append(msg)
- # Claude 4.7 removed temperature/top_p/top_k entirely (400 "deprecated
- # for this model"). Latch the match and reuse it wherever those are set,
- # including the thinking-mode override below that used to force temp=1.
- sampling_removed = bool(_ANTHROPIC_4_7_SAMPLING_REMOVED.match(model))
+ # Newer Claude models removed temperature/top_p/top_k entirely (400
+ # "deprecated for this model"). Reuse the capability wherever those
+ # fields are set, including the thinking-mode temperature override.
+ sampling_removed = _anthropic_sampling_params_removed(model)
body: dict[str, Any] = {
"model": model,
@@ -2027,8 +2104,18 @@ class ExternalProviderClient:
effort = "none"
elif enable_thinking is True:
effort = "medium"
+ # Models that think by default need an explicit disable; omitting the
+ # field leaves thinking on. Anthropic only accepts it at effort <= high,
+ # so send it alone (server default effort is high).
+ if (
+ effort == "none"
+ and thinking_spec
+ and thinking_spec.thinking_default_on
+ and thinking_spec.can_disable
+ ):
+ body["thinking"] = {"type": "disabled"}
# Normalize one semantic Thinking control into Anthropic's two model-era
- # APIs: adaptive effort on Claude 4.6/4.7, manual budget_tokens on 4.5.
+ # APIs: adaptive effort on Claude 4.6+, manual budget_tokens on 4.5.
if effort and effort != "none":
# Anthropic rejects top_k whenever thinking is enabled.
body.pop("top_k", None)
@@ -2150,7 +2237,7 @@ class ExternalProviderClient:
]
}
- # fast_mode is Opus 4.6/4.7 only; silently drop elsewhere. Incompatible
+ # fast_mode is Opus 5 / 4.8 only; silently drop elsewhere. Incompatible
# with the Priority service_tier (frontend gate prevents both at once;
# backend lets Anthropic 400 if combined).
fast_mode_active = bool(fast_mode) and _anthropic_supports_fast_mode(model)
@@ -3568,23 +3655,21 @@ class ExternalProviderClient:
# thinkingBudget (int). Gemini 3 has no full-off; minimum is
# "minimal" on Flash, "low" on Pro.
# https://ai.google.dev/gemini-api/docs/thinking
- _GEMINI3_THINKING_PREFIXES = (
- "gemini-3.5-",
- "gemini-3.1-",
- "gemini-3-",
+ # Match the 3.x family by pattern, not by enumerating minors: a new
+ # `gemini-3.6-*` would otherwise fall through to the 2.5 branch and get
+ # an int budget, which Gemini 3 rejects (400 on thinkingBudget=0).
+ _GEMINI3_ALIASES = (
"gemini-pro-latest",
"gemini-flash-latest",
"gemini-flash-lite-latest",
)
- _GEMINI3_PRO_PREFIXES = (
- "gemini-3.5-pro",
- "gemini-3.1-pro",
- "gemini-3-pro",
- "gemini-pro-latest",
- )
_PRO_THINKING_PREFIXES = ("gemini-2.5-pro",)
- is_gemini3_thinking = any(model_lc.startswith(p) for p in _GEMINI3_THINKING_PREFIXES)
- is_gemini3_pro = any(model_lc.startswith(p) for p in _GEMINI3_PRO_PREFIXES)
+ is_gemini3_thinking = bool(_GEMINI3_FAMILY.match(model_lc)) or model_lc.startswith(
+ _GEMINI3_ALIASES
+ )
+ is_gemini3_pro = bool(_GEMINI3_PRO.match(model_lc)) or model_lc.startswith(
+ "gemini-pro-latest"
+ )
_is_pro_thinking_only = any(
model_lc == p or model_lc.startswith(p + "-") for p in _PRO_THINKING_PREFIXES
)
@@ -3603,9 +3688,8 @@ class ExternalProviderClient:
level = "high"
elif effort_lc in _G3_LEVELS:
# Coerce legacy 3-Pro (low/high only) inputs.
- _is_legacy_gemini3_pro = model_lc.startswith(
- ("gemini-3-pro-preview", "gemini-3-pro")
- ) and not model_lc.startswith(("gemini-3.1-pro", "gemini-3.5-pro"))
+ # Undotted `gemini-3-pro` only; any dotted minor is 3.1+.
+ _is_legacy_gemini3_pro = model_lc.startswith("gemini-3-pro")
if is_gemini3_pro and effort_lc == "minimal":
level = "low"
elif _is_legacy_gemini3_pro and effort_lc == "medium":
@@ -5082,7 +5166,7 @@ class ExternalProviderClient:
yield _error_sse_line(response.status_code, error_text, self.provider_type)
return
- # NOTE: same manual __anext__ loop as stream_chat_completion —
+ # NOTE: same manual __anext__ loop as stream_chat_completion --
# see comment there for the GeneratorExit / aclose ordering.
lines_gen = response.aiter_lines().__aiter__()
done_emitted = False
@@ -5920,13 +6004,9 @@ class ExternalProviderClient:
elif event_type in ("response.failed", "error"):
# Surface the failure to the client; the outer
# route emits [DONE] as part of its cleanup.
- error_payload = event.get("response", {}).get("error", {}) or {
- "message": event.get("message", "Unknown error"),
- "code": event.get("code"),
- }
yield _error_sse_line(
502,
- _json.dumps(error_payload),
+ _openai_response_error_message(event),
self.provider_type,
)
break
@@ -6291,13 +6371,67 @@ def _friendly_provider_error_text(
return raw_message
+def _readable_provider_error(status_code: int, message: str, provider_type: str) -> str:
+ """Reduce an upstream error body to the sentence it carries.
+
+ OpenAI, Anthropic and Gemini all nest the text under `error`, so the raw
+ body would otherwise reach the UI as a JSON blob. Non-JSON input (already
+ friendly text) passes through unchanged.
+ """
+ import json
+
+ try:
+ payload = json.loads(message)
+ except (json.JSONDecodeError, TypeError, ValueError):
+ payload = None
+
+ text = code = None
+ if isinstance(payload, dict):
+ error = payload.get("error")
+ source = error if isinstance(error, dict) else payload
+ text = error if isinstance(error, str) else source.get("message")
+ # Gemini sends an int `code`; prefer whichever label is a string.
+ code = next(
+ (
+ c
+ for c in (source.get("code"), source.get("type"), source.get("status"))
+ if isinstance(c, str) and c
+ ),
+ None,
+ )
+ if not isinstance(text, str) or not text.strip():
+ # FastAPI-style bodies (vllm, llama.cpp, custom OpenAI-compat) carry
+ # `detail`: a string, or a validation list of `{msg, loc}` entries.
+ detail = payload.get("detail")
+ if isinstance(detail, str):
+ text = detail
+ elif isinstance(detail, list):
+ msgs = [
+ d["msg"]
+ for d in detail
+ if isinstance(d, dict) and isinstance(d.get("msg"), str)
+ ]
+ text = "; ".join(msgs) or None
+
+ if not isinstance(text, str) or not text.strip():
+ # Not JSON means already-friendly text: collapse whitespace and cap so
+ # a stray HTML page can't flood the chat.
+ raw = " ".join(message.split())[:500] if isinstance(message, str) else ""
+ if isinstance(payload, dict) or not raw:
+ return f"{provider_type} returned HTTP {status_code} with no error details."
+ return raw
+
+ text = text.strip()
+ return f"{text} ({code})" if code and code not in text else text
+
+
def _error_sse_line(status_code: int, message: str, provider_type: str) -> str:
"""Format an error as an SSE data line in OpenAI error format."""
import json
error_obj = {
"error": {
- "message": message,
+ "message": _readable_provider_error(status_code, message, provider_type),
"type": "provider_error",
"code": str(status_code),
"provider": provider_type,
diff --git a/studio/backend/core/inference/pricing.py b/studio/backend/core/inference/pricing.py
index 30fec47723c..ea568b6ea1a 100644
--- a/studio/backend/core/inference/pricing.py
+++ b/studio/backend/core/inference/pricing.py
@@ -9,11 +9,18 @@ read 0.1x), web search ($10/1000), code execution; OpenAI pricing page.
from __future__ import annotations
+import datetime as _dt
from typing import Any, Optional
# Per-MTok base USD. Cache multipliers apply to `input_per_mtok`
# (not absolute prices), per Anthropic docs.
ANTHROPIC_PRICING: dict[str, dict[str, float]] = {
+ "claude-fable-5": {"input_per_mtok": 10.0, "output_per_mtok": 50.0},
+ "claude-mythos-5": {"input_per_mtok": 10.0, "output_per_mtok": 50.0},
+ "claude-opus-5": {"input_per_mtok": 5.0, "output_per_mtok": 25.0},
+ # Standard rate; the launch rate below applies until 2026-09-01.
+ "claude-sonnet-5": {"input_per_mtok": 3.0, "output_per_mtok": 15.0},
+ "claude-opus-4-8": {"input_per_mtok": 5.0, "output_per_mtok": 25.0},
"claude-opus-4-7": {"input_per_mtok": 5.0, "output_per_mtok": 25.0},
"claude-opus-4-6": {"input_per_mtok": 5.0, "output_per_mtok": 25.0},
# Alias bare + dated id: backend defaults use the bare form, which
@@ -33,8 +40,29 @@ ANTHROPIC_PRICING: dict[str, dict[str, float]] = {
OPENAI_PRICING: dict[str, dict[str, float]] = {
# Verified against developers.openai.com/api/docs/pricing.
- # `long_context_*` keys apply past the threshold (gpt-5.5/5.4: 272k);
+ # `long_context_*` keys apply past the threshold (gpt-5.6/5.5/5.4: 272k);
# families without them ship a single rate.
+ "gpt-5.6-sol": {
+ "input_per_mtok": 5.0,
+ "output_per_mtok": 30.0,
+ "long_context_threshold": 272_000,
+ "long_context_input_per_mtok": 10.0,
+ "long_context_output_per_mtok": 45.0,
+ },
+ "gpt-5.6-terra": {
+ "input_per_mtok": 2.0,
+ "output_per_mtok": 12.0,
+ "long_context_threshold": 272_000,
+ "long_context_input_per_mtok": 4.0,
+ "long_context_output_per_mtok": 18.0,
+ },
+ "gpt-5.6-luna": {
+ "input_per_mtok": 0.20,
+ "output_per_mtok": 1.20,
+ "long_context_threshold": 272_000,
+ "long_context_input_per_mtok": 0.40,
+ "long_context_output_per_mtok": 1.80,
+ },
"gpt-5.5": {
"input_per_mtok": 5.0,
"output_per_mtok": 30.0,
@@ -65,9 +93,16 @@ OPENAI_PRICING: dict[str, dict[str, float]] = {
ANTHROPIC_CACHE_5M_WRITE_MULT = 1.25
ANTHROPIC_CACHE_1H_WRITE_MULT = 2.0
ANTHROPIC_CACHE_READ_MULT = 0.1
-# Anthropic fast-mode (Opus 4.6/4.7 only): 6x on input + output.
+# Anthropic fast-mode is Opus 5 / Opus 4.8 only, both at $10/$50 per MTok
+# against a $5/$25 base, i.e. 2x on input + output. Opus 4.6 accepts `speed`
+# but reports `usage.speed: "standard"` and bills standard rates, so it never
+# reaches this multiplier.
# https://platform.claude.com/docs/en/build-with-claude/fast-mode#pricing
-ANTHROPIC_FAST_MODE_MULT = 6.0
+ANTHROPIC_FAST_MODE_MULT = 2.0
+ANTHROPIC_FAST_MODE_MULT_BY_MODEL = {
+ "claude-opus-5": 2.0,
+ "claude-opus-4-8": 2.0,
+}
# OpenAI: cache reads 0.1x; cache writes pay input price.
OPENAI_CACHE_READ_MULT = 0.1
@@ -83,6 +118,37 @@ OPENAI_WEB_SEARCH_USD_PER_1K = 10.0
OPENAI_CONTAINER_USD_PER_HOUR = 0.09 # 1g default tier
+# Claude Sonnet 5 launched on introductory pricing of $2/$10 per MTok, in force
+# through 2026-08-31; ANTHROPIC_PRICING carries the standard $3/$15 that takes
+# over on 2026-09-01. Billing the standard rate early overstates every Sonnet 5
+# turn by 50%, so overlay the launch rate while it lasts. The entry expires on
+# its own and can be deleted after the cutover.
+# https://platform.claude.com/docs/en/about-claude/pricing
+_LAUNCH_PRICING: dict[str, tuple[_dt.date, dict[str, float]]] = {
+ "claude-sonnet-5": (
+ _dt.date(2026, 9, 1),
+ {"input_per_mtok": 2.0, "output_per_mtok": 10.0},
+ ),
+}
+
+
+def _launch_prices(
+ provider: str,
+ model: str,
+ prices: dict[str, float],
+ today: Optional[_dt.date] = None,
+) -> dict[str, float]:
+ """Overlay a still-running launch rate onto a standard-rate table row."""
+ if provider != "anthropic":
+ return prices
+ for key, (ends, launch) in _LAUNCH_PRICING.items():
+ if model != key and not model.startswith(f"{key}-"):
+ continue
+ if (today or _dt.date.today()) < ends:
+ return {**prices, **launch}
+ return prices
+
+
def _lookup(provider: str, model: str) -> Optional[dict[str, float]]:
table = (
ANTHROPIC_PRICING
@@ -109,6 +175,8 @@ def calculate_cost(provider: str, model: str, usage: dict[str, Any]) -> dict[str
Unknown model -> ``priced`` False and USD fields 0.0 (token counts still report).
"""
prices = _lookup(provider, model)
+ if prices:
+ prices = _launch_prices(provider, model, prices)
out: dict[str, float] = {
"input_usd": 0.0,
"output_usd": 0.0,
@@ -192,12 +260,16 @@ def calculate_cost(provider: str, model: str, usage: dict[str, Any]) -> dict[str
base = prices["input_per_mtok"]
out_per = prices["output_per_mtok"]
- # Anthropic fast-mode: 6x on input + output. Cache multipliers stack
+ # Anthropic fast-mode multiplier on input + output. Cache multipliers stack
# on top, so applying once to (base, out_per) flows into the
# cache_*_usd buckets below.
if provider == "anthropic" and usage.get("speed") == "fast":
- base *= ANTHROPIC_FAST_MODE_MULT
- out_per *= ANTHROPIC_FAST_MODE_MULT
+ fast_mult = next(
+ (m for k, m in ANTHROPIC_FAST_MODE_MULT_BY_MODEL.items() if model.startswith(k)),
+ ANTHROPIC_FAST_MODE_MULT,
+ )
+ base *= fast_mult
+ out_per *= fast_mult
if out["model_priced"]:
out["model_priced"] = f"{out['model_priced']} (fast)"
@@ -261,7 +333,12 @@ def pricing_snapshot() -> dict[str, Any]:
"""Whole pricing table for the /api/providers/pricing endpoint."""
return {
"anthropic": {
- "models": dict(ANTHROPIC_PRICING),
+ # Same launch-rate overlay calculate_cost bills on, so the
+ # /api/providers/pricing table matches the ledger.
+ "models": {
+ model: _launch_prices("anthropic", model, prices)
+ for model, prices in ANTHROPIC_PRICING.items()
+ },
"cache_5m_write_mult": ANTHROPIC_CACHE_5M_WRITE_MULT,
"cache_1h_write_mult": ANTHROPIC_CACHE_1H_WRITE_MULT,
"cache_read_mult": ANTHROPIC_CACHE_READ_MULT,
diff --git a/studio/backend/core/inference/providers.py b/studio/backend/core/inference/providers.py
index d3bffc2f3db..8a2e1029f98 100644
--- a/studio/backend/core/inference/providers.py
+++ b/studio/backend/core/inference/providers.py
@@ -16,6 +16,9 @@ PROVIDER_REGISTRY: dict[str, dict[str, Any]] = {
"display_name": "OpenAI",
"base_url": "https://api.openai.com/v1",
"default_models": [
+ "gpt-5.6-sol",
+ "gpt-5.6-terra",
+ "gpt-5.6-luna",
"gpt-5.5",
"gpt-5.4",
"gpt-5.4-mini",
@@ -28,7 +31,7 @@ PROVIDER_REGISTRY: dict[str, dict[str, Any]] = {
"auth_prefix": "Bearer ",
# Scope the picker to the current generation. /v1/models returns many
# historical snapshots, fine-tunes, and non-chat models we don't want.
- "model_id_allowlist": re.compile(r"^(gpt-5\.[345]|gpt-4\.5|o3)(?:[-.]|$)"),
+ "model_id_allowlist": re.compile(r"^(gpt-5\.[3456]|gpt-4\.5|o3)(?:[-.]|$)"),
# Hide dated snapshots and the retired plain gpt-5.3 id.
"model_id_denylist": re.compile(r"^(gpt-5\.3)$|-\d{4}-\d{2}-\d{2}$"),
},
@@ -36,6 +39,10 @@ PROVIDER_REGISTRY: dict[str, dict[str, Any]] = {
"display_name": "Anthropic",
"base_url": "https://api.anthropic.com/v1",
"default_models": [
+ "claude-opus-5",
+ "claude-sonnet-5",
+ "claude-fable-5",
+ "claude-opus-4-8",
"claude-opus-4-7",
"claude-opus-4-6",
"claude-sonnet-4-6",
@@ -69,7 +76,9 @@ PROVIDER_REGISTRY: dict[str, dict[str, Any]] = {
# `gemini-3.1-pro-preview`, so we surface 3.1 directly).
"default_models": [
"gemini-3.1-pro-preview",
+ "gemini-3.6-flash",
"gemini-3.5-flash",
+ "gemini-3.5-flash-lite",
"gemini-3.1-flash-lite",
"gemini-3-flash-preview",
"gemini-pro-latest",
@@ -97,17 +106,19 @@ PROVIDER_REGISTRY: dict[str, dict[str, Any]] = {
# gemini-3-pro-preview was shut down 2026-03-09 and auto-aliased to
# gemini-3.1-pro-preview; drop it so users see one canonical card.
"model_id_deny_exact": ("gemini-3-pro-preview",),
- # Chat-capable 3.5 / 3.1 / 3 / 2.5 families plus rolling *-latest
+ # Chat-capable 3.6 / 3.5 / 3.1 / 3 / 2.5 families plus rolling *-latest
# aliases. Image-tier ids flow through the Nano Banana
# `responseModalities` path in `_stream_gemini`. Retired 2.0 ids
- # excluded (they 404 on use).
+ # excluded (they 404 on use). `-preview` is optional on the image ids
+ # so a GA rollover does not drop them from the picker.
"model_id_allowlist": re.compile(
r"^("
- r"gemini-3\.5-(?:flash|pro)(?:-preview)?|"
+ r"gemini-3\.6-(?:flash|pro)(?:-preview)?|"
+ r"gemini-3\.5-(?:flash|pro|flash-lite)(?:-preview)?|"
r"gemini-3\.1-(?:flash|pro|flash-lite)(?:-preview)?(?:-customtools)?|"
- r"gemini-3\.1-flash-image-preview|"
+ r"gemini-3\.1-flash-image(?:-preview)?|"
r"gemini-3-(?:flash|pro)(?:-preview)?|"
- r"gemini-3-pro-image-preview|"
+ r"gemini-3-pro-image(?:-preview)?|"
r"nano-banana-pro-preview|"
r"gemini-2\.5-pro|gemini-2\.5-flash|gemini-2\.5-flash-lite|"
r"gemini-2\.5-flash-image|"
diff --git a/studio/backend/tests/test_anthropic_fast_mode_and_refusal.py b/studio/backend/tests/test_anthropic_fast_mode_and_refusal.py
index da0c0941ca7..28b741ad29c 100644
--- a/studio/backend/tests/test_anthropic_fast_mode_and_refusal.py
+++ b/studio/backend/tests/test_anthropic_fast_mode_and_refusal.py
@@ -102,17 +102,25 @@ def _capture(
return captured, out_lines
-def test_fast_mode_attaches_beta_header_and_speed_on_opus_4_7(monkeypatch):
- cap, _ = _capture(monkeypatch, fast_mode = True, model = "claude-opus-4-7")
+def test_fast_mode_attaches_beta_header_and_speed_on_opus_5(monkeypatch):
+ cap, _ = _capture(monkeypatch, fast_mode = True, model = "claude-opus-5")
assert cap["body"].get("speed") == "fast", cap["body"]
beta = cap["headers"].get("anthropic-beta", "")
assert "fast-mode-2026-02-01" in beta, beta
-def test_fast_mode_attaches_beta_header_and_speed_on_opus_4_6(monkeypatch):
+def test_fast_mode_dropped_on_opus_4_7(monkeypatch):
+ """4.7 dropped fast mode upstream and 400s on `speed`."""
+ cap, _ = _capture(monkeypatch, fast_mode = True, model = "claude-opus-4-7")
+ assert "speed" not in cap["body"], cap["body"]
+
+
+def test_fast_mode_dropped_on_opus_4_6(monkeypatch):
+ """4.6 accepts `speed` but answers at standard speed and standard rates,
+ so the toggle would promise a speed-up that never arrives."""
cap, _ = _capture(monkeypatch, fast_mode = True, model = "claude-opus-4-6")
- assert cap["body"].get("speed") == "fast", cap["body"]
- assert "fast-mode-2026-02-01" in cap["headers"].get("anthropic-beta", "")
+ assert "speed" not in cap["body"], cap["body"]
+ assert "fast-mode-2026-02-01" not in cap["headers"].get("anthropic-beta", "")
def test_fast_mode_dropped_on_sonnet(monkeypatch):
diff --git a/studio/backend/tests/test_anthropic_fast_mode_edge.py b/studio/backend/tests/test_anthropic_fast_mode_edge.py
index 03f5d1c0eb2..9a0b8cd3c4f 100644
--- a/studio/backend/tests/test_anthropic_fast_mode_edge.py
+++ b/studio/backend/tests/test_anthropic_fast_mode_edge.py
@@ -113,33 +113,45 @@ def _capture(
# ──────────────────────────── dated snapshot prefix ────────────────────────────
-def test_fast_mode_attaches_on_dated_opus_4_7_snapshot(monkeypatch):
- """Dated snapshot ``claude-opus-4-7-2026-02-01`` must match the prefix."""
- cap, _ = _capture(monkeypatch, fast_mode = True, model = "claude-opus-4-7-2026-02-01")
+def test_fast_mode_attaches_on_dated_opus_4_8_snapshot(monkeypatch):
+ """Dated snapshot ``claude-opus-4-8-2026-02-01`` must match the prefix."""
+ cap, _ = _capture(monkeypatch, fast_mode = True, model = "claude-opus-4-8-2026-02-01")
assert cap["body"].get("speed") == "fast", cap["body"]
assert "fast-mode-2026-02-01" in cap["headers"].get("anthropic-beta", "")
-def test_fast_mode_attaches_on_dated_opus_4_6_snapshot(monkeypatch):
+def test_fast_mode_dropped_on_dated_opus_4_6_snapshot(monkeypatch):
+ """4.6 accepts `speed` but runs at standard speed, so we never send it."""
cap, _ = _capture(monkeypatch, fast_mode = True, model = "claude-opus-4-6-2026-02-01")
- assert cap["body"].get("speed") == "fast", cap["body"]
- assert "fast-mode-2026-02-01" in cap["headers"].get("anthropic-beta", "")
+ assert "speed" not in cap["body"], cap["body"]
+ assert "fast-mode-2026-02-01" not in cap["headers"].get("anthropic-beta", "")
# ──────────────────────────── strict opt-in semantics ────────────────────────────
-def test_fast_mode_does_not_auto_enable_on_future_opus_4_8(monkeypatch):
- """Future ``claude-opus-4-8`` must not auto-enable; per-family opt-in."""
+def test_fast_mode_attaches_on_opus_4_8(monkeypatch):
cap, _ = _capture(monkeypatch, fast_mode = True, model = "claude-opus-4-8")
- assert "speed" not in cap["body"], cap["body"]
- assert "fast-mode-2026-02-01" not in cap["headers"].get("anthropic-beta", "")
+ assert cap["body"].get("speed") == "fast", cap["body"]
+ assert "fast-mode-2026-02-01" in cap["headers"].get("anthropic-beta", "")
-def test_fast_mode_does_not_auto_enable_on_future_opus_5(monkeypatch):
+def test_fast_mode_attaches_on_opus_5(monkeypatch):
cap, _ = _capture(monkeypatch, fast_mode = True, model = "claude-opus-5")
+ assert cap["body"].get("speed") == "fast", cap["body"]
+ assert "fast-mode-2026-02-01" in cap["headers"].get("anthropic-beta", "")
+
+
+def test_fast_mode_dropped_on_opus_4_7(monkeypatch):
+ """4.7 dropped fast mode upstream; sending `speed` 400s."""
+ cap, _ = _capture(monkeypatch, fast_mode = True, model = "claude-opus-4-7")
assert "speed" not in cap["body"], cap["body"]
assert "fast-mode-2026-02-01" not in cap["headers"].get("anthropic-beta", "")
+def test_fast_mode_dropped_on_sonnet_5(monkeypatch):
+ cap, _ = _capture(monkeypatch, fast_mode = True, model = "claude-sonnet-5")
+ assert "speed" not in cap["body"], cap["body"]
+
+
def test_fast_mode_does_not_auto_enable_on_sonnet_dated_snapshot(monkeypatch):
"""Sonnet snapshots share the compaction prefix but not fast_mode."""
cap, _ = _capture(monkeypatch, fast_mode = True, model = "claude-sonnet-4-6-2026-02-01")
@@ -158,7 +170,7 @@ def test_fast_mode_merges_with_code_execution_beta(monkeypatch):
cap, _ = _capture(
monkeypatch,
fast_mode = True,
- model = "claude-opus-4-7",
+ model = "claude-opus-4-8",
enabled_tools = ["code_execution"],
)
parts = _beta_parts(cap["headers"])
@@ -173,7 +185,7 @@ def test_fast_mode_merges_with_compaction_beta(monkeypatch):
cap, _ = _capture(
monkeypatch,
fast_mode = True,
- model = "claude-opus-4-7",
+ model = "claude-opus-4-8",
compaction_threshold = 100_000,
)
parts = _beta_parts(cap["headers"])
@@ -186,7 +198,7 @@ def test_fast_mode_merges_with_code_execution_and_compaction(monkeypatch):
cap, _ = _capture(
monkeypatch,
fast_mode = True,
- model = "claude-opus-4-7",
+ model = "claude-opus-4-8",
enabled_tools = ["code_execution"],
compaction_threshold = 100_000,
)
@@ -200,7 +212,7 @@ def test_fast_mode_merges_with_code_execution_and_compaction(monkeypatch):
def test_fast_mode_beta_value_is_pinned(monkeypatch):
"""Pin the exact beta tag ``fast-mode-2026-02-01`` from the docs."""
- cap, _ = _capture(monkeypatch, fast_mode = True, model = "claude-opus-4-7")
+ cap, _ = _capture(monkeypatch, fast_mode = True, model = "claude-opus-4-8")
parts = _beta_parts(cap["headers"])
assert "fast-mode-2026-02-01" in parts, parts
# Reject obvious typos.
@@ -352,14 +364,14 @@ def test_fast_mode_prefix_tuple_matches_capability_doc(monkeypatch):
https://platform.claude.com/docs/en/build-with-claude/fast-mode."""
from core.inference.external_provider import _ANTHROPIC_FAST_MODE_PREFIXES
assert set(_ANTHROPIC_FAST_MODE_PREFIXES) == {
- "claude-opus-4-7",
- "claude-opus-4-6",
+ "claude-opus-5",
+ "claude-opus-4-8",
}, _ANTHROPIC_FAST_MODE_PREFIXES
def test_fast_mode_speed_field_value_is_literal_fast(monkeypatch):
"""Pin the wire value to the literal string ``"fast"``."""
- cap, _ = _capture(monkeypatch, fast_mode = True, model = "claude-opus-4-7")
+ cap, _ = _capture(monkeypatch, fast_mode = True, model = "claude-opus-4-8")
assert cap["body"]["speed"] == "fast", cap["body"]
diff --git a/studio/backend/tests/test_anthropic_thinking_translation.py b/studio/backend/tests/test_anthropic_thinking_translation.py
index 02c48937358..221be85d627 100644
--- a/studio/backend/tests/test_anthropic_thinking_translation.py
+++ b/studio/backend/tests/test_anthropic_thinking_translation.py
@@ -17,6 +17,7 @@ import asyncio
import json
import httpx
+import pytest
from core.inference import external_provider as ep_mod
from core.inference.external_provider import ExternalProviderClient
@@ -115,6 +116,59 @@ def test_adaptive_thinking_body_uses_output_config_effort_shape(monkeypatch):
assert "top_k" not in body
+ ("model", "sampling_removed"),
+ (
+ ("claude-opus-4-7", True),
+ ("claude-opus-4-8", True),
+ ("claude-opus-5", True),
+ ("claude-sonnet-5", True),
+ ("claude-fable-5", True),
+ ("claude-mythos-5", True),
+ ("claude-mythos-preview", True),
+ ("claude-opus-4-6", False),
+ ("claude-sonnet-4-6", False),
+ ("claude-haiku-4-5-20251001", False),
+ ),
+)
+def test_sampling_parameter_capability_detection(model, sampling_removed):
+ assert ep_mod._anthropic_sampling_params_removed(model) is sampling_removed
+
+
+def test_claude_opus_5_request_omits_removed_sampling_parameters(monkeypatch):
+ captured: dict = {}
+
+ def handler(request: httpx.Request) -> httpx.Response:
+ captured["body"] = json.loads(request.content.decode("utf-8"))
+ return httpx.Response(
+ 200,
+ content = _anthropic_sse([{"type": "message_stop"}]),
+ headers = {"content-type": "text/event-stream"},
+ )
+
+ _mock_http_client(monkeypatch, handler)
+
+ async def run():
+ client = _make_client()
+ async for _ in client._stream_anthropic(
+ messages = [{"role": "user", "content": "hi"}],
+ model = "claude-opus-5",
+ temperature = 0.7,
+ top_p = 0.95,
+ max_tokens = 1024,
+ top_k = 40,
+ enable_thinking = False,
+ ):
+ pass
+ await client.close()
+
+ _drive(run())
+
+ body = captured["body"]
+ assert "temperature" not in body
+ assert "top_k" not in body
+
+
def test_adaptive_thinking_maps_xhigh_to_max_on_claude_4_6(monkeypatch):
captured: dict = {}
@@ -393,3 +447,106 @@ def test_thinking_only_turn_closes_tag_without_text_delta(monkeypatch):
if isinstance(p, dict) and p["choices"][0]["delta"]
)
assert combined == "<think>internal</think>"
+
+
+def _capture_body(monkeypatch, **kwargs) -> dict:
+ """Drive one streamed call and return the outbound Anthropic body."""
+ captured: dict = {}
+
+ def handler(request: httpx.Request) -> httpx.Response:
+ captured["body"] = json.loads(request.content.decode("utf-8"))
+ return httpx.Response(
+ 200,
+ content = _anthropic_sse([{"type": "message_stop"}]),
+ headers = {"content-type": "text/event-stream"},
+ )
+
+ _mock_http_client(monkeypatch, handler)
+
+ async def run():
+ client = _make_client()
+ async for _ in client.stream_chat_completion(
+ messages = [{"role": "user", "content": "hi"}],
+ temperature = 0.7,
+ top_p = 0.95,
+ max_tokens = 64,
+ **kwargs,
+ ):
+ pass
+ await client.close()
+
+ _drive(run())
+ return captured["body"]
+
+
+ "model",
+ ("claude-opus-5", "claude-sonnet-5", "claude-fable-5", "claude-opus-4-8"),
+)
+def test_claude_5_uses_adaptive_thinking_and_effort(monkeypatch, model):
+ """Claude 5 / Opus 4.8 must get adaptive thinking, not a bare request."""
+ body = _capture_body(
+ monkeypatch,
+ model = model,
+ enable_thinking = True,
+ reasoning_effort = "xhigh",
+ )
+ assert body["thinking"] == {"type": "adaptive", "display": "summarized"}
+ assert body["output_config"] == {"effort": "xhigh"}
+
+
+def test_thinking_off_disables_explicitly_on_opus_5(monkeypatch):
+ """Opus 5 thinks by default, so "off" must send an explicit disable."""
+ body = _capture_body(monkeypatch, model = "claude-opus-5", enable_thinking = False)
+ assert body["thinking"] == {"type": "disabled"}
+ assert "output_config" not in body
+
+
+def test_thinking_off_omits_disable_on_fable_5(monkeypatch):
+ """Fable 5 thinking is always on and 400s on an explicit disable."""
+ body = _capture_body(monkeypatch, model = "claude-fable-5", enable_thinking = False)
+ assert "thinking" not in body
+
+
+ ("model", "web", "code", "compaction", "fast"),
+ (
+ ("claude-opus-5", "web_search_20260209", "code_execution_20260120", True, True),
+ ("claude-sonnet-5", "web_search_20260209", "code_execution_20260120", True, False),
+ ("claude-opus-4-8", "web_search_20260209", "code_execution_20260120", True, True),
+ # 4.7 keeps the new tool versions but dropped fast mode upstream.
+ ("claude-opus-4-7", "web_search_20260209", "code_execution_20260120", True, False),
+ ("claude-opus-4-5", "web_search_20250305", "code_execution_20260120", False, False),
+ ),
+)
+def test_model_capability_tables_cover_claude_5(model, web, code, compaction, fast):
+ assert ep_mod._anthropic_web_search_version(model) == web
+ assert ep_mod._anthropic_code_execution_version(model) == code
+ assert ep_mod._anthropic_supports_compaction(model) is compaction
+ assert ep_mod._anthropic_supports_fast_mode(model) is fast
+
+
+ ("model", "sampling_removed"),
+ (
+ # Dotted minor versions and legacy version-first ids.
+ ("claude-opus-4.8", True),
+ ("claude-opus-4.7", True),
+ ("claude-sonnet-4.6", False),
+ ("claude-3-5-sonnet-20241022", False),
+ ("claude-3-7-sonnet-20250219", False),
+ # A snapshot date is not a minor version: claude-opus-4-20250514 is
+ # Opus 4.0, three generations before sampling params were removed, and
+ # reading 20250514 as the minor sorted it above 4.7 and silently
+ # dropped the caller's temperature / top_k.
+ ("claude-opus-4-20250514", False),
+ ("claude-opus-4", False),
+ ("claude-opus-4-1-20250805", False),
+ ("claude-opus-5-20260724", True),
+ ("claude-opus-4-7-20260414", True),
+ # Two-digit minors still parse.
+ ("claude-opus-4-10", True),
+ ),
+)
+def test_sampling_capability_handles_alternate_id_spellings(model, sampling_removed):
+ assert ep_mod._anthropic_sampling_params_removed(model) is sampling_removed
diff --git a/studio/backend/tests/test_gemini_provider.py b/studio/backend/tests/test_gemini_provider.py
index c6ffa798d0b..be409b02db5 100644
--- a/studio/backend/tests/test_gemini_provider.py
+++ b/studio/backend/tests/test_gemini_provider.py
@@ -5351,3 +5351,37 @@ def test_openrouter_no_synthetic_web_search_event_on_forced_function_tool_choice
tool_event = extra.get("toolEvent") if isinstance(extra, dict) else None
if isinstance(tool_event, dict):
assert tool_event.get("tool_name") != "web_search", evt
+
+
+ "model",
+ (
+ "gemini-3.6-flash",
+ "gemini-3.5-flash",
+ "gemini-3.1-flash-lite",
+ "gemini-3-flash-preview",
+ "gemini-pro-latest",
+ ),
+)
+def test_gemini_3_family_uses_thinking_level(monkeypatch, model):
+ """Any 3.x minor must take thinkingLevel; an int budget 400s upstream."""
+ body = _capture_body(monkeypatch, model = model, enable_thinking = False)["body"]
+ thinking = body["generationConfig"]["thinkingConfig"]
+ assert "thinkingLevel" in thinking, (model, thinking)
+ assert "thinkingBudget" not in thinking, (model, thinking)
+
+
[email protected]("model", ("gemini-2.5-flash", "gemini-2.5-pro"))
+def test_gemini_2_5_still_uses_thinking_budget(monkeypatch, model):
+ body = _capture_body(monkeypatch, model = model, enable_thinking = False)["body"]
+ assert "thinkingBudget" in body["generationConfig"]["thinkingConfig"]
+
+
+def test_gemini_3_pro_floor_is_low_not_minimal(monkeypatch):
+ """Pro has no `minimal` level, so thinking off floors at `low`."""
+ body = _capture_body(
+ monkeypatch,
+ model = "gemini-3.1-pro-preview",
+ enable_thinking = False,
+ )["body"]
+ assert body["generationConfig"]["thinkingConfig"] == {"thinkingLevel": "low"}
diff --git a/studio/backend/tests/test_openai_image_generation.py b/studio/backend/tests/test_openai_image_generation.py
index c2eef0381fa..1b2e6d54ba5 100644
--- a/studio/backend/tests/test_openai_image_generation.py
+++ b/studio/backend/tests/test_openai_image_generation.py
@@ -213,3 +213,90 @@ def test_image_generation_done_emits_tool_event_chunks(monkeypatch):
assert ends[0]["size"] == "1024x1024"
assert ends[0]["quality"] == "high"
assert ends[0]["background"] == "opaque"
+
+
+# ── replayed reasoning item stays input-safe ────────────────────────
+
+
+def test_reasoning_replay_item_drops_status():
+ """Responses 400s with "Unknown parameter: 'input[1].status'" when an input
+ reasoning item carries `status`, which broke every replayed image edit."""
+ replay = ep_mod._sanitize_openai_reasoning_replay_item(
+ {
+ "type": "reasoning",
+ "id": "rs_abc",
+ "status": "completed",
+ "summary": [{"type": "summary_text", "text": "thinking"}],
+ "encrypted_content": "secret",
+ }
+ )
+ assert replay == {
+ "type": "reasoning",
+ "id": "rs_abc",
+ "summary": [{"type": "summary_text", "text": "thinking"}],
+ }
+
+
+def test_replayed_image_edit_body_has_no_status_field(monkeypatch):
+ """End to end: a stored turn with reasoning + image_generation_call must
+ reach the wire without `status` on the reasoning item."""
+ captured: dict = {}
+
+ def handler(request: httpx.Request) -> httpx.Response:
+ captured["body"] = json.loads(request.content.decode())
+ return httpx.Response(
+ 200,
+ content = (
+ b"event: response.completed\n"
+ b'data: {"type":"response.completed",'
+ b'"response":{"output":[],"usage":{"input_tokens":0,"output_tokens":0}}}\n\n'
+ ),
+ headers = {"content-type": "text/event-stream"},
+ )
+
+ monkeypatch.setattr(
+ ep_mod,
+ "_http_client",
+ httpx.AsyncClient(transport = httpx.MockTransport(handler)),
+ )
+
+ async def run():
+ client = ExternalProviderClient(
+ provider_type = "openai",
+ base_url = "https://api.openai.com/v1",
+ api_key = "sk-test",
+ )
+ async for _ in client.stream_chat_completion(
+ messages = [
+ {"role": "user", "content": "draw a cat"},
+ {
+ "role": "assistant",
+ "content": [
+ {
+ "type": "reasoning",
+ "id": "rs_abc",
+ "status": "completed",
+ "summary": [],
+ },
+ {"type": "image_generation_call", "id": "ig_abc"},
+ ],
+ },
+ {"role": "user", "content": "make it blue"},
+ ],
+ model = "gpt-5.5",
+ max_tokens = 32,
+ reasoning_effort = "medium",
+ enabled_tools = ["image_generation"],
+ ):
+ pass
+ await client.close()
+
+ _drive(run())
+ items = captured["body"]["input"]
+ reasoning = [i for i in items if isinstance(i, dict) and i.get("type") == "reasoning"]
+ assert reasoning, items
+ assert "status" not in reasoning[0], reasoning[0]
+ # The paired call must survive, else the edit loses its reference.
+ assert any(
+ i.get("type") == "image_generation_call" for i in items if isinstance(i, dict)
+ ), items
diff --git a/studio/backend/tests/test_openai_responses_translation.py b/studio/backend/tests/test_openai_responses_translation.py
index f7d7e83a43c..89d3409838a 100644
--- a/studio/backend/tests/test_openai_responses_translation.py
+++ b/studio/backend/tests/test_openai_responses_translation.py
@@ -20,6 +20,7 @@ import asyncio
import json
import httpx
+import pytest
from core.inference import external_provider as ep_mod
from core.inference.external_provider import ExternalProviderClient
@@ -112,6 +113,50 @@ def test_responses_request_body_uses_input_and_instructions(monkeypatch):
assert "messages" not in body
+def test_responses_failed_without_details_has_actionable_fallback(monkeypatch):
+ def handler(request: httpx.Request) -> httpx.Response:
+ return httpx.Response(
+ 200,
+ content = _responses_sse(
+ [
+ {
+ "type": "response.failed",
+ "response": {
+ "id": "resp_failed_123",
+ "status": "failed",
+ "error": None,
+ },
+ }
+ ]
+ ),
+ headers = {"content-type": "text/event-stream"},
+ )
+
+ _mock_http_client(monkeypatch, handler)
+
+ async def run():
+ client = _make_client()
+ lines = await _collect(
+ client._stream_openai_responses(
+ messages = [{"role": "user", "content": "hi"}],
+ model = "gpt-5.5",
+ temperature = 0.7,
+ top_p = 0.95,
+ max_tokens = None,
+ enable_thinking = None,
+ reasoning_effort = None,
+ )
+ )
+ await client.close()
+ return lines
+
+ lines = _drive(run())
+ error_line = next(line for line in lines if '"error"' in line)
+ error = json.loads(error_line[len("data:") :].strip())["error"]
+ assert "Unknown error" not in error["message"]
+ assert "resp_failed_123" in error["message"]
+
+
def test_responses_translates_image_parts(monkeypatch):
captured: dict = {}
@@ -735,3 +780,54 @@ def test_responses_reasoning_summary_wrapped_in_think_tags(monkeypatch):
if payload["choices"][0]["delta"]
)
assert "<think>plan</think>answer" in combined
+
+
+ ("body", "expected"),
+ (
+ # OpenAI, Anthropic and Gemini error envelopes.
+ (
+ '{"error": {"message": "You have no credits remaining.",'
+ ' "type": "insufficient_quota", "code": "credit_balance_exhausted"}}',
+ "You have no credits remaining. (credit_balance_exhausted)",
+ ),
+ (
+ '{"type":"error","error":{"type":"invalid_request_error",'
+ '"message":"`temperature` is deprecated for this model."},"request_id":"req_1"}',
+ "`temperature` is deprecated for this model. (invalid_request_error)",
+ ),
+ (
+ '{"error": {"code": 400, "message": "API key not valid.",'
+ ' "status": "INVALID_ARGUMENT"}}',
+ "API key not valid. (INVALID_ARGUMENT)",
+ ),
+ # FastAPI-style bodies from OpenAI-compat backends (vllm, llama.cpp).
+ ('{"detail": "Model unavailable"}', "Model unavailable"),
+ (
+ '{"detail": [{"loc": ["body", "model"], "msg": "field required"},'
+ ' {"msg": "bad temperature"}]}',
+ "field required; bad temperature",
+ ),
+ # Already-friendly text passes through; empty/detail-free bodies fall back.
+ ("Timeout waiting for openai response", "Timeout waiting for openai response"),
+ ("", "openai returned HTTP 500 with no error details."),
+ ('{"error": {}}', "openai returned HTTP 500 with no error details."),
+ ('{"detail": []}', "openai returned HTTP 500 with no error details."),
+ ('{"detail": {"weird": 1}}', "openai returned HTTP 500 with no error details."),
+ ),
+)
+def test_upstream_error_body_reduced_to_its_message(body, expected):
+ assert ep_mod._readable_provider_error(500, body, "openai") == expected
+
+
+def test_error_sse_line_carries_no_json_blob(monkeypatch):
+ """A raw upstream body must not reach the client as nested JSON."""
+ line = ep_mod._error_sse_line(
+ 429,
+ '{"error": {"message": "Rate limit reached.", "code": "rate_limit_exceeded"}}',
+ "openai",
+ )
+ error = json.loads(line[len("data:") :].strip())["error"]
+ assert error["message"] == "Rate limit reached. (rate_limit_exceeded)"
+ assert "{" not in error["message"]
+ assert error["code"] == "429"
diff --git a/studio/backend/tests/test_pricing.py b/studio/backend/tests/test_pricing.py
index 8cd7796f142..322b303a20e 100644
--- a/studio/backend/tests/test_pricing.py
+++ b/studio/backend/tests/test_pricing.py
@@ -622,3 +622,64 @@ def test_explicit_zero_output_tokens_wins_over_stale_completion_tokens():
)
assert out["billable_output_tokens"] == 0, out
assert out["output_usd"] == 0.0, out
+
+
+def test_openai_gpt56_family_uses_verified_prices():
+ """Sol / Terra / Luna, both context tiers, from the published table."""
+ expected = {
+ "gpt-5.6-sol": (5.0, 30.0, 10.0, 45.0),
+ "gpt-5.6-terra": (2.0, 12.0, 4.0, 18.0),
+ "gpt-5.6-luna": (0.20, 1.20, 0.40, 1.80),
+ }
+ for model, (inp, out, long_in, long_out) in expected.items():
+ row = OPENAI_PRICING[model]
+ assert row["input_per_mtok"] == inp, model
+ assert row["output_per_mtok"] == out, model
+ assert row["long_context_threshold"] == 272_000, model
+ assert row["long_context_input_per_mtok"] == long_in, model
+ assert row["long_context_output_per_mtok"] == long_out, model
+ short = calculate_cost("openai", model, {"input_tokens": 1000, "output_tokens": 1000})
+ assert short["priced"] is True, model
+ assert _isclose(short["input_usd"], 1000 / 1_000_000.0 * inp), model
+ # Past the threshold the whole request reprices at the long rates.
+ long = calculate_cost("openai", model, {"input_tokens": 300_000, "output_tokens": 1000})
+ assert _isclose(long["input_usd"], 300_000 / 1_000_000.0 * long_in), model
+ assert _isclose(long["output_usd"], 1000 / 1_000_000.0 * long_out), model
+
+
+def test_sonnet_5_bills_the_launch_rate_until_the_cutover():
+ """Sonnet 5 ships at $2/$10 through 2026-08-31 and $3/$15 from 2026-09-01.
+ Ref: https://platform.claude.com/docs/en/about-claude/pricing"""
+ import datetime
+
+ from core.inference.pricing import _launch_prices
+
+ table = ANTHROPIC_PRICING["claude-sonnet-5"]
+ assert table["input_per_mtok"] == 3.0 and table["output_per_mtok"] == 15.0
+
+ launch = _launch_prices("anthropic", "claude-sonnet-5", table, today = datetime.date(2026, 8, 31))
+ assert launch["input_per_mtok"] == 2.0 and launch["output_per_mtok"] == 10.0
+ # A dated snapshot inherits the same launch rate.
+ dated = _launch_prices(
+ "anthropic", "claude-sonnet-5-20260629", table, today = datetime.date(2026, 8, 31)
+ )
+ assert dated["input_per_mtok"] == 2.0
+
+ after = _launch_prices("anthropic", "claude-sonnet-5", table, today = datetime.date(2026, 9, 1))
+ assert after == table
+ # Neighbouring families are untouched on either side of the cutover.
+ opus = ANTHROPIC_PRICING["claude-opus-5"]
+ assert (
+ _launch_prices("anthropic", "claude-opus-5", opus, today = datetime.date(2026, 8, 31)) == opus
+ )
+
+
+def test_fast_mode_multiplier_is_2x_for_the_supported_opus_models():
+ """Fast mode is Opus 5 / Opus 4.8 only, at $10/$50 against a $5/$25 base.
+ Ref: https://platform.claude.com/docs/en/build-with-claude/fast-mode#pricing"""
+ assert ANTHROPIC_FAST_MODE_MULT == 2.0
+ for model in ("claude-opus-5", "claude-opus-4-8"):
+ usage = {"input_tokens": 1_000_000, "output_tokens": 1_000_000, "speed": "fast"}
+ out = calculate_cost("anthropic", model, usage)
+ assert _isclose(out["input_usd"], 10.0), model
+ assert _isclose(out["output_usd"], 50.0), model
diff --git a/studio/backend/tests/test_provider_model_allowlist.py b/studio/backend/tests/test_provider_model_allowlist.py
new file mode 100644
index 00000000000..03f2f055f5b
--- /dev/null
+++ b/studio/backend/tests/test_provider_model_allowlist.py
@@ -0,0 +1,49 @@
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+"""The picker filters in ``core/inference/providers.py`` are pattern-based, so
+a new model family silently disappears when a pattern is not widened. These
+tests pin live ids against the filters."""
+
+import sys
+from pathlib import Path
+
+_BACKEND = Path(__file__).resolve().parents[1]
+if str(_BACKEND) not in sys.path:
+ sys.path.insert(0, str(_BACKEND))
+
+from core.inference.providers import PROVIDER_REGISTRY # noqa: E402
+
+
+def test_current_generation_model_ids_reach_the_picker():
+ """Live ids from each provider's list endpoint must survive the
+ allow/deny filters, otherwise the newest models are invisible."""
+ live = {
+ "openai": ["gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna", "gpt-5.5", "gpt-5.5-pro"],
+ "gemini": [
+ "gemini-3.6-flash",
+ "gemini-3.5-flash",
+ "gemini-3.5-flash-lite",
+ "gemini-3.1-pro-preview",
+ "gemini-3.1-flash-image",
+ "gemini-3-pro-image",
+ "gemini-2.5-flash",
+ ],
+ }
+ for provider, model_ids in live.items():
+ registry = PROVIDER_REGISTRY[provider]
+ allow = registry["model_id_allowlist"]
+ deny = registry.get("model_id_denylist")
+ deny_exact = registry.get("model_id_deny_exact") or ()
+ for model_id in model_ids:
+ assert allow.match(model_id), f"{provider}: {model_id} not allowlisted"
+ assert not (deny and deny.search(model_id)), f"{provider}: {model_id} denylisted"
+ assert model_id not in deny_exact, f"{provider}: {model_id} denied exactly"
+
+
+def test_dated_snapshots_and_retired_ids_stay_out_of_the_picker():
+ openai = PROVIDER_REGISTRY["openai"]
+ for model_id in ("gpt-5.6-sol-2026-07-09", "gpt-5.5-2026-04-23", "gpt-5.3"):
+ assert openai["model_id_denylist"].search(model_id), model_id
+ gemini = PROVIDER_REGISTRY["gemini"]
+ assert "gemini-3-pro-preview" in gemini["model_id_deny_exact"]
diff --git a/studio/frontend/src/features/chat/chat-settings-sheet.tsx b/studio/frontend/src/features/chat/chat-settings-sheet.tsx
index 8361bf78b43..cb4fc01fb04 100644
--- a/studio/frontend/src/features/chat/chat-settings-sheet.tsx
+++ b/studio/frontend/src/features/chat/chat-settings-sheet.tsx
@@ -1210,8 +1210,9 @@ export function ChatSettingsPanel({
Fast mode
</span>
<InfoHint>
- Beta. Up to 2.5x higher output tokens per second on
- Claude Opus 4.6 and 4.7 at 6x standard Opus pricing.
+ Research preview. Up to 2.5x higher output tokens per
+ second on Claude Opus 5 and 4.8 at 2x standard Opus
+ pricing.
Switching between fast and standard invalidates the
prompt cache and is incompatible with the Priority
service tier.
diff --git a/studio/frontend/src/features/chat/provider-capabilities.ts b/studio/frontend/src/features/chat/provider-capabilities.ts
index ec251cdada9..e7959294daf 100644
--- a/studio/frontend/src/features/chat/provider-capabilities.ts
+++ b/studio/frontend/src/features/chat/provider-capabilities.ts
@@ -89,13 +89,24 @@ const EXTERNAL_MAX_OUTPUT_TOKENS_BY_MODEL: Array<{
cap: number;
}> = [
// OpenAI
- { providerType: "openai", prefixes: ["gpt-5.5-pro", "gpt-5.5"], cap: 128000 },
+ {
+ providerType: "openai",
+ prefixes: ["gpt-5.6", "gpt-5.5-pro", "gpt-5.5"],
+ cap: 128000,
+ },
{ providerType: "openai", prefixes: ["gpt-5.4-pro", "gpt-5.4"], cap: 65536 },
{ providerType: "openai", prefixes: ["gpt-5.3"], cap: 16384 },
// Anthropic
{
providerType: "anthropic",
- prefixes: ["claude-opus-4-7"],
+ prefixes: [
+ "claude-opus-5",
+ "claude-sonnet-5",
+ "claude-fable-5",
+ "claude-mythos-5",
+ "claude-opus-4-8",
+ "claude-opus-4-7",
+ ],
cap: 128000,
},
{
@@ -229,13 +240,15 @@ export function providerSupportsBuiltinWebFetch(
/**
* Whether the active provider + model supports Anthropic fast-mode
- * (`speed: "fast"` + `fast-mode-2026-02-01` header). Opus 4.6 / 4.7
- * only per https://platform.claude.com/docs/en/build-with-claude/fast-mode.
+ * (`speed: "fast"` + `fast-mode-2026-02-01` header). Opus 5 / Opus 4.8 only
+ * per https://platform.claude.com/docs/en/build-with-claude/fast-mode: 4.7
+ * errors on `speed`, and 4.6 accepts it but runs at standard speed, so the
+ * toggle there promises a speed-up that never arrives.
* Backend silently drops on unsupported models as a second defence.
*/
const ANTHROPIC_FAST_MODE_MODEL_PREFIXES = [
- "claude-opus-4-7",
- "claude-opus-4-6",
+ "claude-opus-5",
+ "claude-opus-4-8",
] as const;
export function providerSupportsFastMode(
@@ -275,6 +288,11 @@ export function providerSupportsFastMode(
* `input_file`) are a deliberate follow-up.
*/
const ANTHROPIC_CODE_EXECUTION_MODEL_PREFIXES = [
+ "claude-opus-5",
+ "claude-sonnet-5",
+ "claude-fable-5",
+ "claude-mythos-5",
+ "claude-opus-4-8",
"claude-opus-4-7",
"claude-opus-4-6",
"claude-sonnet-4-6",
@@ -288,10 +306,12 @@ const ANTHROPIC_CODE_EXECUTION_MODEL_PREFIXES = [
"claude-sonnet-4",
] as const;
-// OpenAI cloud shell-tool gating. Docs only show gpt-5.5; gpt-5.5-pro shares
-// the same /v1/responses contract. `gpt-5.5-pro` is checked first so the prefix
-// match doesn't collide with e.g. a hypothetical `gpt-5.5-turbo`.
+// OpenAI cloud shell-tool gating. The gpt-5.6 family (sol/terra/luna) lists the
+// hosted shell under its supported tools; gpt-5.5-pro shares the same
+// /v1/responses contract as gpt-5.5. `gpt-5.5-pro` is checked first so the
+// prefix match doesn't collide with e.g. a hypothetical `gpt-5.5-turbo`.
const OPENAI_CODE_EXECUTION_MODEL_PREFIXES = [
+ "gpt-5.6",
"gpt-5.5-pro",
"gpt-5.5",
] as const;
@@ -606,16 +626,31 @@ const NO_REASONING_CAPS: ReasoningCaps = {
const ANTHROPIC_REASONING_MODELS = [
{
- prefixes: ["claude-opus-4-7"],
+ // Fable / Mythos 5 think in adaptive mode always: `thinking.type
+ // "disabled"` 400s, so there is no off switch to offer.
+ prefixes: ["claude-fable-5", "claude-mythos-5"],
+ supportsOff: false,
+ levels: ["low", "medium", "high", "xhigh", "max"],
+ },
+ {
+ prefixes: [
+ "claude-opus-5",
+ "claude-sonnet-5",
+ "claude-opus-4-8",
+ "claude-opus-4-7",
+ ],
+ supportsOff: true,
levels: ["none", "low", "medium", "high", "xhigh", "max"],
},
{
prefixes: ["claude-opus-4-6", "claude-sonnet-4-6"],
+ supportsOff: true,
levels: ["none", "low", "medium", "high", "max"],
},
{
prefixes: ["claude-opus-4-5", "claude-sonnet-4-5", "claude-haiku-4-5"],
// Backend maps semantic levels to manual budget_tokens.
+ supportsOff: true,
levels: ["none", "low", "medium", "high"],
},
] as const;
@@ -635,7 +670,7 @@ function resolveAnthropicReasoningEffortCapabilities(modelId: string): Reasoning
if (matched) {
return {
supportsReasoning: true,
- supportsReasoningOff: true,
+ supportsReasoningOff: matched.supportsOff,
reasoningEffortLevels: matched.levels,
};
}
@@ -649,7 +684,9 @@ const OPENAI_REASONING_MODELS = [
levels: ["medium", "high", "xhigh"],
},
{
- prefixes: ["gpt-5.5", "gpt-5.4"],
+ // gpt-5.6 (sol/terra/luna) rejects "minimal"; the ladder is the same as
+ // gpt-5.5 / gpt-5.4.
+ prefixes: ["gpt-5.6", "gpt-5.5", "gpt-5.4"],
supportsOff: true,
levels: ["none", "low", "medium", "high", "xhigh"],
},
@@ -739,16 +776,14 @@ function resolveKimiReasoningCapabilities(modelId: string): ExternalReasoningCap
// (0=off on Flash, -1=dynamic, N>0=cap; Pro rejects 0).
// - 2.5 Flash-Lite: no native thinking surfaced; leave off.
// - Image-tier ids: image generation path -- no reasoning controls.
-const GEMINI3_PRO_PREFIXES = [
- "gemini-3.5-pro",
- "gemini-3.1-pro",
- "gemini-3-pro-preview",
- "gemini-pro-latest",
-];
+// Match the 3.x minors by pattern rather than enumerating them: a new
+// `gemini-3.6-flash` otherwise falls through to the 2.5 branch and gets the
+// integer thinkingBudget ladder, which Gemini 3 rejects. Mirrors
+// `_GEMINI3_FAMILY` / `_GEMINI3_PRO` in the backend's external_provider.py.
+const GEMINI3_PRO_PATTERN = /^gemini-3(\.\d+)?-pro/;
+const GEMINI3_FLASH_PATTERN = /^gemini-3(\.\d+)?-flash/;
+const GEMINI3_PRO_PREFIXES = ["gemini-pro-latest"];
const GEMINI3_FLASH_PREFIXES = [
- "gemini-3.5-flash",
- "gemini-3.1-flash",
- "gemini-3-flash",
"gemini-flash-latest",
"gemini-flash-lite-latest",
];
@@ -788,7 +823,7 @@ function resolveGeminiReasoningCapabilities(
] as const,
});
}
- if (GEMINI3_PRO_PREFIXES.some((p) => m.startsWith(p))) {
+ if (GEMINI3_PRO_PATTERN.test(m) || GEMINI3_PRO_PREFIXES.some((p) => m.startsWith(p))) {
// Gemini 3.x Pro: thinkingLevel low/medium/high; cannot fully disable, and
// "minimal" is rejected on Pro. Refs:
// https://ai.google.dev/gemini-api/docs/thinking and
@@ -799,7 +834,7 @@ function resolveGeminiReasoningCapabilities(
reasoningEffortLevels: ["low", "medium", "high"] as const,
});
}
- if (GEMINI3_FLASH_PREFIXES.some((p) => m.startsWith(p))) {
+ if (GEMINI3_FLASH_PATTERN.test(m) || GEMINI3_FLASH_PREFIXES.some((p) => m.startsWith(p))) {
// Gemini 3 Flash: thinkingLevel minimal/low/medium/high. Minimal is the
// closest to "off" Google offers on Gemini 3.
return withReasoningEffortStyle({
diff --git a/studio/frontend/tests/provider-capabilities-current-models.test.ts b/studio/frontend/tests/provider-capabilities-current-models.test.ts
new file mode 100644
index 00000000000..c55ae46a0d3
--- /dev/null
+++ b/studio/frontend/tests/provider-capabilities-current-models.test.ts
@@ -0,0 +1,98 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import { registerBundlerResolver } from "./helpers/kit.ts";
+
+registerBundlerResolver();
+
+const {
+ getExternalMaxOutputTokens,
+ getExternalReasoningCapabilities,
+ providerSupportsBuiltinCodeExecution,
+ providerSupportsFastMode,
+} = await import("../src/features/chat/provider-capabilities.ts");
+
+// The picker's default_models list (backend core/inference/providers.py) grew a
+// Claude 5 / gpt-5.6 / gemini-3.6 generation. Every table here is prefix-based,
+// so an un-widened prefix silently drops the control instead of failing loudly:
+// a model with no reasoning entry loses its Thinking picker entirely.
+
+test("Claude 5 and Opus 4.8 expose the adaptive effort ladder", () => {
+ for (const model of [
+ "claude-opus-5",
+ "claude-sonnet-5",
+ "claude-opus-4-8",
+ "claude-opus-4-7",
+ ]) {
+ const caps = getExternalReasoningCapabilities("anthropic", model);
+ assert.equal(caps.supportsReasoning, true, model);
+ assert.equal(caps.supportsReasoningOff, true, model);
+ assert.deepEqual(
+ [...caps.reasoningEffortLevels],
+ ["none", "low", "medium", "high", "xhigh", "max"],
+ model,
+ );
+ }
+});
+
+test("Fable 5 thinks always, so no off switch is offered", () => {
+ // `thinking.type: "disabled"` 400s on Fable/Mythos 5.
+ const caps = getExternalReasoningCapabilities("anthropic", "claude-fable-5");
+ assert.equal(caps.supportsReasoning, true);
+ assert.equal(caps.supportsReasoningOff, false);
+ assert.ok(![...caps.reasoningEffortLevels].includes("none"));
+});
+
+test("fast mode is offered on Opus 5 / 4.8 and nowhere else", () => {
+ for (const model of ["claude-opus-5", "claude-opus-4-8-2026-02-01"]) {
+ assert.equal(providerSupportsFastMode("anthropic", model), true, model);
+ }
+ // 4.7 errors on `speed`; 4.6 accepts it but answers at standard speed.
+ for (const model of ["claude-opus-4-7", "claude-opus-4-6", "claude-sonnet-5"]) {
+ assert.equal(providerSupportsFastMode("anthropic", model), false, model);
+ }
+});
+
+test("the gpt-5.6 family gets the gpt-5.5 reasoning ladder", () => {
+ for (const model of ["gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna"]) {
+ const caps = getExternalReasoningCapabilities("openai", model);
+ assert.equal(caps.supportsReasoning, true, model);
+ assert.equal(caps.supportsReasoningOff, true, model);
+ // The API rejects "minimal" on this family.
+ assert.deepEqual(
+ [...caps.reasoningEffortLevels],
+ ["none", "low", "medium", "high", "xhigh"],
+ model,
+ );
+ assert.equal(getExternalMaxOutputTokens("openai", model), 128000, model);
+ }
+});
+
+test("Gemini 3.x minors keep the thinkingLevel ladder", () => {
+ // gemini-3.6-flash must not fall through to the 2.5 integer-budget branch.
+ for (const model of ["gemini-3.6-flash", "gemini-3.5-flash-lite", "gemini-3-flash-preview"]) {
+ const caps = getExternalReasoningCapabilities("gemini", model);
+ assert.equal(caps.reasoningStyle, "reasoning_effort", model);
+ assert.deepEqual(
+ [...caps.reasoningEffortLevels],
+ ["minimal", "low", "medium", "high"],
+ model,
+ );
+ }
+ const pro = getExternalReasoningCapabilities("gemini", "gemini-3.1-pro-preview");
+ assert.deepEqual([...pro.reasoningEffortLevels], ["low", "medium", "high"]);
+});
+
+test("new Anthropic and OpenAI ids keep their max-output cap and code pill", () => {
+ for (const model of ["claude-opus-5", "claude-sonnet-5", "claude-opus-4-8"]) {
+ assert.equal(getExternalMaxOutputTokens("anthropic", model), 128000, model);
+ assert.equal(providerSupportsBuiltinCodeExecution("anthropic", model), true, model);
+ }
+ assert.equal(
+ providerSupportsBuiltinCodeExecution("openai", "gpt-5.6-sol", "https://api.openai.com/v1"),
+ true,
+ );
+});