Repository navigation
fix(listen): don't count cancelled Parakeet sessions as connection_lost - #22372
Merged
Merged
Conversation
A Parakeet window whose pump task listen cancels (owner close, recovery switch, teardown) latches death_reason='cancelled'. That token was not in the bounded live-STT vocabulary, so normalization defaulted it to connection_lost: a provider failure that feeds the STT routing disruption gate and the serving circuit. Add 'cancelled' as a known, censored reason. It now appears as its own label value on the cost-routing observation/settlement counters, the fallback counter and the window session outcome counter, and it moves neither the gate numerator nor its denominator. A pump that ends on its own, POST errors and unknown free-text reasons keep their provider classification. The 0.08 threshold is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…failure Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
3 tasks done
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.
Summary
Since 10-14 the STT routing disruption gate (
STT_ROUTING_DISRUPTION_GATE=0.08) has benched Parakeet for 10–16 h/day. That sends English sessions to Soniox first, at about $75/day. The bench trigger is Parakeet-window failovers counted asconnection_lost. At peak (14–21Z) they went from 2.1% of successes to 10.2%.The suspected mechanism is a reason-vocabulary gap. When listen cancels a Parakeet window's pump task (owner close, recovery switch, teardown), the window latches
death_reason='cancelled'(parakeet_window.py_pumpCancelledError branch and_on_pump_done).cancelledwas not inLIVE_STT_REASONS, sonormalize_live_stt_reasondefaulted it toconnection_lost. That is a provider failure, and it fed both the cost-routing gate and the serving circuit.This PR makes
cancelleda known, censored reason:backend/utils/stt/live_reason.py: adds'cancelled'toLIVE_STT_FAILURE_REASONS.provider_observationalready returnsNone(censored) for every reason outsidePROVIDER_FAILURE_REASONS, so a cancelled failover moves neither the gate's numerator nor its denominator.record_sessionreturns beforetransition. It also does not open the serving circuit (_SERVE_FAILURE_REASONSis unchanged).backend/utils/stt/parakeet_window.py:omi_stt_window_session_outcome_totalnow recordsreason="cancelled"instead ofnonefor a cancelled session. There is also a comment on the cancel branch. The reason flows through the window's bounded rawdeath_reason, whichLiveLegSocket.normalized_death_reason,live_stt_terminal_reasonandPendingLiveFailover.from_socketalready read. It is deliberately not exposed astyped_death_reason: inLiveLegSocket.typed_death_reasona raw typed reason outranks_local_death_reason, so a typedcancelledwould mask a listen-localsend_failedorvad_failedlatched just before the transport was finished. The existing precedent for this channel istest_window_bounded_raw_reason_wins_even_without_typed_proxy.Unchanged (genuine provider-side drops still count): a pump that ends without listen closing or cancelling it is still
connection_lost. POST 5xx, 413, bad JSON and transport exceptions are stillprovider_5xx, and timeouts are stilltimeout. An unknown or free-text reason still defaults toconnection_lost.Metric label split (low cardinality: one new value per existing label set)
reason="cancelled"now appears as its own value on:omi_stt_cost_routing_observations_total{target,outcome="censored",reason="cancelled"}, which is the gate input.omi_stt_cost_routing_settlements_total{target,outcome="censored",reason="cancelled",path}omi_fallback_total{component="stt_live_session",from_mode="parakeet",reason="cancelled",...}omi_stt_window_session_outcome_total{outcome,reason="cancelled"}omi_live_stt_terminal_failures_total(phaseconnection, the same bucket as before)Alert and recording-rule impact
I searched
backend/charts/monitoring/(alerts,alert-rules.json, dashboards). No alert or recording rule selectsreason="connection_lost".omi_stt_window_session_outcome_totalalerts (live-stt.json): the no-text ratio sums overreason, so it is unchanged. Only the label value moves fromnonetocancelled.omi_live_stt_terminal_failures_total{phase=~"connection|send"}rate:cancelledmaps to phaseconnection, so it is unchanged.omi_fallback_totalalerts selectoutcome,to_mode, or specific reasons (capacity_full,gate_unavailable, cache-write reasons). They are unchanged.reason="connection_lost"fortarget="parakeet-window"will drop by the cancelled share. That is the intended correction, and the drop now appears underreason="cancelled".Coordination
#22365 ("perf(listen): close idle Soniox sockets sooner") touches Soniox socket and idle code. This PR touches none of the same files or functions. The only shared module is the reason vocabulary (
live_reason.py), which #22365 does not edit.Product invariants affected
none. This is health attribution and telemetry only. It changes no transcript content, audio custody or client-facing behavior. Failover itself is unchanged; only its classification changes.
Failure class (fixes)
Failure-Class: new
New definition added in this PR:
.github/failure-classes/FC-listen-cancellation-counted-as-provider-failure.json. When listen cancels a live STT leg itself, the leg's death token must be a bounded, censored reason. A token outside the vocabulary defaults toconnection_lostand charges the provider in the routing gate and the serving circuit. No existing class covers this; the closest,FC-rollout-state-counted-as-failover, covers selection state, not death attribution.Tests
backend/tests/unit/test_live_health_reason_reconciliation.py:CASESadds Parakeetcancelled(censored), a free-text unknown (falls back toconnection_lost, provider_failure) and a rawconnection_lost(provider_failure). Each runs across the monitor, send_false and send_exception observers and the recovered, degraded and exhausted settlements.test_listen_cancelled_real_window_is_censored_not_connection_lost[task_cancel|transport_finish]: a realWindowedParakeetSocketis cancelled during an in-flight POST. The leg's reason iscancelled, the failover hop carriescancelled, the censored observation and settlement counters each increment once,window_session_outcome{reason="cancelled"}increments, and the gate state is untouched.test_window_pump_ending_on_its_own_is_still_connection_lost: a provider-side drop still counts against the provider (n == failures == 1).test_cancelled_failovers_cannot_trip_the_disruption_gate: 50% cancelled failovers across 400 distinct users leave the gate at stage 100 withfailures == 0, andncounts only the text sessions. The threshold stays 0.08.test_connection_lost_failovers_still_trip_the_disruption_gate: the same mix withconnection_lostbenches the target.test_unknown_failover_reason_still_counts_against_the_provider[None|free text]: an unknown or missing reason still counts against the provider.cancelledis asserted censored.Local runs (backend
test.sh,nice -n 19):test_live_health_reason_reconciliation.py: 193 passed. With thelive_reason.pychange reverted, 13 of the new and updated cases fail.live_failureorparakeet_windowall pass.Verify in prod after deploy
sum by (outcome, reason) (increase(omi_stt_cost_routing_observations_total{job="backend-listen-metrics",target="parakeet-window",reason=~"cancelled|connection_lost"}[1h])).reason="cancelled"appears asoutcome="censored", andprovider_failure,connection_lostshould fall by about the same amount if the hypothesis holds.sum by (reason) (increase(omi_fallback_total{job="backend-listen-metrics",component="stt_live_session",from_mode=~"parakeet.*"}[1h]))gives the cancelled vs connection_lost split of window failovers.max by (target) (omi_stt_cost_routing_stage{job="backend-listen-metrics",target="parakeet-window"})should stay at 100 through the 14–21Z peak, andomi_stt_cost_routing_decisions_total{reason="cost_primary",target="soniox"}should return toward about 14k/day.no_text(omi_stt_window_session_outcome_total{outcome="no_text"}ratio) does not rise.If
cancelledturns out to be a small share ofconnection_lost, the hypothesis is wrong, and the config fallback (raising the gate to 0.15) stays on the table.Rollback: revert this commit.
🤖 Generated with Claude Code