Repository navigation
SCA-365: route remaining HTTP LLM surfaces through the gateway - #12337
Merged
Git-on-my-level merged 10 commits intoAug 28, 2026
Merged
Git-on-my-level merged 10 commits into
Git-on-my-level merged 10 commits into
Conversation
OpenAI retired Assistants on 2026-08-26, so every /v1/threads create 404s and non-vision file chat is down. Stream PDFs as Chat Completions file parts on gpt-4.1 (documented file-input contract) and keep images on the verified gpt-5.6-luna vision lane. Failure-Class: FC-pinned-vendor-request-contract-retired Co-authored-by: Cursor <[email protected]> Co-authored-by: multica-agent <[email protected]>
Unpacking a token-budget dict into create() is untyped and fails pyright. Failure-Class: FC-pinned-vendor-request-contract-retired Co-authored-by: Cursor <[email protected]> Co-authored-by: multica-agent <[email protected]>
CI ran each unit file in its own process; incomplete BYOK/LLM stubs and a duration-guard race on desktop transcribe failed the backend suite. Co-authored-by: Cursor <[email protected]> Co-authored-by: multica-agent <[email protected]>
Upstream 7c900a9 moved the Soniox client into utils.stt.soniox but left SafeSonioxSocket / process_audio_soniox imported in streaming.py without a re-export marker; receiver.py and test_soniox_streaming.py import them through utils.stt.streaming, so strict pyright fails main and every PR merge ref. Carry the one-line marker so this backend CI lane can go green; matches the existing SafeDeepgramSocket compat re-export convention on the previous line. Co-authored-by: multica-agent <[email protected]>
…-365-llm-gateway-surfaces # Conflicts: # backend/tests/unit/test_byok_security.py # backend/tests/unit/test_chat_file_upload_unsupported.py # backend/tests/unit/test_chat_quota.py # backend/tests/unit/test_desktop_transcribe.py # backend/tests/unit/test_paywall_reconnect_gate.py # backend/utils/stt/streaming.py
File-chat completions, company-paid desktop Vertex traffic (text + single embed), and both embedding surfaces now hop backend/llm_gateway so accounting (build_accounting_event / gateway metrics) is the single spend ledger when OMI_LLM_GATEWAY_FEATURE_MODE=gateway: - gateway: OpenAI-shaped /v1/embeddings surface (omi:auto:openai-embeddings, omi:auto:gemini-embeddings) with accounting; desktop-vertex-* chat lanes generated from vertex_pt_routing; VertexGeminiProvider owns the PT policy (pin, promotion latch, overflow ladder, reachability, capacity header, regional vs multi-region host split) and gains tools/toolConfig translation plus :predict embeddings; validator accepts file parts, json_object, and the extra_body-style google options field. - backend: chat_file streams/sync completions through the file-chat lanes (OpenAI Files upload/download stays direct by design); the OpenAI embeddings proxy and gemini_embed_query hop the gateway lanes with BYOK kept on documented thin direct paths; desktop_proxy stays the BFF (auth/metering/limits) and translates Gemini JSON via utils/llm/desktop_gemini_gateway.py, keeping BYOK and batchEmbedContents direct. - FEATURE_MODE=off keeps every legacy direct path (kill switch unchanged); inventory + guardrails updated; omni WS stays blocked.
…ut of the ratcheted files providers.py and desktop_proxy.py grew past the product line-count ratchet; the vertex adapter's pure wire translation (vertex_wire.py), the PT policy mixin (vertex_pt_policy.py), shared provider types (provider_types.py), and the desktop BFF's gateway hop + Gemini body sanitization (utils/llm/desktop_gemini_gateway.py) move into focused modules with the original call sites and test seams preserved via re-exports.
…ile-chat spend The gateway Vertex provider was sharing the PT monotonic clock with ADC token expiry, so tokens never refreshed after the first fetch. File-chat hops also omitted the user uid, leaving ledger rows unattributed, and the desktop tool-loop minted a new tool_call_id after the ordinal advanced. Failure-Class: none Co-authored-by: Cursor <[email protected]> Co-authored-by: multica-agent <[email protected]>
…t stubs Direct-path aembed_query/aembed_documents now notify and fall back to the Omi key on BYOK 401 like the sync methods. Hermetic app-integration harnesses stub utils.llm.temporal so collection survives the main merge that imports current_date_for_uid. Co-authored-by: Cursor <[email protected]> Co-authored-by: multica-agent <[email protected]>
Live probe confirmed Luna accepts the Chat Completions file-part contract, so the documents lane leaves gpt-4.1. Keep the separate file-chat-documents lane because the request shape still differs. Failure-Class: none Co-authored-by: Cursor <[email protected]> Co-authored-by: multica-agent <[email protected]>
Git-on-my-level
added a commit
that referenced
this pull request
Aug 28, 2026
…12374) ## What The Auto Deploy Desktop Backend to Development promotion gate fail-closed on every candidate since #12337: the probe's `REAL_GEMINI_PROVIDER_ROUTES` did not admit the `llm_gateway` provider route the desktop proxy now stamps on `X-Omi-Provider` for company-paid Gemini traffic (run [33219770852](https://github.com/BasedHardware/omi/actions/runs/33219770852), step "Prove candidate chat compatibility", `gemini_proxy: response did not come from an admitted provider route`). Dev stayed 100% on the stale revision `desktop-backend-cdca0c865fd1-33169706190-1`; the candidate was correctly held tag-only. This PR admits the real post-gateway route in the probe allowlist. No backend behavior changes. ## Why this is a real route, not a weakened gate The probed surface is `POST /v1/proxy/gemini/models/gemini-2.5-flash:generateContent`. Post-#12337, that request hops the gateway: - `backend/routers/desktop_proxy.py` → `company_paid_via_gateway` → `proxy_company_paid_via_gateway` stamps `telemetry.provider = 'llm_gateway'` → `X-Omi-Provider: llm_gateway` (`backend/utils/llm/desktop_gemini_gateway.py:595`). - `gemini-2.5-flash` maps to lane `omi:auto:desktop-vertex-flash` (`utils/llm/vertex_pt_routing.py` DESKTOP_TEXT_LANES), whose route pins primary provider `gemini` = `VertexGeminiProvider` with **no fallbacks** (`backend/llm_gateway/gateway/config_loader.py:330`) — real Gemini-on-Vertex. - `offline_stub`, `desktop_llm_stub`, unknown, and empty header values remain rejected fail-closed; the existing offline-stub rejection test is unchanged. ## Test plan - `python3 .github/scripts/test_desktop_backend_candidate_probe.py` — 19 tests OK locally, including: - updated `test_gemini_probe_rejects_stub_or_unknown_provider_routes`: rejects `offline_stub` / `desktop_llm_stub` / `unknown` / `""`, admits `vertex_ai` / `ai_studio` / `ai_studio_byok`; - new `test_gemini_probe_admits_post_gateway_llm_gateway_route`: a gateway-served response (`x-omi-provider: llm_gateway`) passes `_gemini_request` end to end and reports `provider_route: llm_gateway` — the exact live failure mode, now pinned as passing. - After merge: Auto Deploy Desktop Backend to Development must build, probe, and shift 100% dev traffic to the merge-SHA revision; `gcloud run services describe desktop-backend --project=based-hardware-dev --region=us-central1` is the independent serving proof (tracked on SCA-368). ## Product invariants none (per `scripts/pr-preflight --suggest`) ## Failure-Class Failure-Class: FC-client-model-outside-proxy-allowlist #12337 retargeted the desktop proxy at a new provider route without widening the gate that admits it in the same change, so the promotion gate rejected a value it did not know instead of degrading. This PR widens the admission set in data and pins both directions (real route admitted, stub class still rejected) in the probe's test file. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/12374?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="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
pull Bot
pushed a commit
to codingwatching/omi
that referenced
this pull request
Aug 29, 2026
BasedHardware#12337 routed company-paid desktop Gemini traffic through the LLM gateway; since then the desktop proxy stamps X-Omi-Provider: llm_gateway (backend/utils/llm/desktop_gemini_gateway.py), a value the Auto Deploy candidate probe's REAL_GEMINI_PROVIDER_ROUTES did not admit, so "Prove candidate chat compatibility" fail-closed on every promotion (run 33219770852) and dev desktop-backend stayed on the stale revision. Admit llm_gateway: the probed surface (gemini-2.5-flash generateContent) maps to the gateway's desktop-vertex-flash lane, whose primary provider is VertexGeminiProvider with no fallbacks (config_loader.py), so the hop is real Gemini-on-Vertex. Stubs, unknown, and empty routes stay rejected fail-closed; the offline-stub rejection test is unchanged and a new test pins the post-gateway route as admitted end to end through _gemini_request. Verification: python3 .github/scripts/test_desktop_backend_candidate_probe.py 19 tests OK (incl. test_gemini_probe_admits_post_gateway_llm_gateway_route). Failure-Class: FC-client-model-outside-proxy-allowlist Co-authored-by: multica-agent <[email protected]>
This was referenced Aug 29, 2026
Git-on-my-level
added a commit
that referenced
this pull request
Aug 30, 2026
…equires (#12443) ## What broke Live-captured conversations stopped finalizing in production at **2026-08-30T15:21:42Z** and are still failing. The pusher had not deployed since **2026-07-01** (`2ae7f78841`). #12429 fixed the pre-Helm capacity gate that was failing the lane, and the rollout that followed (Helm applied 15:16:28Z, complete 15:28:51Z) carried two months of change onto a Deployment whose environment was never extended to match. The old pusher never ran this code. Its opcode-104 handler called `process_conversation` directly and never touched the durable-job architecture. Today is the **first time the pusher has ever executed `finalize_persisted_conversation`** — cold activation of a dormant subsystem, not a contract drift. Verified: `backend/routers/pusher.py`, `backend/utils/listen_pusher_session.py` and `_claim_finalization_job_txn` are byte-identical across `6f7c57ac15..6134ebd`. ## Root cause The pusher chart ships **68 env vars where backend-listen ships 115**, and `MEMORY_ENABLED` is among the 50 it lacks. Confirmed against the live cluster: ``` prod-omi-pusher 68 env vars, zero MEMORY_* vars prod-omi-backend-listen 115 env vars, MEMORY_ENABLED=on ``` `rollout_mode_env_value()` fail-closes to `off` when the flag is unset (`backend/config/memory_rollout.py`). `MemoryService.ensure_canonical_mutation_ready()` — called **unconditionally and unwrapped** by `_extract_memories_inner` for every non-discarded conversation — then raises `HTTPException(503, "Memory writes are globally paused")`. `finalizer.py` converts that to `ConversationFinalizationError('processing_failed')`, and the listen session retries roughly 4x per conversation. Measured distribution in a clean window (23:00–23:10Z, all entries): | Exception | Count | Share | | --- | --- | --- | | `HTTPException` (this bug) | 366 | 89.5% | | `LegalHoldAuthorityUnavailable` | 43 | 10.5% | This PR fixes the 89.5%. The remainder is a separate, older regression — see below. ## Why nothing paged `finalizer.py` logs only `type(error).__name__`. Production emitted ~16k/hour of bare `error=HTTPException` carrying no status code, no detail and no traceback, so the signature read as already-known. The listener itself stayed healthy throughout — WS connections in band, 5/5 ready pods, listen-LB 5xx at zero, every `Backend-listen` critical rule inactive, and no client-side Sentry spike. Audio was captured and transcribed; it simply never became a conversation. ## The fix Set `MEMORY_ENABLED=on` for dev and prod pusher, matching backend-listen. It is a plain literal, so it requires no key from the pusher's ExternalSecret — deliberately avoiding the failure class from #12298, where a chart consumed a secret key the ExternalSecret did not enumerate. The test asserts the **contract**, not the key: the env a chart ships must resolve to a mode that permits memory writes, and the two co-hosts may not disagree. Against the charts as they stood during the incident it fails with `assert 'off' == 'write'`. ## Failure class This reopens an existing class. Its prevention artifact, `test_conversation_notes_v2_beta_rollout.py`, pins three named flags across backend-listen and the Cloud Run backend. It does not generalize to other flags, and it does not know the pusher is now a third host of `process_conversation`. Failure-Class: FC-rollout-flag-absent-from-a-cohost-of-its-code-path ## Deliberately not in this PR - **The other 49 missing env vars**, including `GEMINI_API_KEY`, `USE_VERTEX_AI`, `LISTEN_FINALIZATION_ORPHAN_STALE_SECONDS` and the `FAIR_USE_*` set. Real exposure, but several are secret refs and widening them under incident pressure risks the #12298 class. Needs its own change. - **`LegalHoldAuthorityUnavailable`** (10.5% of failures) — `current_destructive_operation_token()` at `backend/database/legal_holds.py:403`, reached from `canonical_memory_adapter.py:2029`, requires an active `destructive_operation_gate(...)` context that this call site never enters. Introduced by #12084, first seen in prod 2026-08-28T01:51:36Z and firing continuously for ~2.5 days on `/v1/conversations/from-segments`. Independent of this bug and of today's deploy. - **`/v1/embeddings` 404s at the LLM gateway.** `prod-omi-llm-gateway` runs image `c61d815` (2026-08-20), which predates #12337's gateway embeddings route; `gcp_llm_gateway.yml` is dispatch-only and was never run after that merge. Swallowed at `vector_db.py`, so not user-visible as an error — but `save_structured_vector` has been failing silently since ~13:44Z, meaning **no conversation created since then has a summary vector in Pinecone**, and it will not self-heal without a backfill. Fix is to deploy the gateway, not to change code. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/12443?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="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
Git-on-my-level
added a commit
that referenced
this pull request
Aug 31, 2026
…ute (#12444) ## The outage Since 2026-08-30 the prod pusher failed **every** conversation finalization: ``` ERROR:database.vector_db:find_similar_action_items failed uid=...: Client error '404 Not Found' for url 'http://prod-omi-llm-gateway.prod-omi-backend.svc.cluster.local:8080/v1/embeddings' ``` ~1,300/h, 100% in the pusher container. Live voice captures dead-lettered to `processing_failed`; "Conversation processed by pusher" went to ~0/h. ## Root cause: the client shipped, the server didn't | | | | --- | --- | | Prod gateway last deployed | 2026-08-20, run [32428978705](https://github.com/BasedHardware/omi/actions/runs/32428978705), SHA `48bb6e799f` | | `/v1/embeddings` route added | 2026-08-28, `fe3df5ac00` (#12337, SCA-365) | | `fe3df5ac00` is an ancestor of `48bb6e799f`? | **No** — the deployed gateway is 800 commits behind main | `#12337` added both halves of the hop: the gateway route *and* the backend client that calls it. The backend auto-deploys on merge to main; `gcp_llm_gateway.yml` is `workflow_dispatch`-only. So the caller reached prod and the callee never did. Ruled out, not assumed: - **Route not mounted** — `main.py` does `app.include_router(embeddings.router)` on main. - **Feature-mode mismatch** — the gateway is serving `/v1/chat/completions` **200** and `/v1/embeddings` **404** in the same 30-minute window, from the same pods. Feature mode is on; the route is what's missing. - **A route the gateway declines to serve** — the 404 is Starlette's unrouted-path answer, not a `GatewayError`. ## What this PR changes It does **not** redeploy the gateway — that is still required, and is tracked separately. It removes the gateway's ability to take embeddings down when it is behind. `_gateway_mode` already trades ledger accounting for availability when a rollout is misconfigured — it catches `RuntimeError` and degrades to direct, because embeddings are load-bearing for memory and vector search. It could not see this skew: the gateway is healthy, it is simply older than its client. Meanwhile a working direct embeddings path sat three lines behind that 404 the entire outage. **Status alone cannot carry route-absence** — the gateway also returns 404 for `model_not_found` (`_status_code_for_error`). The bodies differ, so `is_gateway_route_absent` discriminates on the body: | 404 body | Meaning | Behaviour | | --- | --- | --- | | `{"detail": "Not Found"}` (Starlette, unrouted) | server predates client | degrade to direct, log once | | `{"error": {...}}` (OpenAI-shaped) | gateway owns the route, rejected the request | **raise**, unchanged | Applied to all four `_OpenAIEmbeddingsProxy` embedding methods and to `gemini_embed_query`, which reaches the same `/v1/embeddings` route for screen-activity search and had the identical defect. The skew is logged once per process rather than per call: the condition holds until the gateway is redeployed, the callers behind it run thousands of embeddings an hour, and the gateway's own access log keeps counting the 404s. ## Tests `backend/tests/unit/test_embeddings_gateway.py`, driven through the real seam (`clients.embeddings` / `clients.gemini_embed_query`) with real `httpx` responses: - 6 new tests fail on the unfixed tree with exactly the production symptom (`httpx.HTTPStatusError: Client error 404` escaping `embed_query`), pass with the fix. - 2 of the new tests pass **both** before and after — deliberately: they pin that `model_not_found` still raises, so the fallback cannot widen into masking lane drift. ``` 17 passed tests/unit/test_embeddings_gateway.py 521 passed all 41 gateway/embedding test files ``` ## Follow-ups (not in this PR) - **The gateway still needs redeploying.** This PR restores availability; it does not restore the embeddings ledger rows, which stay unaccounted while the gateway is behind. - The 800-commit gateway drift is the standing risk. A backend↔gateway route dependency has no equivalent of the release-lane probe that this failure class's canonical prevention installed for the Windows update feed. Failure-Class: FC-ship-before-required-route <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/12444?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="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
pull Bot
pushed a commit
to codingwatching/omi
that referenced
this pull request
Aug 31, 2026
The prod LLM gateway was last deployed 2026-08-20 (48bb6e7); the /v1/embeddings route landed 2026-08-28 in fe3df5a (BasedHardware#12337). The backend half of that PR auto-deploys on merge, the gateway is workflow_dispatch-only, so the client shipped and the server did not. From 2026-08-30 the gateway answered every embeddings call with a Starlette 404, embed_query raised it, find_similar_action_items failed, and conversation finalization dead-lettered ~1,300/h in prod. A working direct embeddings path was sitting right behind that 404 the whole time. _gateway_mode already trades ledger accounting for availability when a rollout is misconfigured (it catches RuntimeError), but it could not see this skew: the gateway is healthy, it is simply older than its client. So treat route-absence as its own condition. The status alone cannot carry it -- the gateway also answers 404 for model_not_found -- but the bodies differ: a route the app never registered gets Starlette's bare {"detail": "Not Found"}, while a gateway-owned rejection is OpenAI-shaped {"error": {...}}. is_gateway_route_absent discriminates on the body, so deploy skew degrades to direct while lane misconfiguration still raises. Applied to all four OpenAI embedding methods and to gemini_embed_query, which reaches the same route for screen-activity search and had the identical defect. The skew is logged once per process, not per call. This does not remove the need to redeploy the gateway; it removes the gateway's ability to take embeddings down when it is behind. Failure-Class: FC-ship-before-required-route
Git-on-my-level
added a commit
that referenced
this pull request
Aug 31, 2026
## What changed and why File chat now treats an OpenAI-compatible `404` with the typed `model_not_found` code as a gateway capability-skew signal and retries the completion through the existing direct-provider kill-switch path. It records the recovery through shared fallback telemetry, while genuine provider file `404`s remain typed stale-attachment failures. Production evidence on 2026-08-30 showed the backend calling the new `omi:auto:file-chat-*` lanes added by #12337 while the serving gateway image still predated those lanes. Every observable `llm_gateway_request_rejected ... error_class=model_not_found` event matched a backend `StaleChatFileError` chat failure; the status-only attachment classifier had hidden the actual gateway rejection. ## Product invariants affected none ## How it was verified - Live production logs: 21 gateway `model_not_found` rejections on the current backend revision matched 21 file-chat `StaleChatFileError` failures one-for-one by timestamp. The earlier backend revision contributed four more file-chat failures; its gateway pod logs had already rolled over. - `cd backend && PYTHONPATH=. .venv/bin/python -m pytest -q tests/unit/test_chat_file_gateway_surface.py tests/unit/test_chat_file_completions.py` — 16 passed. - `cd backend && ./scripts/typecheck.sh` — 0 errors. - `git diff --check` — passed. - `make preflight` — passed after commit against `origin/main`. The fix was not deployed from this branch. Live log correlation proves the incident path; the regression suite exercises the recovery seam without sending user data or provider traffic. ## Tests `backend/tests/unit/test_chat_file_gateway_surface.py` now proves: - async streaming falls back only for a typed gateway `model_not_found` rejection; - a genuine file `404` does not fall back and remains `StaleChatFileError`; - a direct fallback that fails mid-stream records `exhausted`, never `recovered`; - the synchronous file-search completion path has the same compatibility behavior; - successful gateway routing remains gateway-only. ## Failure class (fixes) Failure-Class: FC-ship-before-required-route <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/12449?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="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
This was referenced Sep 9, 2026
Git-on-my-level
added a commit
that referenced
this pull request
Sep 13, 2026
Desktop Insight/Task only act on Gemini functionCall parts. The #12337 OpenAI-compatible Vertex adapter forwarded tools on the request and dropped them on the 200 response, which zeroed Advice Generated and Task Extracted. Failure-Class: new
Git-on-my-level
added a commit
that referenced
this pull request
Sep 13, 2026
) ## What changed and why Gateway Vertex `generateContent` already forwarded OpenAI `tools` to Gemini, but `_vertex_to_openai_response` / `_vertex_to_openai_stream_chunk` copied **text only**. Company-paid desktop Insight/Task (`sendImageToolLoop`) only act on `functionCall`, so after #12337 hopped them through the gateway they got HTTP 200s with billed tokens and emitted **zero** `Advice Generated` / `Task Extracted` (#13666). JSON-schema Memory/Suggestion still worked because they parse text. This round-trips Vertex `functionCall` parts to OpenAI `tool_calls` (and `finish_reason: tool_calls`), including functionCall-only candidates. Desktop BFF translation already maps that back to Gemini. No client change. Do not flip `OMI_LLM_GATEWAY_FEATURE_MODE`. Closes #13666 ## Product invariants affected none ## How it was verified ``` backend/.venv/bin/python -m pytest \ backend/tests/unit/test_llm_gateway_vertex_provider.py \ backend/tests/unit/test_desktop_gemini_gateway.py -q ``` 36 passed, including the new functionCall-only generateContent and SSE regressions. Could not exercise live prod desktop Insight/Task in this PR; that path is the GKE LLM gateway. After merge, ship **llm-gateway** (not Cloud Run-only) so desktop-backend's existing hop sees the translator. ## Tests `test_vertex_function_call_only_response_emits_openai_tool_calls` and `test_vertex_function_call_sse_emits_openai_tool_call_delta` in `backend/tests/unit/test_llm_gateway_vertex_provider.py`. A Vertex candidate with only `functionCall` (no text) must emit OpenAI `tool_calls`. That is the test that would have stayed red on #12337. ## Failure class (fixes) Failure-Class: new ## Failure-class transition narrative (only when needed) Violated contract: an OpenAI-compatible Vertex adapter that advertises function tools must return those tool calls, not a 200 with empty/text-only content. Canonical guard: response + SSE normalizers emit `tool_calls` from Gemini `functionCall` parts; the two new hermetic tests are the prevention artifact. Registry file: `.github/failure-classes/FC-gateway-vertex-drops-function-calls.json`. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/13671?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="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
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.
Summary
When
OMI_LLM_GATEWAY_FEATURE_MODE=gateway, the remaining Omi-paid HTTP LLM surfaces hopbackend/llm_gatewaysobuild_accounting_event/ gateway metrics are the spend ledger.omi:auto:file-chat-vision(gpt-5.6-luna) andomi:auto:file-chat-documents(gpt-4.1). OpenAI Files upload/download stays direct (bytes/file_idlifecycle). BYOK OpenAI is not used on this surface because the Files namespace is company-owned.generateContent/streamGenerateContent/embedContenthop generatedomi:auto:desktop-vertex-*lanes andomi:auto:gemini-embeddings.desktop_proxystays the BFF. PT pin/overflow/host policy lives inVertexGeminiProviderviavertex_pt_routing.py(no second policy). Mac Gemini JSON is translated in the BFF; no Desktop Swift change. Gemini BYOK stays thin direct AI Studio.POST /v1/embeddingsfor OpenAItext-embedding-3-largeand Vertexgemini-embedding-001(:predict).batchEmbedContentsstays on AI Studio (Vertex batch wire shape incompatible).This branch merges open #12284 (Assistants sunset → Chat Completions) so file-chat hops the completions path, not a re-deleted Assistants stack. Do not comment on or reassign SCA-362.
Review follow-ups on top of the OMP implementation:
time.time); the PT probe clock is monotonic and must not be shared or tokens never expire-refresh.X-Omi-User-Uidso ledger rows are attributed.tool_call_idinstead of minting a new ordinal.Leftover exceptions (intentional)
omni_relay.py) remains blocked-when-gateway-on.OMI_LLM_GATEWAY_FEATURE_MODE=offkeeps every legacy direct path (kill switch).:generateContentroutes on the gateway.Test plan
pytest tests/unit/test_chat_file_gateway_surface.py tests/unit/test_desktop_gemini_gateway.py tests/unit/test_llm_gateway_vertex_provider.py tests/unit/test_embeddings_gateway.py tests/unit/test_llm_gateway_embeddings_route.py tests/unit/test_llm_gateway_coverage_guardrails.py tests/unit/test_desktop_proxy.py— 162 passedpytest tests/unit/test_chat_file_completions.py tests/unit/test_vertex_pt_routing.py tests/unit/test_llm_gateway_validator.py— 84 passedscripts/pr-preflight --suggestthenOMI_PR_BODY_FILE=… make preflightCould not exercise live Vertex/OpenAI hops from this host (no production credentials / no traffic shift).
Closes SCA-365
Product invariants affected
none
Failure class (fixes)
Failure-Class: none