Skip to content

SCA-4247: Recover background Flex and reuse V3 outline prefixes - #26258

Merged
Git-on-my-level merged 18 commits into
mainfrom
lane/sca4247-llm-flex
Nov 26, 2026
Merged

Git-on-my-level merged 18 commits into
mainfrom
lane/sca4247-llm-flex

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

What changed and why

SCA-4247 adds caller-scoped Flex budgets for background structure and L1. The old 10–15 second admission caps cut off slower completions, and the first 429 immediately triggered Standard. The Nov 24 partial reason sample contained 294 structure timeouts and 288 rate limits. Eligible calls now retry one 429 when a fresh attempt still fits and reserve time for Standard.

The existing V3 builder lease can be promoted by an explicit open during a paid background outline or summary. A superseded writer cannot publish. Background outline uses the same Luna route and JSON contract with a nonstreaming transport, capped at 110 seconds and admitted only with room before close + 2 hours. The separately reversible cache change places a stable, owner-scoped cache breakpoint before dynamic timing and transcript evidence. It keeps the existing logical result-cache key.

The merge retains main commit 8b3cc87cef7’s Standard default for omi:auto:conversation-v3-summary. Background Flex recovery remains enabled by default for conv-structure and memory-l1.

Product invariants affected

  • INV-MEM-4. Background notes keep their processing obligation and continue into the existing memory extraction path after an open takes over.
  • INV-TASK-2. The drain retains the existing task candidate policy and derived-effects path.

How it was verified

  • Merge head dcaf4879344e801892caef84af1af9a523402dbf passed all 1,279 focused backend tests across 16 files via omi-heavy run --wait 600 -- timeout 600 bash test.sh on M1.

  • After merging current main, all 537 focused backend tests passed across 10 files through omi-heavy, including the Standard default, Flex receipt and timeout handling, and V3 lease reload and task retries.

  • The default-off gating follow-up passed all 307 tests across the V3 review, stream, transactions, and gateway executor files through omi-heavy, using a focused subset of the changed-files selection.

  • At the panel follow-up head, 410 focused backend tests passed through the M1 omi-heavy gate. This includes synthetic replay sample bounds, provider timeout and retry behavior, strict Firestore lease races, and released-client detail compatibility.

  • Focused backend/test.sh suite via omi-heavy, 399 tests passed across gateway executor, V3 engine, stream, transactions, task retry, and finalization.

  • The two open-path suites passed 98 tests after updating the lease fixture, and the two L1 foreground deadline suites passed 32. The bounded pre-push check passed with zero type errors.

  • The exact stable text measured 1,223 tokens with o200k_base versus 546 for the old unexpanded template. The mock HTTP gateway verified the explicit cache breakpoint and unchanged lane, JSON response mode and reasoning effort.

  • Read-only Prometheus reported a 9.05% outline cached-input share for the Nov 23 12:00 to Nov 24 12:00 UTC baseline. Post-change cache share and net spend await matched usage receipts.

  • The offline evaluator was smoke-tested with 300 synthetic paired receipts. The blind paired model replay, foreground p95/p99, deployment compatibility and custody/freshness gates are pending. Keep first-open gating off pending SCA-3677 and keep the outline arms off pending the rollout evidence below.

Tests

The replay runbook explains the gate and kill switches. Focused regressions cover successful Flex retry, preservation of Standard reserve, realtime admission without budget, message wire format, and the open race against an in-flight writer.

Panel review and rollout

Follow-up to panel review-20261125t032001-fa2e. Eligible background structure and L1
retain the default-on retry and deadline behavior. V3 summaries keep the Standard
default from main (8b3cc87cef7), where Flex served about 5% of the lane. After
a readback, LLM_GATEWAY_FLEX_FIRST_LANES can re-enable Flex for that lane without
a deploy. Receipt-free Flex timeouts stop dispatch because provider usage may be indeterminate. Only a confirmed receipt-free 429 can use the Standard reserve. Standard retries and failover use the same
deadline. Waited and unscoped calls use Standard.

The V3 summary first-open switch (OMI_V3_SUMMARY_FIRST_OPEN_GATING) defaults off. SCA-3677 gates activation. With the switch off, background summary generation continues without waiting for a detail open.

The outline prompt and cache prefix and the outline Flex transport default off.
After the approved 300-pair replay passes, SCA-3677 transcript access is cleared,
SCA-3655 and SCA-3657 freshness is verified, and Margin writes GO, Release can
enable each arm in the approved cohort. Release owns the backend
OMI_OUTLINE_CACHE_PREFIX key and the backend and gateway
LLM_GATEWAY_BACKGROUND_OUTLINE_FLEX key. Margin checks foreground p95/p99,
close + 2h publication and net provider spend in the first full 24-hour cohort
window before approving expansion. Set either key to off to roll it back.

UI evidence

UI-Evidence: none -- no visual UI change; the client now marks an explicit conversation-detail open.

Failure class

Failure-Class: none

Line-Count-Exception: backend/database/conversations_v3.py | 1502 -> 1508 | Keep the separate Flex and realtime attempt counters inside the existing lease transaction.

Line-Count-Exception: backend/routers/conversations.py | 3197 -> 3209 | Preserve released-client generation and polling while requiring explicit intent for lease promotion.

Line-Count-Exception: backend/utils/conversations/v3/service.py | 1711 -> 1835 | Keep outline admission, provider ownership fencing and the background settlement race in their existing orchestration path.

Line-Count-Exception: backend/utils/conversations/process_conversation.py | 3612 -> 3614 | Let the existing notes error boundary propagate lease loss to the drain.

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

FIX findings on exact head d39f9496135a9ba571c7d42e5c492932bfef45cc. The outline arms being off by default does not cover these default-on background completion paths. The 300-pair replay, SCA-3677 clearance, SCA-3655/3657 freshness checks, and Margin GO remain separate rollout gates. The connected GitHub identity authored this PR, so GitHub rejected a formal REQUEST_CHANGES review; these comments record the findings.

Comment thread backend/llm_gateway/gateway/executor.py Resolved
Failure-Class: none
Co-Authored-By: Claude Opus 5.5 <[email protected]>

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

RE-REVIEW: both prior P1 fixes are verified at exact head 196329985f81cad81275ef36ab4be3018a987d2d. Flex timeouts stop dispatch even without a usage receipt; only a confirmed receipt-free 429 retains the scoped Standard reserve. The summary stream rechecks freshness and eligibility on the row reloaded under its lease, releases the lease, and serves stored notes without starting the notes model. The added race test asserts zero notes calls and lease release. No additional background retry was added; the stated delay/recovery tradeoff remains. The 178 passing tests are reported by the author; I did not rerun them. The replay, custody, freshness, and Margin GO gates remain separate.

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Delta review at exact head abef1ac (from 1963299): no P0/P1 found for the requested shipped configuration. With OMI_V3_SUMMARY_FIRST_OPEN_GATING and both outline arms off, the new first-open behaviors are inactive; summary reads, background enrichment, and the v3_process_pending queue retain main behavior. The existing Flex recovery and the receipt-free timeout stop and lease freshness recheck remain. Static review only; I did not rerun tests.

@Git-on-my-level
Git-on-my-level marked this pull request as ready for review November 26, 2026 02:28
@Git-on-my-level
Git-on-my-level merged commit a4a78f2 into main Nov 26, 2026
77 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/sca4247-llm-flex branch November 26, 2026 20:24
Git-on-my-level added a commit that referenced this pull request Nov 27, 2026
… owner (#26530)

Follow-up to #26258 for SCA-4247.

- Use one gateway deadline from a valid backend background budget for
Standard, Flex, and failover. Scoped Flex requires enough time for the
Standard reserve and a useful Flex attempt.
- Scope opt-in V3 outline prompt cache keys by owner for both streaming
and builder calls.
- Register V3 summary first-open gating with its default-off behavior
and SCA-3677 rollout gate. Document scoped and legacy Flex fallback and
rollback behavior.
- Cover default-mode deterministic outline cache reuse and assert that
the second pass skips the model.

## Product invariants affected

none

## Failure class

Failure-Class: FC-per-hop-timeout

## Verification

- From `backend/`, `.venv/bin/python -m pytest -q
tests/unit/test_llm_gateway_executor.py
tests/unit/test_conversations_v3_review.py
tests/unit/test_conversations_v3_stream.py` passed all 262 tests.
- `python -m testing.pipeline_lab affected` selected 16 scenarios. All
16 passed with the local emulator and fake gateway.
- `python3 scripts/check_feature_flag_registry.py` passed.
- Pre-push PR preflight passed all 42 checks with this PR body.

SCA-4247 continues to track serving evidence and the matched R36
readback. First-open gating uses the December 1 review checkpoint shared
by the related outline flags.


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/26530?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<a
href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/26530?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F26530&source=description"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img
alt="Turn on auto-fix"
src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
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