Skip to content

The agent that grows with you

fix(tools): null-safe Groq STT config read

Mate Remias13b52e0fa329
diff --git a/tests/tools/test_transcription_tools.py b/tests/tools/test_transcription_tools.py
index 0dbebda66b8..1674e0383aa 100644
--- a/tests/tools/test_transcription_tools.py
+++ b/tests/tools/test_transcription_tools.py
@@ -400,6 +400,27 @@ class TestTranscribeGroq:
kwargs = mock_client.audio.transcriptions.create.call_args.kwargs
assert "language" not in kwargs
+ def test_null_groq_subsection_is_safe(self, monkeypatch, sample_wav):
+ """`stt.groq: null` in YAML yields None; must not raise, auto-detect stays intact."""
+ monkeypatch.setenv("GROQ_API_KEY", "gsk-test")
+ monkeypatch.delenv("HERMES_LOCAL_STT_LANGUAGE", raising=False)
+
+ mock_client = MagicMock()
+ mock_client.audio.transcriptions.create.return_value = "hi"
+
+ with patch("tools.transcription_tools._HAS_OPENAI", True), \
+ patch("openai.OpenAI", return_value=mock_client), \
+ patch(
+ "tools.transcription_tools._load_stt_config",
+ return_value={"groq": None},
+ ):
+ from tools.transcription_tools import _transcribe_groq
+ result = _transcribe_groq(sample_wav, "whisper-large-v3-turbo")
+
+ assert result["success"] is True
+ kwargs = mock_client.audio.transcriptions.create.call_args.kwargs
+ assert "language" not in kwargs
+
# ============================================================================
# _transcribe_openai — additional tests
diff --git a/tools/transcription_tools.py b/tools/transcription_tools.py
index 1a724eda55c..25bb458fde8 100644
--- a/tools/transcription_tools.py
+++ b/tools/transcription_tools.py
@@ -1320,7 +1320,7 @@ def _transcribe_groq(file_path: str, model_name: str) -> Dict[str, Any]:
logger.info("Model %s not available on Groq, using %s", model_name, DEFAULT_GROQ_STT_MODEL)
model_name = DEFAULT_GROQ_STT_MODEL
- groq_cfg = _load_stt_config().get("groq", {})
+ groq_cfg = _load_stt_config().get("groq") or {}
language = str(
groq_cfg.get("language") or os.getenv(LOCAL_STT_LANGUAGE_ENV) or ""
).strip() or None