fix(stt): surface the selection-specific error for explicit openai STT - #93052
liuhao1024 wants to merge 1 commit into
Conversation
When the managed openai-audio gateway is unavailable, _resolve_openai_audio_client_config() raises a ValueError that names the blocker (and, for managed-Nous users, the `hermes tools` remediation). The boolean probe in _get_provider's explicit-openai branch flattened that into False, so the log claimed "no API key available" and the transcription result returned the all-provider install hint -- pointing operators at unrelated setup instead of their managed route (NousResearch#93045). Resolve the config directly in the branch so the warning names the real blocker, and let the dispatch's "none" fallback surface the selection-specific error for an explicit openai choice. No fallback is added: an unavailable selection still resolves to "none", it just reports why.
Correct diagnosis: flattening
The negative test asserting auto-detection keeps the generic all-provider hint shows good boundary discipline. |
|
Merged via #93356 (rebase) — your commit is on main with authorship preserved. |
What does this PR do?
Makes an explicit
stt.provider: openaiselection report its real blocker instead of generic setup guidance. When the managedopenai-audiogateway is unavailable,_resolve_openai_audio_client_config()already raises aValueErrorthat names the blocker and — for managed-Nous users — appends thehermes toolsremediation. But the explicit-openai branch of_get_provider()checked availability through the boolean_has_openai_audio_backend()probe, which flattens thatValueErrorintoFalse. The log then claimed "STT provider 'openai' configured but no API key available" and the transcription result fell through to the all-provider "No STT provider available. Install faster-whisper … set GROQ_API_KEY …" hint — directing operators toward unrelated provider setup when their managed route is what's down.Two changes, both in the explicit-selection path (auto-detect is untouched):
_get_provider()resolves_resolve_openai_audio_client_config()directly (same gate:_HAS_OPENAI+ the resolver succeeding ≡ the old probe), so the warning names the actual blocker instead of a bare API-key hint._dispatch_stt_provider()'s "none" fallback re-resolves the config when the config explicitly choseopenaiand returns itsValueErrormessage as the transcription error. The generic all-provider hint remains the answer for auto-detect with no credentials.No fallback is added — an unavailable selection still resolves to
none; it just says why.Related Issue
Fixes #93045
Type of Change
Changes Made
tools/transcription_tools.py_get_provider()explicitopenaibranch: replace the_has_openai_audio_backend()probe with a direct_resolve_openai_audio_client_config()call in a try/except so the warning carries the selection-specific message (comment names the probe-flattening mechanism)_dispatch_stt_provider()"No provider available" fallback: when the config explicitly choseopenaiand the package is present, re-resolve and return the selection-specific error dict instead of the all-provider install hint (comment marks the explicit-choice-only guard)tests/tools/test_transcription_tools.pyTestExplicitOpenaiSelectionErrorclass:_get_providernames the managed-route blocker (and not "no API key") when the managed gateway is down; the dispatch result carries thehermes toolsremediation (and not the generic hint) for an explicit openai choice; auto-detect with no credentials still gets the generic hint (guard against over-firing)How to Test
.venv/bin python -m pytest tests/tools/test_transcription_tools.py -qtools/transcription_tools.pymakes exactly the two selection-specific tests fail (2 failed, 1 passed), confirming they pin the new reporting.stt.provider: openai, clearVOICE_TOOLS_OPENAI_KEY/OPENAI_API_KEY, and disable the managedopenai-audiogateway — a transcription call now returns the selection-specific error naming the managed route (with thehermes toolsremediation for managed-Nous users) instead of "No STT provider available. Install faster-whisper …".Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests pass (full transcription suite; 4 failures reproduce identically on unmodified main — environment deps, not this diff)Documentation & Housekeeping
docs/, docstrings) — or N/A (inline comments name the mechanism)cli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/A