Repository navigation
feat(stt): close idle Soniox transports behind a default-off flag - #20650
Merged
Merged
Conversation
Git-on-my-level
marked this pull request as ready for review
October 4, 2026 16:53
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Active VAD currently withholds silence but keeps Soniox's paid connection open. Add default-off
SONIOX_IDLE_CLOSE_SECONDS; suggest45for a first canary. Unset/zero returns the original adapter and does not register idle metric series. Positive thresholds below 20s clamp to 20s and warn once per process.SONIOX_IDLE_REARM_SECONDSdefaults to 60s (hard minimum 60s);SONIOX_IDLE_MAX_CLOSES_PER_HOURdefaults to 12 closes per rolling hour. A listen-session-owned budget survives provider leg replacement in both connector paths. Rate-limited closes leave the active transport serving audio and keepalive normally.After continuous VAD silence, finalize and drain the old socket for at most two seconds, then close/abort its transport while retaining the logical provider leg. The next VAD onset retains original PCM pre-roll, waits for the old callback drain, opens the same captured endpoint/config through the shared Soniox connector, and sends pre-roll before onset. A real failed reopen enters ordinary connect/failover handling; retained onset queues behind recovery replay with already accepted capture prefixes excluded. Planned closes publish no death, breaker/quarantine strike, fallback or cost-router failure evidence. Genuine account/config errors still propagate.
Rebase each socket's restarted provider clock onto the existing accepted-audio ledger, including Soniox elapsed-axis mode, then use the existing wall/capture projection. Socket epochs reset provider-local speaker IDs. Shutdown while suspended finishes normally without reopening. Five unlabeled metrics measure closes, reopens, reopen latency, failures and estimated connected seconds avoided.
Billing scope: Soniox explicitly bills the full stream, including keepalive-only idle time (docs). Deepgram streaming STT is billed by processed audio duration (official answer); keepalive control frames contain no audio (docs), so audio-free socket idle should not be billed as processed audio (inference from those sources). Modulate lists processed-audio-hour pricing (pricing); a keepalive-only billing guarantee is not documented there. Sent silence is still processed audio. Leave both adapters unchanged.
Validation: 918 focused fast tests pass through
backend/test.shon the synchronized branch, including 54 idle lifecycle cases, 149 runtime-env cases and 129 connector/rejection/rate-limit/recovery cases. The canonical runtime-env fixture also passes separately with the unchanged CPU guard. New regressions exercise 120 alternating threshold/onset cycles with recovery on/off and default/custom hourly caps, exact cooldown/rolling-hour expiry, session budget continuity across socket replacement, safe config parsing and one-time floor warning. Unset/zero parity snapshots the real default Prometheus registry with cold and already-registered idle metrics, asserting identical global series and unchanged idle samples. Legacy connector fixtures assert the receiver budget is passed through both normal and same-provider dials. Typecheck: 0 errors. Local preflight and all normal exact-head push gates passed. Exact-head CI results are available in the PR checks. A repeated CI timing failure in the unchanged containment detector required a one-line dictionary field-read fast path, retaining the generic Mapping/object fallback. All 162 containment tests pass, including new non-dict Mapping parity, with the original 0.30s limit unchanged. Seven local trials of six maximum-layout decisions reduced median CPU from 102ms to 41ms. Recent main changes are incorporated; both concurrent pipeline documentation sections are preserved. Luna's P2 findings are addressed; no new review verdict is claimed.Local fake-mode soak uses draft #20477's preserved harness on throwaway branch
soak/soniox-idle-close-round2, with all 16 changed production Python files byte-identical to execution head049ede6e3f5f9b12385bf6a63896485ae77d454e; the final STT implementation is unchanged by the later containment lookup optimization (the fake harness is isolated from the production tree). Two sessions per arm, 129s each, 6s public speech / 60s silence, 45s threshold, 60s rearm and default 12/hour cap. Scrubbed environment; local Firestore/Redis emulators; ADC unavailable. Every manually launched process, service and metrics probe records its PID in.local/owned-pids.txt; all owned service PIDs were reaped. No provider fault is injected.Reopen failures: 0. Onset byte hashes matched 2/2 per enabled arm. Flag-off emitted no idle series. The avoided counters read 43.35s / 42.24s; independent arm scheduling accounts for small differences versus measured socket lifetime. Cooldown reduces closes from four in the historical round-one run to two in each current enabled arm. The generic recovery gate remains
REVIEW_REQUIREDbecause there is no fault injection; the requested idle assertions pass. Count-only receipts:.local/round2-synced-soak-summary.json, with raw metrics, isolation and cleanup receipts in the three arm directories. No live Soniox or acoustic acceptance is claimed.CI: head
475ac229d16bd73ca91facca35e60fe17f79305f: exact-head checks; flag-off keeps its original wire path. Draft only; no merge or deployment. Fake dial latency is not real Soniox handshake latency or acoustic acceptance.Product invariants affected: none
Failure-Class: none
Additive, default-off cost optimization; existing failure contracts remain authoritative.
Line-Count-Exception: backend/routers/listen/receiver.py | 2398 -> 2402 | Add session-owned Soniox churn budget and pass it through the two legacy connection paths so provider leg replacement cannot reset the rolling hourly cap.