Repository navigation
fix(backend): let custom-STT users get summaries again - #12663
Merged
Merged
Conversation
Revert the Omi-paid LLM post-processing gate from #7690 (commit 3c998bf). Custom-STT users bring their own STT key, and the gate skipped ALL LLM enrichment for their conversations unless they ALSO carried an LLM BYOK key: no title, no overview, no memories, no action items, no app results. Bringing an STT key is not a request to lose summaries, and almost nobody carries a second OpenAI/Anthropic key, so in practice the gate silently turned summarization off for every custom-STT user. Removed: - the process_conversation gate and its deferred BYOK lookup - the live-session photo gate that stored "Custom STT: photo description skipped" instead of calling describe_image - should_skip_custom_stt_postprocessing, now unreferenced Kept: the durable Conversation.uses_custom_stt marker and its creation/resume/merge plumbing. It is provenance only now — it keeps custom-STT spend queryable and feeds the isolated fair-use lane (#10127) — so the API contract and generated clients are unchanged. Comments that described it as a cost gate were corrected to say so. Tests invert the two gate assertions into regression tests: a custom-STT conversation with no LLM BYOK key must run structuring, and a custom-STT photo must reach describe_image. The now-moot "hot path never reads BYOK state" deferral tests are dropped with the deferral. Verification: cd backend && pytest tests/unit/<file>.py # one file at a time test_process_conversation_usage_context.py 53 passed test_listen_multichannel_mix_buffer_leak.py 5 passed test_transcribe_decisions.py 25 passed test_listen_process_pending_shutdown.py 13 passed test_merge_audio_chunk_copy_failure.py 5 passed test_shared_conversation_field_exposure.py 8 passed test_byok_security_enrollment.py 34 passed test_new_usage_tracking_gaps.py 45 passed Failure-Class: none
There was a problem hiding this comment.
1 issue found across 12 files
Confidence score: 5/5
- In
backend/tests/unit/test_process_conversation_usage_context.py, theis_byok_activemonkeypatches no longer affect execution because the reverted gate removed the only caller; remove the dead patches to keep the tests accurate and maintainable.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="backend/tests/unit/test_process_conversation_usage_context.py">
<violation number="1" location="backend/tests/unit/test_process_conversation_usage_context.py:1923">
P3: These `is_byok_active` monkeypatches are now dead: the reverted gate was the only caller of `users_db.is_byok_active` in `process_conversation`, so they no longer influence the tests. Remove the `is_byok_active` monkeypatch from both custom-STT tests (and drop the now-misleading 'No LLM BYOK key' comment in the first) so the tests reflect that enrichment runs unconditionally.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| monkeypatch.setattr(process_conversation, 'trigger_conversation_apps', lambda *a, **k: None) | ||
| # No LLM BYOK key on this request, so Omi would pay — the gate must fire. | ||
| monkeypatch.setattr(process_conversation, 'submit_with_context', MagicMock()) | ||
| # No LLM BYOK key: enrichment must run anyway, on Omi's bill. |
There was a problem hiding this comment.
P3: These is_byok_active monkeypatches are now dead: the reverted gate was the only caller of users_db.is_byok_active in process_conversation, so they no longer influence the tests. Remove the is_byok_active monkeypatch from both custom-STT tests (and drop the now-misleading 'No LLM BYOK key' comment in the first) so the tests reflect that enrichment runs unconditionally.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/tests/unit/test_process_conversation_usage_context.py, line 1923:
<comment>These `is_byok_active` monkeypatches are now dead: the reverted gate was the only caller of `users_db.is_byok_active` in `process_conversation`, so they no longer influence the tests. Remove the `is_byok_active` monkeypatch from both custom-STT tests (and drop the now-misleading 'No LLM BYOK key' comment in the first) so the tests reflect that enrichment runs unconditionally.</comment>
<file context>
@@ -1917,32 +1919,17 @@ def test_custom_stt_conversation_without_llm_byok_key_skips_llm_work(monkeypatch
monkeypatch.setattr(process_conversation, 'trigger_conversation_apps', lambda *a, **k: None)
- # No LLM BYOK key on this request, so Omi would pay — the gate must fire.
+ monkeypatch.setattr(process_conversation, 'submit_with_context', MagicMock())
+ # No LLM BYOK key: enrichment must run anyway, on Omi's bill.
monkeypatch.setattr(process_conversation.users_db, 'is_byok_active', lambda _uid: False)
- monkeypatch.setattr(process_conversation, 'request_has_llm_byok_key', lambda: False)
</file context>
cursor Bot
pushed a commit
to apoorvdarshan/omi
that referenced
this pull request
Sep 18, 2026
…TT-credit bypass Custom-STT still skips has_transcription_credits at listen connect and never records transcription_seconds. After BasedHardware#12663 reverted the BasedHardware#10962 blanket LLM skip, those sessions had no processing budget. Cap Omi-paid structuring / summary / memory against the catalog listening allowance read from speech_seconds. Paid unlimited and LLM BYOK stay allowed; lookup errors fail open so a Firestore blip cannot strip summaries. Failure-Class: none Verification: - backend/.venv/bin/python -m pytest -q tests/unit/test_custom_stt_llm_processing_gate.py tests/unit/test_listen_runtime_regressions.py tests/unit/test_process_conversation_usage_context.py tests/unit/test_process_conversation_free_tier_branch.py tests/unit/test_client_processing_acceptance.py tests/unit/test_client_processing_finalize.py tests/unit/test_free_tier_entrypoint_matrix.py tests/unit/test_fair_use_engine.py tests/unit/test_fair_use_plan_aware.py tests/unit/test_subscription_plans.py - 491 passed - Did not exercise a live custom-STT listen session Co-authored-by: Apoorv Darshan <[email protected]>
kodjima33
pushed a commit
that referenced
this pull request
Sep 19, 2026
…TT-credit bypass (#14300) * fix(backend): meter custom-STT LLM post-processing without skipping STT-credit bypass Custom-STT still skips has_transcription_credits at listen connect and never records transcription_seconds. After #12663 reverted the #10962 blanket LLM skip, those sessions had no processing budget. Cap Omi-paid structuring / summary / memory against the catalog listening allowance read from speech_seconds. Paid unlimited and LLM BYOK stay allowed; lookup errors fail open so a Firestore blip cannot strip summaries. Failure-Class: none Verification: - backend/.venv/bin/python -m pytest -q tests/unit/test_custom_stt_llm_processing_gate.py tests/unit/test_listen_runtime_regressions.py tests/unit/test_process_conversation_usage_context.py tests/unit/test_process_conversation_free_tier_branch.py tests/unit/test_client_processing_acceptance.py tests/unit/test_client_processing_finalize.py tests/unit/test_free_tier_entrypoint_matrix.py tests/unit/test_fair_use_engine.py tests/unit/test_fair_use_plan_aware.py tests/unit/test_subscription_plans.py - 491 passed - Did not exercise a live custom-STT listen session Co-authored-by: Apoorv Darshan <[email protected]> * test(backend): isolate custom-STT STT-credit skip from subscription stubs The bootstrap admit test imported listen_session_bootstrap after the file stubbed database._client for subscription isolation, so test.sh file isolation failed on fair_use.db. Keep the gate tests isolated and pin the STT-credit skip on the existing bootstrap suite. Failure-Class: none Verification: - BACKEND_UNIT_TEST_FILE_LIST with test_custom_stt_llm_processing_gate.py and test_listen_session_bootstrap.py via backend/test.sh - 8 passed + 5 passed Co-authored-by: Apoorv Darshan <[email protected]> * fix(backend): keep custom-STT LLM skip from aborting memory fan-out The new should_skip_omi_paid_postprocessing import bound a truthy AutoMock in test_upstream_boundary, so process_conversation returned before _extract_memories. Consult the gate only for custom-STT conversations and pin the isolation stub to fail-open, matching the other subscription gates. Failure-Class: none Verification: - pending: tests/unit/test_upstream_boundary.py via backend/test.sh Co-authored-by: Apoorv Darshan <[email protected]> * chore: retrigger Hygiene after line-count exception update PR body already declares process_conversation.py 3167 -> 3199. Hygiene on 86c79cf still shows the stale 3196 mismatch because body edits do not re-run that check. Co-authored-by: Apoorv Darshan <[email protected]> * test(backend): pin unset BYOK context and subscription_inactive LLM gate Review on #14300 asked for two cases that pin current policy without changing it: leave `_byok_uid_ctx` unset (do not monkeypatch the helper) so a BYOK-enrolled custom-STT user follows the plan check, and add `plan=None` covering `subscription_inactive`. Co-authored-by: Apoorv Darshan <[email protected]> * fix(backend): keep custom-STT LLM skip after unpaid on-device summary #14513 made the free-tier store_projection path reachable via free_tier_local_processing_enabled(uid). The custom-STT skip was a trial-paywall-style early return above that branch, so a desktop custom-STT session that would persist the local summary never reached it. Move the skip to after the unpaid desktop path (and the flag-off elifs) so it only gates Omi-paid _get_structured. Gate policy is unchanged. Failure-Class: none Verification: - pending: custom-STT gate + process_conversation unit tests Co-authored-by: Apoorv Darshan <[email protected]> --------- Co-authored-by: Cursor Agent <[email protected]>
This was referenced Sep 20, 2026
Closed
kodjima33
added a commit
that referenced
this pull request
Sep 22, 2026
… lookup failure (#15952) routers/sync.py wrote is_locked=True onto a conversation whenever has_transcription_credits() returned False, and that helper fails closed for any lookup it can't trust (a Firestore blip, an untrusted usage record) as well as for genuine exhaustion. Unlike gating a live listen socket, nothing routinely clears is_locked afterward, so a transient failure paywalled the conversation on every future read (app, folders, search, MCP, developer API) until the user's subscription happened to change. resolve_conversation_processing_allowance already treats these same two reasons (allowance_unavailable, usage_invalid) as fail-open for the other paid gate, citing #12663. This applies the same distinction to the durable sync lock: only lock when the resolver's reason indicates the plan is actually out of minutes. fixes #15232
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.
What changed and why
Reverts the Omi-paid LLM post-processing gate from #7690 (commit
3c998bf, PR #10962).Custom-STT users bring their own STT key. The gate skipped all LLM enrichment for
their conversations — title, overview, memories, action items, embeddings, app results —
unless they also carried an OpenAI/Anthropic BYOK key on the request. Bringing an STT
key is not a request to lose summaries, and almost nobody carries a second LLM key, so
in practice the cost cap read as "summarization is off" for the entire custom-STT
population. Same story on the live photo path:
_process_photostored the literal stringCustom STT: photo description skipped (no LLM BYOK key).instead of callingdescribe_image.Removed
process_conversationgate and its deferredis_byok_activelookup._process_photogate inrouters/listen/receiver.py.should_skip_custom_stt_postprocessing, now unreferenced.Kept
Conversation.uses_custom_sttand its creation / resume / merge plumbing. It isprovenance only now — it keeps custom-STT spend queryable and feeds the isolated
fair-use lane (#10127) — so the API contract and the generated Dart/OpenAPI clients
are unchanged. Comments that described it as a cost gate were corrected to match.
Cost visibility therefore survives the revert; only the enforcement is gone. If a cap
is wanted later it belongs in the fair-use lane that already meters this traffic, keyed
on actual spend rather than on a BYOK key almost no gated user holds.
Product invariants affected
Neither changes behavior here. The diff removes an early return, so custom-STT
conversations now reach exactly the promotion and task-capture paths every other
conversation already takes. No guard test needed updating.
Failure class (fixes)
Failure-Class: none
The gate did what it was written to do; the policy behind it was wrong for the
population it selected. This is a product-policy revert, not the repair of a violated
code contract, so no class is declared and none is opened.
Tests
The two gate assertions are inverted into regression tests: a custom-STT conversation
with no LLM BYOK key must run structuring, and a custom-STT photo must reach
describe_image. The "hot path never reads BYOK state" deferral tests are droppedalong with the deferral they guarded.
Verification
cd backend && pytest tests/unit/<file>.py(one file at a time):test_process_conversation_usage_context.pytest_listen_multichannel_mix_buffer_leak.pytest_transcribe_decisions.pytest_listen_process_pending_shutdown.pytest_merge_audio_chunk_copy_failure.pytest_shared_conversation_field_exposure.pytest_byok_security_enrollment.pytest_new_usage_tracking_gaps.pymake preflight— all manifest checks pass.Not exercised against a live custom-STT session: that needs a real third-party STT key
bound to an account. The behavior is covered at the
process_conversationand_process_photoseams instead.