Skip to content

feat(listen): route hidden English capture by live demand - #21481

Merged
Git-on-my-level merged 14 commits into
BasedHardware:mainfrom
Git-on-my-level:lane/live-demand-routing
Oct 14, 2026
Merged

Git-on-my-level merged 14 commits into
BasedHardware:mainfrom
Git-on-my-level:lane/live-demand-routing

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Eligible English single-language listen sessions start on the existing vendor tail, then move to the Parakeet window leg after stable hidden demand. A visible surface, unknown/mixed client state, or active real-time consumer requires a vendor; existing admission, capture replay, callback fencing and bounded failure recovery remain authoritative.

All controls default off: STT_LIVE_DEMAND_ENABLED=false, STT_LIVE_DEMAND_PERCENT=0, empty STT_LIVE_DEMAND_UID_ALLOWLIST; STT_LIVE_DEMAND_MIN_DWELL_SECONDS=15. Shared authenticated presence covers listen clients across pods. Consumer reads use the app/webhook authorities and mentor's per-user opt-out, paid gate, and actual v2 cohort authority. Candidate admission and a fresh shared-demand check precede retiring the old socket. Capacity refusal keeps the current vendor; degradation pins the session to vendor service. Healthy policy switches preserve transport-failure episode allowances. Dead cheap candidates latch vendor fallback, the coordinator is supervised for the session lifetime, imports fail during startup, and the owning listen/pusher pipeline map is updated.

Metrics: omi_listen_live_lane_seconds_total{lane,reason} (including baseline controls), omi_listen_live_lane_switches_total{from_lane,to_lane,reason}, and shared omi_fallback_total{component="stt_live_session",reason,outcome}. Wall seconds are separate from existing billed/VAD audio counters.

Validation: 53 focused policy, shared-presence Lua, consumer, healthy-switch and replay acceptance tests passed via backend/test.sh; existing Parakeet window (166 tests) and provider-pair replay (27 tests) passed with the documented CI 1.0s CPU ceiling. One existing window case exceeded the local 0.30s CPU ceiling on this host (0.40s); all functional assertions passed. Async blocker scan found zero selected findings; the enforced backend type checker reported zero errors. PR metadata validation passed, including INV-MEM-4 and the receiver line-count exception. Full make preflight passed all 41 selected checks; the 21 existing pusher co-host regression tests also passed. CI initially exposed partial-lifecycle fixture assumptions and an extra flag-off selector keyword; both were corrected, with the original runtime/visibility/translation regression suites rerun. No production calls, writes, merge or deployment.

Rollout belongs to the lead: deploy dark; globally enable presence at 0%, complete all pod/socket draining before any canary; test allowlisted English account and mixed clients/consumer/refusal cases; ramp to at most 5%, then wait at least 12h. Rollback globally disables demand and clears percentage/allowlist through normal listen deployment. Existing GPU gates are unchanged. Runbook: backend/docs/operational/demand-driven-live-stt.md.

INV-MEM-4: capture remains on the existing shared transcript/persistence path; no transcript-of-record or memory promotion authority changes.
Failure-Class: none
Line-Count-Exception: backend/routers/listen/receiver.py | 2480 -> 2510 | Keep receiver-owned initialization, state messages, and adoption/teardown wiring together; policy, shared presence, replay handover and wall metering are separate modules.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T11:46:50.144871Z ff102b1 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8de7df0375

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread backend/routers/listen/demand_switch.py Resolved
Comment thread backend/routers/listen/runtime.py Resolved
Comment thread backend/utils/stt/demand_consumers.py Resolved
Comment thread backend/routers/listen/receiver.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ff102b125e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

try:
await abort_replay_socket(previous)
release_live_stt_socket(previous)
if await receiver._pump_replacement(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Abort cheap replay when demand turns visible

When a hidden-to-Parakeet handover has a nonempty replay prefix, this awaited pump can pace for REPLAY_PREFIX_SECONDS (20 seconds) while holding _stt_failover_lock, and _pump_replacement() only consults delivery_active(). If client_state turns visible after the fresh check and fence, the changed policy cannot interrupt the pump; it still adopts Parakeet and waits for the next reconciliation before dialing a vendor, so newly visible audio can sit behind the full prefix. Abort this policy replay when demand.window_permitted becomes false and enter vendor recovery instead.

Useful? React with 👍 / 👎.

Comment on lines +44 to +46
demand = getattr(getattr(host, 'receiver', None), 'live_demand', None)
if demand is not None and demand.eligible and not demand.window_permitted:
return {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep recovery behind the hidden-demand dwell

Immediately after the first valid hidden report, DemandPolicy.decide() sets window_permitted true; the configured dwell is enforced only later by DemandPolicy.ready(). If the current vendor dies during that dwell, select_live_replacement() calls this helper and receives window_uid, allowing the first configured Parakeet window target to be adopted through ordinary recovery without the dwell or the fresh presence/consumer check. Keep recovery vendor-only until the coordinator has completed the dwell, or apply the same readiness and admission checks in recovery.

Useful? React with 👍 / 👎.

Comment on lines +377 to +380
st.STTService(provider_for_model_token(model))
for model in models
if provider_for_model_token(model) in {'parakeet', 'soniox', 'modulate', 'deepgram'}
),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Map Deepgram tokens to the Deepgram service

When STT_SERVICE_MODELS starts with or consists only of a Deepgram token such as dg-nova-3, provider_for_model_token() returns deepgram_cloud, which is absent from this literal set. A DG-first chain is therefore silently reordered behind the next vendor, while a DG-only chain raises config_incomplete and leaves a visible-demand session on Parakeet. Normalize members of DEEPGRAM_PROVIDERS to STTService.deepgram, as connect_configured_chain() already does.

Useful? React with 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit e0e6534 into BasedHardware:main Oct 14, 2026
49 checks passed
Git-on-my-level added a commit that referenced this pull request Oct 25, 2026
…never drop, the cloud stream (#23610)

* proto: CLOUD_LIVE_STT_MODE policy switch (stream/when_watched/off), local_preview handshake, saved-seconds metrics

Dark foundation for the batch-only cloud transcription proposal. Default
stream reproduces today's behavior exactly; when_watched forces the existing
#21481 live-demand machinery to admit every session (no parallel switch);
off opens no cloud streaming STT session at all while audio is still
received and persisted (the #23388 cap_paused receive/persist shape), with
BYOK custom STT never suppressed. local_preview is a client capability
declaration on /v4/listen. Metrics: omi_cloud_live_stt_mode_sessions_total
and omi_cloud_live_stt_saved_seconds_total.

* feat(listen): mobile local-preview lane for batch-lane users; defer, never drop, the cloud stream

A mobile session that declares local_preview=enabled and whose uid is on the
batch record lane (allowlist or batch percent), with private cloud sync and no
custom STT, is admitted to the local-preview lane: ready and every
mobile_batch_admission renewal carry local_preview=true with
mobile_standard_batch=true, so the client journals all pendant audio through
the lossless mobile Standard batch route and renders its own on-device preview.
Integrations no longer hold these sessions on the live stream (David,
2026-10-25: realtime apps/webhooks degrade).

Listen defers the provider stream instead of dropping it: live segments are
what keep a listen conversation alive and register it for batch, so a session
with audio and no stream loses its transcript. The first socket audio opens
today's stream. CLOUD_LIVE_STT_MODE=off (#23498) now uses the same deferral.

Kill switch LOCAL_PREVIEW_BATCH_ENABLED, on unless set off; no separate ramp.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(listen): start demand routing once a deferred or cap-paused stream actually opens

Luna r1 P2 on #23610: a deferred open that cap admission pauses creates no
socket, and the later cap-recovery re-init never started the demand-routing
task the session skipped. ensure_live_demand_routing() starts it exactly once
whenever a stream exists (session start, deferred open, cap recovery); the
deferred-open counter now counts only opens that produced a socket.

Failure-Class: none

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(listen): label local-preview admission outcomes through the closed reason enum

CI test_reason_label_enums: outcome labels must come from a reasons.py enum via
reason_label(). Adds LocalPreviewOutcome (LIVE_STT family); REASONS derives from it.

Failure-Class: none

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(listen): count a deferred stream once however it opens; document late routing tasks

Luna r2 on #23610: a deferred open that cap admission paused, then cap
recovery opened, was never counted; note_deferred_stream_opened() counts once
from either path. Routing tasks started after supervise() snapshots its set are
tracked and cancelled at teardown but cannot end the session; that fail-soft
behaviour is intended and now documented at the call.

Failure-Class: none

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[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