Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes STT OpenAI audio client resolution so an explicit stt.use_gateway: true preference reliably routes transcription through the managed Nous OpenAI audio gateway rather than being bypassed by any direct credential source.
Changes:
- Updates
_resolve_openai_audio_client_config()to prioritize the managedopenai-audiogateway whenstt.use_gatewayis enabled and to fail closed if the gateway cannot be resolved. - Preserves the legacy direct-first resolution order when
stt.use_gatewayis false/absent. - Adds regression tests covering gateway preference vs config key, local keyless endpoint, env/direct key, real config propagation, and gateway-unavailable behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tools/transcription_tools.py | Reorders OpenAI audio config resolution to honor stt.use_gateway and fail closed when gateway is unavailable. |
| tests/tools/test_transcription_tools.py | Adds regression coverage for gateway preference overriding direct STT credential paths and config propagation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
fix(stt): honor gateway preference over direct credentials
|
|
Thanks @bgrablin — you diagnosed this exactly right, and a week before we got to it. Selecting Nous Subscription STT and then being silently billed against a direct OpenAI key was a real contract violation, and your root-cause analysis (the resolver never consulting the stored gateway intent) was spot on. This landed on main in #90317 (commit 099258e, "route TTS/STT OpenAI audio on the stored selection, not credentials"), which rebuilt both audio resolvers — STT and the TTS twin — around a strict Closing as implemented on main. Appreciate the careful report and fix — sorry the timing overlapped. |
Summary
stt.use_gateway: truenow selects the managed OpenAI audio gateway before every direct credential source. A configured OpenAI key, a local keyless endpoint, or an environment/credential-pool key can no longer silently bypass an explicit Nous Subscription selection.Problem
Selecting Nous Subscription for Speech-to-Text writes:
The repository contract says this flag routes through Nous regardless of direct keys, and the STT provider picker declares
VOICE_TOOLS_OPENAI_KEYandOPENAI_API_KEYas overridden. The runtime resolver did the opposite: it returned the first direct config, local endpoint, or key before attempting the gateway. Users could therefore select managed STT but still send transcription requests to, and be billed by, direct OpenAI.Root cause
_resolve_openai_audio_client_config()used this order:stt.openai.api_keyIt never consulted
stt.use_gatewaybefore accepting the direct paths.Fix
openai-audiothrough the managed gateway first.use_gatewayis false or absent.This is separate from #79754: that PR covers permissive fallback for other tools when a gateway is unavailable and does not modify STT. This change enforces the existing explicit-routing contract for STT.
Validation
HERMES_HOMEconfig propagationstt.use_gateway: trueselectedhttps://openai-audio-gateway.nousresearch.com/v1while direct credentials remained configured.main(1 failure in 5 baseline runs).Compatibility and risk
The behavior change is limited to an explicit
stt.use_gateway: trueopt-in. False/absent configurations retain the previous resolution order. No model-inference routing or non-STT provider behavior changes.Infographic