The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(stt): preserve xAI model override compatibility
Julien Talbot32586978aea7
diff --git a/hermes_cli/config_defaults.py b/hermes_cli/config_defaults.pyindex 3620713944a..d027c5a402b 100644--- a/hermes_cli/config_defaults.py+++ b/hermes_cli/config_defaults.py@@ -1198,9 +1198,9 @@ DEFAULT_CONFIG = {"language": "", # auto-detect; set "en", "es", ... to force},"xai": {- # grok-voice-transcribe-2.0 | grok-voice-transcribe-1.0. Sent as the multipart- # ``model`` field; omitting it leaves xAI on 1.0 until that server default flips.- "model": "grok-voice-transcribe-2.0",+ # grok-voice-transcribe-2.0 | grok-voice-transcribe-1.0. An empty value lets+ # STT_XAI_MODEL (or the resolver's 2.0 default) choose the multipart model.+ "model": "","language": "", # auto-detect; set "en", "es", ... to force},"elevenlabs": {diff --git a/tests/tools/test_transcription_tools.py b/tests/tools/test_transcription_tools.pyindex 03a06a09670..cd7b6551274 100644--- a/tests/tools/test_transcription_tools.py+++ b/tests/tools/test_transcription_tools.py@@ -933,7 +933,7 @@ class TestTranscribeXAI:data = call_kwargs.kwargs.get("data", call_kwargs[1].get("data", {}))assert data.get("language") == "fr"assert data.get("format") == "true"- assert data.get("model") == "grok-stt"+ assert data.get("model") == "grok-voice-transcribe-2.0"def test_omitted_model_pins_transcribe_2(self, monkeypatch, sample_ogg, mock_xai_http_module):"""xAI still defaults an omitted model to transcribe-1.0. Always send one."""@@ -1032,6 +1032,17 @@ class TestTranscribeAudioXAIDispatch:assert mock_xai.call_args[0][1] == "grok-voice-transcribe-1.0"+ def test_legacy_grok_stt_alias_uses_current_default(self, sample_ogg):+ config = {"provider": "xai", "xai": {"model": "grok-stt"}}+ with patch("tools.transcription_tools._load_stt_config", return_value=config), \+ patch("tools.transcription_tools._get_provider", return_value="xai"), \+ patch("tools.transcription_tools._transcribe_xai",+ return_value={"success": True, "transcript": "hi"}) as mock_xai:+ from tools.transcription_tools import transcribe_audio+ transcribe_audio(sample_ogg, model=None)++ assert mock_xai.call_args[0][1] == "grok-voice-transcribe-2.0"+# ============================================================================# _transcribe_elevenlabs# ============================================================================diff --git a/tools/transcription_cloud.py b/tools/transcription_cloud.pyindex 80fef1d614f..27c65c707e1 100644--- a/tools/transcription_cloud.py+++ b/tools/transcription_cloud.py@@ -19,9 +19,10 @@ from urllib.parse import urljoinfrom utils import is_truthy_valuefrom tools.transcription_audio import _transcode_audio_for_sttfrom tools.transcription_common import (- DEFAULT_GROQ_STT_MODEL, DEFAULT_STT_MODEL, DEFAULT_XAI_STT_MODEL, ELEVENLABS_STT_BASE_URL,+ DEFAULT_GROQ_STT_MODEL, DEFAULT_STT_MODEL, ELEVENLABS_STT_BASE_URL,GROQ_BASE_URL, GROQ_MODELS, OPENAI_BASE_URL, OPENAI_MODELS, STTResponseError, XAI_STT_BASE_URL,- _error_result, _get_stt_section, _lazy_ensure_quietly, _log_prompt_unsupported, _ok_result)+ _error_result, _get_stt_section, _lazy_ensure_quietly, _log_prompt_unsupported, _ok_result,+ normalize_xai_stt_model)# Log-record parity with the origin module.logger = logging.getLogger("tools.transcription_tools")@@ -281,7 +282,7 @@ def _transcribe_xai(def _post() -> Any:from tools.xai_http import hermes_xai_user_agent# Omit ``model`` and xAI serves grok-voice-transcribe-1.0 until it flips the default.- resolved_model = str(model_name or "").strip() or DEFAULT_XAI_STT_MODEL+ resolved_model = normalize_xai_stt_model(model_name)data: Dict[str, str] = {"model": resolved_model}if language:data["language"] = languagediff --git a/tools/transcription_common.py b/tools/transcription_common.pyindex a4f300b6495..8b87b011233 100644--- a/tools/transcription_common.py+++ b/tools/transcription_common.py@@ -26,6 +26,7 @@ DEFAULT_STT_TIMEOUT = 60.0# 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.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"LOCAL_STT_LANGUAGE_ENV = "HERMES_LOCAL_STT_LANGUAGE"COMMON_LOCAL_BIN_DIRS = ("/opt/homebrew/bin", "/usr/local/bin")@@ -69,6 +70,14 @@ class STTResponseError(ValueError):than stringifying the response object into its repr (#78098)."""+def normalize_xai_stt_model(model: Any) -> str:+ """Return a valid xAI STT model, including compatibility for Hermes' old alias."""+ value = str(model or "").strip()+ if not value or value == LEGACY_XAI_STT_MODEL:+ return DEFAULT_XAI_STT_MODEL+ return value++def _ok_result(transcript: str, provider: str) -> Dict[str, Any]:return {"success": True, "transcript": transcript, "provider": provider}diff --git a/tools/transcription_tools.py b/tools/transcription_tools.pyindex 6f44385df3f..00a4f776f48 100644--- a/tools/transcription_tools.py+++ b/tools/transcription_tools.py@@ -26,7 +26,7 @@ from tools.transcription_common import (BUILTIN_STT_PROVIDERS, CLOUD_STT_PROVIDERS, DEFAULT_ELEVENLABS_STT_MODEL,DEFAULT_GROQ_STT_MODEL, DEFAULT_LOCAL_MODEL, DEFAULT_MISTRAL_STT_MODEL, DEFAULT_PROVIDER,DEFAULT_STT_MODEL, DEFAULT_XAI_STT_MODEL, LOCAL_STT_COMMAND_ENV, LOCAL_STT_LANGUAGE_ENV,- _error_result, _get_stt_section, _ok_result)+ normalize_xai_stt_model, _error_result, _get_stt_section, _ok_result)from tools.transcription_audio import (_convert_caf_to_wav, _prepare_audio_for_transcription, _trim_silence_for_cloud_stt,_validate_audio_file, _validate_audio_file_size, _validate_audio_source_file)@@ -484,7 +484,8 @@ def _builtin_model_name(provider: str, stt_config: Dict[str, Any], model: Optionreturn modelsection, key, default, empty_is_missing = _BUILTIN_MODEL_KEYS[provider]cfg = _get_stt_section(stt_config, section)- return (cfg.get(key) or default) if empty_is_missing else cfg.get(key, default)+ resolved = (cfg.get(key) or default) if empty_is_missing else cfg.get(key, default)+ return normalize_xai_stt_model(resolved) if provider == "xai" else resolveddef _dispatch_stt_provider(diff --git a/tools/voice_client_config.py b/tools/voice_client_config.pyindex c5ba8f50257..a909b36fcc6 100644--- a/tools/voice_client_config.py+++ b/tools/voice_client_config.py@@ -146,7 +146,7 @@ def _resolve_stt_client_config() -> Dict[str, Any]:if not api_key:return _relay("xai oauth (server-managed) or no credentials")return direct(STT_WIRE_XAI, env_base_url("XAI_STT_BASE_URL", tc.XAI_STT_BASE_URL), api_key,- section.get("model") or tc.DEFAULT_XAI_STT_MODEL)+ tc.normalize_xai_stt_model(section.get("model")))if provider == "elevenlabs":api_key = tt._resolve_provider_key("ELEVENLABS_API_KEY", "elevenlabs")if not api_key: