The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(stt): coerce the new client keys, apply the 60s default to the QQ STT call, document both
teknium1749f657fbf80
diff --git a/gateway/platforms/qqbot/adapter.py b/gateway/platforms/qqbot/adapter.pyindex b7cad9f64b9..b4890438555 100644--- a/gateway/platforms/qqbot/adapter.py+++ b/gateway/platforms/qqbot/adapter.py@@ -81,6 +81,7 @@ def check_qq_requirements() -> bool:_VOICE_EXTENSIONS = (".silk", ".amr", ".mp3", ".wav", ".ogg", ".m4a", ".aac", ".speex", ".flac")+_STT_DEFAULT_TIMEOUT = 60.0 # seconds; matches stt.openai.timeout's default_STT_PROVIDER_BASE_URLS = {"zai": "https://open.bigmodel.cn/api/coding/paas/v4",# Aliases that target direct REST APIs not modeled as first-class providers in PROVIDER_REGISTRY. Used@@ -1197,28 +1198,37 @@ class QQAdapter(OwnAccessPolicyMixin, BasePlatformAdapter):self._log_tag, Path(src_path).name, Path(wav_path).stat().st_size)return wav_path- def _resolve_stt_config(self) -> Optional[Dict[str, str]]:+ def _resolve_stt_config(self) -> Optional[Dict[str, Any]]:"""Resolve STT backend: ``extra["stt"]`` config first, then ``QQ_STT_*`` env- vars; None when unconfigured (QQ's built-in ASR still works)."""+ vars; None when unconfigured (QQ's built-in ASR still works). ``timeout`` (seconds,+ default 60) follows the shared STT client default so a self-hosted model's cold start+ is not cut off at 30s (#112939)."""stt_cfg = (self.config.extra or {}).get("stt")if isinstance(stt_cfg, dict) and stt_cfg.get("enabled") is not False:base_url = stt_cfg.get("baseUrl") or stt_cfg.get("base_url", "")api_key = stt_cfg.get("apiKey") or stt_cfg.get("api_key", "")model = stt_cfg.get("model", "")+ try:+ timeout = float(stt_cfg.get("timeout", _STT_DEFAULT_TIMEOUT))+ except (TypeError, ValueError):+ timeout = _STT_DEFAULT_TIMEOUTif base_url and api_key:- return {"base_url": base_url.rstrip("/"), "api_key": api_key, "model": model or "whisper-1"}+ return {"base_url": base_url.rstrip("/"), "api_key": api_key, "model": model or "whisper-1",+ "timeout": timeout}if api_key: # provider-only configprovider = stt_cfg.get("provider", "zai")base_url = _STT_PROVIDER_BASE_URLS.get(provider, "")if base_url:default_model = "glm-asr" if provider in {"zai", "glm"} else "whisper-1"- return {"base_url": base_url, "api_key": api_key, "model": model or default_model}+ return {"base_url": base_url, "api_key": api_key, "model": model or default_model,+ "timeout": timeout}qq_stt_key = _resolve_qq_secret("QQ_STT_API_KEY", "")if qq_stt_key:base_url = _resolve_qq_secret("QQ_STT_BASE_URL", _STT_PROVIDER_BASE_URLS["zai"])model = _resolve_qq_secret("QQ_STT_MODEL", "glm-asr")- return {"base_url": base_url.rstrip("/"), "api_key": qq_stt_key, "model": model}+ return {"base_url": base_url.rstrip("/"), "api_key": qq_stt_key, "model": model,+ "timeout": _STT_DEFAULT_TIMEOUT}return Noneasync def _call_stt(self, wav_path: str) -> Optional[str]:@@ -1236,7 +1246,7 @@ class QQAdapter(OwnAccessPolicyMixin, BasePlatformAdapter):headers={"Authorization": f"Bearer {api_key}"},files={"file": (Path(wav_path).name, f, "audio/wav")},data={"model": model},- timeout=30.0)+ timeout=stt_cfg["timeout"])resp.raise_for_status()result = resp.json()# Zhipu/GLM: {"choices": [{"message": {"content": ...}}]}; OpenAI/Whisper: {"text": ...}diff --git a/tests/gateway/test_qqbot.py b/tests/gateway/test_qqbot.pyindex 25b2a475e21..69d77a4d1aa 100644--- a/tests/gateway/test_qqbot.py+++ b/tests/gateway/test_qqbot.py@@ -287,6 +287,15 @@ class TestResolveSTTConfig:with mock.patch.dict(os.environ, {}, clear=True):assert adapter._resolve_stt_config() is None+ def test_timeout_defaults_to_60_and_honours_config(self):+ """The STT request timeout is configurable and no longer a fixed 30s (#112939)."""+ with mock.patch.dict(os.environ, {}, clear=True):+ adapter = self._make_adapter(app_id="a", client_secret="b", stt={"apiKey": "k", "provider": "zai"})+ assert adapter._resolve_stt_config()["timeout"] == 60.0+ adapter = self._make_adapter(app_id="a", client_secret="b",+ stt={"apiKey": "k", "provider": "zai", "timeout": "95"})+ assert adapter._resolve_stt_config()["timeout"] == 95.0+# ---------------------------------------------------------------------------# _detect_message_typediff --git a/tools/transcription_cloud.py b/tools/transcription_cloud.pyindex 5b5598ee4ea..97c87c23f55 100644--- a/tools/transcription_cloud.py+++ b/tools/transcription_cloud.py@@ -37,18 +37,22 @@ def _has_xai_stt_credentials() -> bool:def _with_openai_client(api_key: str, base_url: Optional[str], file_path: str, log_label: str, body):- """Run ``body(client)`` on a fresh, configured OpenAI SDK client; always closed.+ """Run ``body(client)`` on a fresh OpenAI SDK client; always closed. Transport shape comes from+ ``stt.openai.timeout`` / ``stt.openai.max_retries`` (defaults 60s, 1 retry; #112939) for every+ rider of this helper — openai, groq and deepinfra — because a self-hosted endpoint's model cold+ start exceeds the old fixed 30s and lost the voice message at the first attempt.Errors map to the shared envelope. APIConnectionError is checked before APITimeoutError (itssubclass) so timeouts report as connection errors, as they always have."""try:from openai import OpenAI+ from tools.transcription_common import _config_numberfrom tools.transcription_tools import _load_stt_configopenai_config = _get_stt_section(_load_stt_config(), "openai")client = OpenAI(api_key=api_key,base_url=base_url,- timeout=openai_config.get("timeout", 60),- max_retries=openai_config.get("max_retries", 1),+ timeout=_config_number(openai_config, "timeout", 60.0),+ max_retries=_config_number(openai_config, "max_retries", 1, cast=int),)try:return body(client)diff --git a/website/docs/user-guide/configuration.md b/website/docs/user-guide/configuration.mdindex 626dc013c9f..cd9146c8856 100644--- a/website/docs/user-guide/configuration.md+++ b/website/docs/user-guide/configuration.md@@ -2349,11 +2349,15 @@ stt:openai:model: "whisper-1" # whisper-1 | gpt-4o-mini-transcribe | gpt-4o-transcribe | gpt-transcribelanguage: "" # per-provider override of stt.language+ timeout: 60 # seconds per transcription request; raise for self-hosted model cold starts+ max_retries: 1 # SDK transport retries (connection errors, 408/409/429/5xx); 0 = single attempt# model: "whisper-1" # Legacy fallback key still respected```Language resolution is the same for **every** STT provider (local, groq, openai, mistral, xai, elevenlabs, deepinfra, command providers, and plugins): `stt.<provider>.language` → `stt.language` → `HERMES_LOCAL_STT_LANGUAGE` env var → provider auto-detect. **The default is `stt.language: "en"`** — Whisper auto-detection frequently misidentifies short or accented clips, which shows up as voice notes transcribed in the wrong language. Non-English speakers should set `stt.language` to their language code once (e.g. `"es"`, `"zh"`, `"uk"`); set it to `""` to restore auto-detection for multilingual use.+`stt.openai.timeout` and `stt.openai.max_retries` shape the OpenAI-SDK transcription client that the `openai`, `groq` and `deepinfra` providers share (there are no per-provider siblings yet, and the SDK reads no environment variables for these). The defaults are `60` / `1` rather than the previous fixed 30 s / no retries because a self-hosted OpenAI-compatible endpoint can take longer than 30 s to load its model on the first request, which used to lose that voice message outright. The trade-off: an unreachable backend now holds a voice message for up to two attempts × the timeout before Hermes gives up; set `timeout: 30` and `max_retries: 0` for the old shape.+Set `stt.echo_transcripts: false` when the gateway should transcribe voice notes for the agent but must not post the raw transcript back to the chat (for example, customer-facing WhatsApp bots).Provider behavior:diff --git a/website/docs/user-guide/messaging/qqbot.md b/website/docs/user-guide/messaging/qqbot.mdindex e5050b304fc..288522518af 100644--- a/website/docs/user-guide/messaging/qqbot.md+++ b/website/docs/user-guide/messaging/qqbot.md@@ -81,6 +81,7 @@ platforms:baseUrl: "https://open.bigmodel.cn/api/coding/paas/v4"apiKey: "your-stt-key"model: "glm-asr"+ timeout: 60 # seconds per transcription request (default 60)```## Voice Messages (STT)