Skip to content

feat(backend): alert on live-STT chain exhaustion and conversation fragmentation - #15189

Merged
Git-on-my-level merged 1 commit into
mainfrom
feat/stt-exhaustion-and-fragmentation-alerts
Sep 20, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
feat/stt-exhaustion-and-fragmentation-alerts

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Sep 20, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Page when the live-STT provider chain is exhausted for most /v4/listen sessions, and warn at the standing 16–25% baseline. The 2026-09-19 outage died in initialize_stt() before a LiveSTTAttempt existed, so omi_live_stt_terminal_total{outcome="failure"} / omi_live_stt_accepted_total stayed green while 82–89% of accepts exhausted.
  • Close that blind spot: a pre-audio terminal now increments omi_live_stt_accepted_total and omi_live_stt_terminal_total{outcome="failure",phase="initialization"} without constructing a LiveSTTAttempt (no product analytics for a transcript that never started).
  • Make conversation fragmentation visible regardless of cause: ingest_sync_conversation records omi_sync_intake_total{outcome="created|merged"} and logs omi_sync_intake outcome=…. The alert evaluates Cloud Logging because Cloud Run backend-sync is not in the metrics exporter allowlist (backend + desktop-backend only). Assignment continuity stays in fix/sync-capture-continuity.
  • Warn when a fallback to_mode recovers zero of ≥50 stt_selection attempts in 6h (Deepgram has been in this state since 2026-09-14). Panels 15–17 on Resilience / Fallbacks.

What already existed vs what this PR adds

Already on origin/main:

  • omi_fallback_total / omi_fallback_event with component="stt_selection" and outcome="exhausted|recovered"
  • omi_listen_accepted_total at WebSocket accept (job=backend-listen-metrics Counter)
  • omi-journey-live-transcription-fail at 10% of omi_live_stt_* (structurally blind to initialize_stt() deaths)
  • Parakeet capacity / CUDA / ready-pod-no-success alerts; no Deepgram-leg 100%-fail-for-hours alert
  • Sync enqueue-uncertainty panel with the documented scrape gap; no created-vs-merged intake signal

Added:

  • omi-stt-chain-exhausted-warn (0.35 / 10m / warning) and omi-stt-chain-exhausted-page (0.60 / 5m / critical)
  • record_live_stt_pre_audio_failure on terminate_live_stt_session when no LiveSTTAttempt exists
  • omi-stt-fallback-leg-dead (warning)
  • omi_sync_intake_total + omi-sync-intake-fragmented (Cloud Logging)
  • Dashboard panels 15–17

Failure-Class

Failure-Class: FC-alert-never-provably-fired

New rules pin job="backend-listen-metrics" and use increase() on Prometheus Counters (not Stackdriver gauges). Each rule records evaluated_bad / evaluated_good in its own annotations.

Invariants

none — scripts/pr-preflight --suggest reported no product-invariant path glob matches. Merge base is current origin/main.

Evidence (Cloud Logging, project based-hardware, backend-listen)

Evidence layer is gcloud logging read counts of omi_fallback_event component=stt_selection outcome=exhausted, divided by the measured 2-minute /v4/listen accept samples. Prometheus/Grafana read-only was not reachable from this agent; exact increase() evaluation is still owed.

window (UTC) accepts exhausted ratio warn 0.35 page 0.60
2026-09-18 09:00 (tolerable) 227 57 0.251 no no
2026-09-19 04:40 (incident) 688 562 0.817 yes yes
2026-09-19 09:30 (incident) 913 811 0.888 yes yes
2026-09-20 14:30 (recovered) 347 57 0.164 no no

5m exhausted counts: tolerable 135, recovered 163, incident 1376. ~1 exhausted event per exhausted session (22 to=parakeet of 562 at 04:40Z).

Provider-leg (omi-stt-fallback-leg-dead): Deepgram outcome=recovered = 0 in the 2026-09-18 09:00Z 5m window, the 2026-09-19 04:40Z 5m window, and the 2026-09-19 04:40–10:40Z 6h window; exhausted-to-deepgram hit the 20000 query cap in that 6h. This is why the alert is warning, not a page — the leg has been dead through both good and bad periods.

Fragmentation (omi-sync-intake-fragmented): brand-new series, no production history. Expected created share ~1.0 in a per-chunk storm (107 shards / 121 conversations for one account on 2026-09-19) versus 1/N for an N-chunk continuous recording. Fleet-wide created/merged is unmeasured; 0.80 with ≥100 created / 30m is a provisional gap.

Prometheus evaluation still owed

Whoever can query prod Prometheus/Grafana read-only should evaluate these exact expressions over 2026-09-19 04:40–16:00Z (bad) and 2026-09-18 09:00Z / 2026-09-20 14:30Z (good) and replace the log-derived annotation numbers if they differ:

  1. sum(increase(omi_fallback_total{job="backend-listen-metrics",component="stt_selection",outcome="exhausted"}[5m])) / clamp_min(sum(increase(omi_listen_accepted_total{job="backend-listen-metrics"}[5m])), 1)
  2. sum by (to_mode) (increase(omi_fallback_total{job="backend-listen-metrics",component="stt_selection",outcome="recovered"}[6h])) vs attempts, especially to_mode=deepgram
  3. omi_sync_intake_total after deploy (no history today); Cloud Logging omi_sync_intake outcome= after the first backend-sync revision that emits it

Owner: whoever has Grafana monitor.omi.me read access (platform / on-call). This agent must not.

Test plan

  • BACKEND_UNIT_TEST_FILE_LIST + bash backend/test.sh on Python 3.11.15 uv venv: test_transcription_outcomes.py, test_live_stt_failure.py, test_conversation_lifecycle_contract.py, test_monitoring_alert_rule_contract.py, test_journey_observability.py, test_fallback_observability.py
  • Grafana provision of the four new UIDs (split alerts/*.json + combined alert-rules.json)
  • After deploy: confirm omi_fallback_event ratio on panel 15 during a real listen session; confirm omi_sync_intake log lines on backend-sync

🤖 Generated with Claude Code

Review in cubic

…agmentation

The 2026-09-19 outage died in initialize_stt() before LiveSTTAttempt existed, so the live-STT failure-ratio alert stayed green. Watch exhausted fallbacks over listen accepts, close that blind spot, and surface sync created-vs-merged.

Co-authored-by: Cursor <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit 16fc207 into main Sep 20, 2026
62 of 70 checks passed
@Git-on-my-level
Git-on-my-level deleted the feat/stt-exhaustion-and-fragmentation-alerts branch September 20, 2026 16:38
Git-on-my-level added a commit that referenced this pull request Sep 20, 2026
…T chain

Independent review (Cursor Grok) plus coordinator findings, all behind the same dark flags:
- 18 s window buffer; sustained overload sheds with capacity_full and opens the pod's
  Parakeet circuit instead of killing sessions that still get 200s.
- Last-resort dialing never bypasses an account-state cooldown and never forces a
  shedding TDT leg.
- Fail-closed/forced-active VAD only for the windowed leg; other legs on the configured
  chain keep today's fail-open gate and honour VAD_GATE_MODE / client override.
- Excluded session shapes drop only the parakeet-window token.
- Non-terminal leg skips/failures emit degraded + leg-attempt metric; exhausted is
  emitted once per terminal chain so the #15189 pages stay truthful with the flag on.
- Remove the init-terminal critical rule (it would fire immediately in today's prod).
- Drain releases admission at once; malformed 200/413/semaphore-queue timeouts are
  session-local; only 5xx/acquired-POST timeouts feed the serve-error circuit.
- Pass window_uid only when the managed chain is on (legacy selector call shape while dark).
- Incident-history docstrings moved into utils/stt/ARCHITECTURE.md.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Git-on-my-level added a commit that referenced this pull request Sep 20, 2026
…n STT connect chain with a Soniox leg (dark in prod) (#15234)

* feat(backend): rampable windowed Parakeet TDT live leg, config-driven STT connect chain with a Soniox leg, per-leg breakers

Everything is dark unless STT_CONNECT_ORDER_FROM_CONFIG=true and
PARAKEET_WINDOW_ALLOCATION_PERCENT>0; prod values keep both off, dev turns them on.

- Connect-time fallback order derives from STT_SERVICE_MODELS, adds a Soniox leg,
  passes every leg from every primary branch, never re-walks a failed provider.
- New `parakeet-window` streaming token: bounded 6 s windows over /v1/transcribe
  (TDT 0.6b v3) behind a fail-closed VAD gate, eligible on the user's requested
  base language, with stable per-uid allocation, a process session cap, one
  in-flight POST per session and clean overflow to the next leg.
- Leg-level circuit breakers, long account-state cooldown (Deepgram 401/402/403,
  Soniox budget exhaustion), bounded half-open probes, last-resort primary dial.
- Live-STT metrics and Grafana rules; stt_live_session/connection_lost join the
  bounded fallback vocabulary.

Implemented by Codex gpt-6-astra from a coordinator plan; verified by re-running the
21-file unit selection (exit 0) outside its sandbox.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* fix(backend): review fixes for the windowed TDT leg and configured STT chain

Independent review (Cursor Grok) plus coordinator findings, all behind the same dark flags:
- 18 s window buffer; sustained overload sheds with capacity_full and opens the pod's
  Parakeet circuit instead of killing sessions that still get 200s.
- Last-resort dialing never bypasses an account-state cooldown and never forces a
  shedding TDT leg.
- Fail-closed/forced-active VAD only for the windowed leg; other legs on the configured
  chain keep today's fail-open gate and honour VAD_GATE_MODE / client override.
- Excluded session shapes drop only the parakeet-window token.
- Non-terminal leg skips/failures emit degraded + leg-attempt metric; exhausted is
  emitted once per terminal chain so the #15189 pages stay truthful with the flag on.
- Remove the init-terminal critical rule (it would fire immediately in today's prod).
- Drain releases admission at once; malformed 200/413/semaphore-queue timeouts are
  session-local; only 5xx/acquired-POST timeouts feed the serve-error circuit.
- Pass window_uid only when the managed chain is on (legacy selector call shape while dark).
- Incident-history docstrings moved into utils/stt/ARCHITECTURE.md.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* fix(backend): type the managed-session selector kwargs

A bare dict spread into get_stt_service_for_language fails pyright; a TypedDict helper
keeps the legacy call shape while the configured chain is dark.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant