fix(xai-oauth): strip service_tier and add safety-net sanitization for slash enums

xAI's /v1/responses endpoint rejects service_tier with HTTP 400
"Argument not supported: service_tier" when users activate /fast mode.

Also add a safety-net strip_slash_enum call in _preflight_codex_api_kwargs
to catch any tool schemas that might slip through the caller-level
sanitization. xAI's Responses API grammar compiler rejects enum values
containing forward slashes (e.g. HuggingFace model IDs like
"Qwen/Qwen3.5-0.8B") with the opaque "Invalid arguments passed to the
model" error.

Fixes the root cause of "Invalid arguments passed to the model" errors
reported by xAI OAuth (SuperGrok) users.
This commit is contained in:
Nami4D 2026-05-19 11:23:40 +09:00 committed by Teknium
parent 0325e18f34
commit a699de83ec
2 changed files with 31 additions and 0 deletions

View file

@ -184,6 +184,17 @@ class ResponsesApiTransport(ProviderTransport):
if request_overrides:
kwargs.update(request_overrides)
# xAI Responses API rejects ``service_tier`` (HTTP 400 "Argument not
# supported: service_tier") — hit when ``/fast`` priority-processing
# mode lingers from a prior model in the same session, or when a
# user explicitly sets ``agent.service_tier`` in config.yaml. The
# main-loop guard (``resolve_fast_mode_overrides`` only returns
# ``service_tier`` for OpenAI fast-eligible models) doesn't cover
# those leak paths, so strip defensively when targeting xAI. See
# #28490 for the original report.
if is_xai_responses:
kwargs.pop("service_tier", None)
# Forward per-request timeout to the SDK so OpenAI/Anthropic clients
# honor it. Without this, ``providers.<id>.request_timeout_seconds``
# is silently dropped on the main agent Codex path while the