Skip to content

SCA-1972: fix(batch): skip the vendor for provider units with under 2 s of speech - #25192

Merged
Git-on-my-level merged 9 commits into
mainfrom
lane/provider-min-speech
Nov 14, 2026
Merged

Git-on-my-level merged 9 commits into
mainfrom
lane/provider-min-speech

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

What

A provider-route batch unit whose strict-VAD speech is under 2 s is now answered as local silence, with no vendor call. Before this change, only a unit with no speech spans at all skipped the vendor. The threshold is BATCH_VENDOR_MIN_SPEECH_SECONDS: default 2, and 0 restores the old no-spans-only rule.

Why

David, 2026-11-13: process user recordings economically; skipping very short ones is fine.

Provider units are ~31 s capture spans, and each is billed for its full duration even when VAD found a second of speech. Production sample (2026-11-13 ~10:30Z, ro-prod, metadata only):

  • 2,966 settled result_ready provider-route units; 1,345 had no speech and were already skipped.
  • Share of billed provider audio by measured speech: under 1 s 20%, 1–2 s 6%, 2–3 s 3.6%, 3–5 s 7.6%, 5–10 s 15.4%, 10 s or more 47.5%.
  • So units under 2 s are 26% of billed provider audio. Provider STT runs at about $155–190/day (KB daily-cost-current, 11-05..11-09), so this saves about $40–50/day on fresh input, plus the same share of the provider backlog still to drain.
  • Content lost per skipped unit: under 2 s of speech in a 31 s span, a word or two at most. On 11-02 most empty_asr quarantines were exactly these sub-2 s units, so vendors often return nothing for them anyway.

Change

  • config/batch_pipeline_vendor_failover.py: min_speech_seconds() reads BATCH_VENDOR_MIN_SPEECH_SECONDS. Default 2, range 0–10; malformed or out-of-range values keep 2.
  • utils/batch_pipeline/provider_stt.py: _skips_vendor(inspected) is decided once in _prepare and carried on _Call.skip_vendor. The health arm, the intent's vendor_skipped, _call_sync and _call_async all use it. The skip reuses the existing local-silence path end to end: silence_payload, outcome silence, audio_seconds=0, normal settle and merge. No new state, and no change to the merge, projection, custody or privacy fences.
  • The intent keeps measured_vad_speech_seconds > 0 next to vendor_skipped: true, so a short-speech skip stays distinguishable from true silence. The abandoned-intent reconcile already settles vendor_skipped intents as silence without billing.
  • New counter omi_batch_pipeline_vendor_short_speech_skipped_audio_seconds_total{provider} measures the unbilled audio (frozen-name pin 18 → 19). It counts on the direct path and on the abandoned-intent silence reconcile.
  • The flag registry, flag_budget.json and the rendered registry doc are updated.
  • Tests:
    • short speech skips the vendor, is marked, and is counted;
    • threshold 0 restores the old rule;
    • malformed values keep the default;
    • exactly 2.0 s still calls the vendor.
    • The shared SPEECH fixtures widened from 0.5 s to 2.5 s so existing paid-path tests keep exercising the vendor.

Not in scope

  • The GPU route: GPU cost is fixed node time (mostly idle), so skipping there saves nothing.
  • Age-based skipping of old backlog: measured separately and reported to David.
  • The provider merge fix: that is fix(batch): provider-route units join the ordered merge #25187, owned by the provider-STT design session. This branch is rebased on it.
  • Allowance runs before VAD in _prepare, so a unit held for allowance is deferred before the skip can apply. That ordering already applies to true silence and is unchanged here; moving VAD ahead of allowance is a separate design question.

Review

Luna (gpt-6-luna, read-only) on the first commit: P1 conformance test still expected a vendor call for 1 s of speech (fixed: span widened); P2 reconcile path did not count skips (fixed, with a test); P1 allowance-before-VAD (pre-existing for silence, left as noted above).

Rollout

  • Ships on.
  • Rollback: set BATCH_VENDOR_MIN_SPEECH_SECONDS=0 on backend-integration (where the provider stage serves). Units already skipped keep their silence result.
  • Watch:
    • omi_batch_pipeline_vendor_short_speech_skipped_audio_seconds_total should be about 26% of billed provider audio;
    • omi_batch_pipeline_vendor_attempt_audio_seconds_total{outcome="ok"} should fall by that share;
    • silence share of provider results should rise from about 43% to about 55% of units.
  • Must stay flat: provider settle rate and merge commit rate.
  • Verification layer: local unit tests only. No production read of the new metric yet.

Landing verification

The provider merge emulator fixture now uses 2.5 seconds of strict-VAD speech so it continues to exercise the paid vendor path under the new default. The nojob emulator's repeat-sweep assertion compares selected row identities because a new sweep recomputes ages against wall time; its minimum-age assertions remain. Main's additional flags are preserved in the ledger count.

Failure-Class: none

🤖 Generated with Claude Code

View guided diff Turn on auto-fix

Git-on-my-level and others added 3 commits November 13, 2026 18:23
A provider-route unit is billed for its whole ~31 s span. Units with under
2 s of strict-VAD speech were 26% of billed provider audio on 2026-11-13.
They now take the existing local-silence path. BATCH_VENDOR_MIN_SPEECH_SECONDS
(default 2, 0 restores the no-spans-only rule) sets the threshold, and
omi_batch_pipeline_vendor_short_speech_skipped_audio_seconds_total counts
the unbilled audio.

Failure-Class: none

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…and recovery tests out of the skip

Failure-Class: none

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…conformance speech span

Luna review r1 on the short-speech skip: the abandoned-intent silence path
now counts skipped audio when the intent measured speech, and the provider
conformance test supplies 2.5 s of speech so it still exercises the vendor.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T11:43:32.187003Z 27e139a 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.

Resolve provider_stt _Call against SCA-1750 allowance_period (keep both
fields, pass by keyword) and raise the flag budget count to 274.

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

@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: fb6163a3af

ℹ️ 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".

HELD_STALE_GRACE_SECONDS_MAX,
)


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 Document the changed transcription boundary in the pipeline notes

This changes the default transcription behavior from skipping only silence to discarding units containing up to two seconds of detected speech, but the commit adds no pipeline change note. backend/AGENTS.md explicitly requires a note for transcription changes. A repository search of backend/docs/listen_pusher_pipeline* also found no documentation of BATCH_VENDOR_MIN_SPEECH_SECONDS. Add the required note describing the intentional content loss, rollout, and rollback, and document the new environment/default contract in the pipeline reference. The feature-flag registry alone does not satisfy this requirement.

AGENTS.md reference: backend/AGENTS.md:L164-L164

Useful? React with 👍 / 👎.

Comment on lines +1020 to +1021
if plan.skip_vendor and plan.inspected and plan.inspected[2]:
vendor_metrics.short_speech_skip(plan.service, duration)

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 Count short-speech skips when reconciling a persisted result

If persisting a short-speech silence result succeeds but the subsequent settle fails, _finish returns a retry before incrementing this counter. On redelivery, _reconcile finds the saved URI and settles through its first branch, which records only late-result and overflow metrics; it never calls short_speech_skip. The new call in _settle_skipped_silence covers only cases with no saved result, so these successfully skipped units are permanently absent from the savings metric. Increment the counter after a successful saved-result reconciliation when the intent identifies a short-speech skip.

Useful? React with 👍 / 👎.

Git-on-my-level and others added 2 commits November 14, 2026 07:13
…he pipeline note

REVIEW finding 1: add docs/listen_pusher_pipeline/changes/2026-11-13-provider-min-speech.md.
backend/AGENTS.md requires a note for transcription changes, and this one intentionally
discards up to 2 s of speech per unit; the flag registry alone does not record it.

REVIEW finding 2: _reconcile's saved-result branch now counts the unbilled audio in
omi_batch_pipeline_vendor_short_speech_skipped_audio_seconds_total when a persisted
short-speech silence settles late, the third path a skip can take, with a test that
fails without the increment.

Also makes the _finish guard require the silence outcome explicitly (non-blocking note).

Failure-Class: none

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Git-on-my-level Git-on-my-level changed the title fix(batch): skip the vendor for provider units with under 2 s of speech SCA-1972: fix(batch): skip the vendor for provider units with under 2 s of speech Nov 14, 2026
@Git-on-my-level
Git-on-my-level merged commit 0d38aa2 into main Nov 14, 2026
71 of 73 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/provider-min-speech branch November 14, 2026 14:56
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