The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(stt): xAI format=true only with a language; accurate model-default notes
teknium1d1152d797c66
diff --git a/apps/desktop/src/lib/voice-client-direct.test.ts b/apps/desktop/src/lib/voice-client-direct.test.tsindex 19ac1e52bdb..daebf9f5a5c 100644--- a/apps/desktop/src/lib/voice-client-direct.test.ts+++ b/apps/desktop/src/lib/voice-client-direct.test.ts@@ -269,6 +269,30 @@ describe('transcribeAudioClientDirect', () => {expect((init.body as FormData).get('model')).toBe('grok-voice-transcribe-2.0')})+ it('drops format=true on the xai wire when no language is set (xAI answers HTTP 400 otherwise)', async () => {+ mockDesktopApi({+ ok: true,+ stt: {+ ...directStt,+ wire: 'xai-stt',+ provider: 'xai',+ base_url: 'https://api.x.ai/v1',+ model: 'grok-voice-transcribe-2.0',+ language: ''+ },+ tts: relay+ })++ const fetchMock = vi.fn(async () => new Response(JSON.stringify({ text: 'auto detected' }), { status: 200 }))+ vi.stubGlobal('fetch', fetchMock)++ expect(await transcribeAudioClientDirect(new Blob(['x']))).toBe('auto detected')++ const [, init] = fetchMock.mock.calls[0] as unknown as [string, RequestInit]+ expect((init.body as FormData).has('format')).toBe(false)+ expect((init.body as FormData).has('language')).toBe(false)+ })+it('speaks the elevenlabs wire shape with xi-api-key auth', async () => {mockDesktopApi({ok: true,diff --git a/apps/desktop/src/lib/voice-client-direct.ts b/apps/desktop/src/lib/voice-client-direct.tsindex 784317ffd94..85b2e3d4a59 100644--- a/apps/desktop/src/lib/voice-client-direct.ts+++ b/apps/desktop/src/lib/voice-client-direct.ts@@ -317,14 +317,15 @@ export async function transcribeAudioClientDirect(audio: Blob, owner?: ResolvedOif (stt.wire === 'xai-stt') {const form = new FormData()form.set('file', audio, sttFileName(audio))- form.set('format', 'true')if (stt.model) {form.set('model', stt.model)}+ // xAI rejects format=true without a language (HTTP 400), so auto-detect drops the flag.if (stt.language) {form.set('language', stt.language)+ form.set('format', 'true')}const response = await sttFetch(stt, `${stt.base_url.replace(/\/+$/, '')}/stt`, {diff --git a/tests/tools/test_stt_language_resolution.py b/tests/tools/test_stt_language_resolution.pyindex 22c38d7387d..0ae49969ae3 100644--- a/tests/tools/test_stt_language_resolution.py+++ b/tests/tools/test_stt_language_resolution.py@@ -70,6 +70,9 @@ class TestXaiNoForcedEnglish:assert result["success"] is Trueassert "language" not in (captured["data"] or {}), \"xAI must auto-detect when no language is configured (was forced to 'en')"+ # /v1/stt returns HTTP 400 for format=true without a language, so auto-detect drops it.+ assert "format" not in (captured["data"] or {}), \+ "format=true must not be sent without a language (xAI rejects it with HTTP 400)"def test_global_language_reaches_xai(self, tmp_path, monkeypatch):import tools.transcription_tools as ttdiff --git a/tools/transcription_cloud.py b/tools/transcription_cloud.pyindex 216825da6ed..c7d5709abba 100644--- a/tools/transcription_cloud.py+++ b/tools/transcription_cloud.py@@ -281,13 +281,17 @@ def _transcribe_xai(def _post() -> Any:from tools.xai_http import hermes_xai_user_agent- # Always send the model so xAI's current 1.0 server default cannot leak into Hermes.+ # Always name the model: xAI moved the server default from 1.0 to 2.0 mid-September and+ # will retire 1.0, so an omitted field silently changes what Hermes runs.resolved_model = normalize_xai_stt_model(model_name)data: Dict[str, str] = {"model": resolved_model}if language:data["language"] = language- data.update({flag: "true" for flag, default in (("format", True), ("diarize", False))- if is_truthy_value(xai_config.get(flag, default))})+ # ``format`` (inverse text normalization) requires ``language``; /v1/stt answers HTTP 400+ # "Field 'language' is required when 'format' is true" otherwise, so with stt.language ""+ # (auto-detect) the flag is dropped instead of failing every transcription.+ flags = ((("format", True),) if language else ()) + (("diarize", False),)+ data.update({flag: "true" for flag, default in flags if is_truthy_value(xai_config.get(flag, default))})def _post_transcription(bearer: str, endpoint_base_url: str):headers = {"Authorization": f"Bearer {bearer}", "User-Agent": hermes_xai_user_agent()}diff --git a/tools/transcription_common.py b/tools/transcription_common.pyindex 8b87b011233..c783016f363 100644--- a/tools/transcription_common.py+++ b/tools/transcription_common.py@@ -22,9 +22,9 @@ DEFAULT_ELEVENLABS_STT_MODEL = os.getenv("STT_ELEVENLABS_MODEL", "scribe_v2")# Seconds for one STT HTTP request; shared by the OpenAI-SDK path and the QQ adapter so a# self-hosted model's cold start is not cut off at the old fixed 30s (#112939).DEFAULT_STT_TIMEOUT = 60.0-# xAI's /v1/stt still defaults to grok-voice-transcribe-1.0 when ``model`` is omitted.-# Pin 2.0 so Hermes doesn't stay on 1.0 until xAI flips the server default, then-# break when 1.0 is removed. Override with STT_XAI_MODEL or stt.xai.model.+# /v1/stt's server default moved from grok-voice-transcribe-1.0 to 2.0 between Sep 17 and+# Sep 21 2026 and 1.0 is slated for retirement; naming the model keeps the wire deterministic+# and lets STT_XAI_MODEL / stt.xai.model pin 1.0 for a rollback.DEFAULT_XAI_STT_MODEL = os.getenv("STT_XAI_MODEL", "grok-voice-transcribe-2.0")LEGACY_XAI_STT_MODEL = "grok-stt"LOCAL_STT_COMMAND_ENV = "HERMES_LOCAL_STT_COMMAND"