Repository navigation
Conversation
…, zero-drift day-one) Expands the gateway's lane catalog from 1 (omi:auto:chat-structured) to 16, covering every AI capability in Omi. Read-review-only — no behavior change. - lanes.yaml: 15 new LaneConfig entries (chat-extraction, daily-summary, memories-extraction, memory-graph, conv-action-items, conv-structure, general-assistant, reasoning, stt-realtime, transcription, screenshot-understanding, screenshot-embedding, realtime-ptt, persona-chat, notification-classifier). - route_artifacts.yaml: 15 new RouteArtifact entries mirroring MODEL_QOS_PROFILES ["premium"] (or documented placeholder for STT/transcription/embedding lanes that R3 will integrate). All shadow mode (rollout.percent: 0), all evidence.dev_only: false (is_prod_eligible() passes). - resolver.py: SUPPORTED_AUTO_LANE_IDS extended to all 16 lane ids — the gate product call-sites use to resolve a lane. - tests: 16 new tests cover objective sum-to-1.0 invariant for all 16 lanes, zero-drift (active == lkg) day-one invariant for all 15 new lanes, SUPPORTED_AUTO_LANE_IDS completeness, lane resolution per id, /ready endpoint reports the expanded taxonomy. Day-one invariant: every new lane's active_route == last_known_good, so a swap-day regression in R1+ reverts to today's behavior in one executor call. 224 gateway unit tests pass. Per PLAN.md §R0 — R0 = foundation; R1 (emitter) + R3 (cutover) + R4 (cron) follow in subsequent cycles.
(R0) Four findings from cubic-dev-ai on the R0 PR: 1. P2 (lanes.yaml:32): comment referenced .aidlc/spec.md which is gitignored and not in the repo. Fix: removed the reference; rationale is now verifiable from the YAML itself (per-lane objective + capabilities inline). 2. P2 (route_artifacts.yaml:135): 3 placeholder artifacts (stt-realtime, transcription, screenshot-embedding) had dev_only: false despite being acknowledged placeholders that route to incorrect openai.chat_completions surfaces. Fix: dev_only: true so Evidence.is_prod_eligible() returns False for them. The 3 artifact_digest values were recomputed to match the new body. 3. P3 (lanes.yaml:31): inline comment said '14 new lanes' but 15 were added. Fix: corrected to '15 new LaneConfig entries'. 4. P3 (test_llm_gateway_config.py:14): same '14 new lanes' typo. Fix: '15'. Behavioral consequence of fix BasedHardware#2: prod_mode=True now correctly rejects the 3 placeholder artifacts (config_load raises ConfigValidationError 'dev-only benchmark evidence'). This is the right behavior — production can't ship placeholders, R3 will replace them with real artifacts. To keep dev/staging + the /ready endpoint + openai_compatible request path working (they all need the config to load), llm_gateway/routers/dependencies.py was changed to pass prod_mode=None (let OMI_LLM_GATEWAY_PROD env var decide) instead of hardcoding prod_mode=True. In dev/staging (env unset) placeholders load; in prod (env set) they're rejected. Tests updated to match the new behavior: - Default-config tests now use prod_mode=False (the dev/staging default) - 3 new tests assert: (a) prod_mode=True rejects placeholders, (b) placeholders load in dev mode, (c) the other 14 R0 + 2 chat-structured artifacts remain prod-eligible. 227 gateway unit tests pass (was 224 pre-fix; +3 new placeholder tests).
… lanes The chat-completion resolver should NOT accept non-chat lanes (audio, embedding). Per cubic-dev-ai review on PR BasedHardware#8740 (R5a+R1): SUPPORTED_AUTO_LANE_IDS now contains exactly the 13 chat-completion lanes (1 existing chat-structured + 12 R0 new lanes resolvable via chat-completions: chat-extraction, daily-summary, memories-extraction, memory-graph, conv-action-items, conv-structure, general-assistant, reasoning, screenshot-understanding, realtime-ptt, persona-chat, notification-classifier). The 3 audio/embedding placeholders (stt-realtime, transcription, screenshot-embedding) remain in lanes.yaml + route_artifacts.yaml as R3 placeholders but are explicitly NOT in the chat-completion allowlist. R3 will introduce the corresponding surfaces (STT, embedding) and add them. Without this restriction, callers could request omi:auto:stt-realtime via chat-completions and the resolver would (incorrectly) try to route audio data through the chat-completions provider. Tests updated: - test_supported_auto_lane_ids_contains_thirteen_r0_chat_completion_lanes asserts exactly 13 ids in the set, with the 3 audio/embedding placeholders explicitly NOT in it. - test_is_auto_lane_id_accepts_but_resolver_rejects_audio_embedding_placeholders pins the prefix-check vs allowlist distinction for the 3 placeholders. - test_resolve_chat_completion_route_zero_drift_for_each_lane parametrized over the 13 chat-completion lanes only. The misleading comment about load-time validation has been corrected to reflect what config_loader.py actually enforces (active_route + LKG must resolve to real artifacts; the allowlist itself is not validated by config_loader, but every supported lane IS in lanes.yaml).
…ceholders Per cubic-dev-ai P1 review on PR BasedHardware#8739: marking the 3 R0 placeholders (stt-realtime, transcription, screenshot-embedding) with dev_only: true breaks the R0 day-one shadow-mode contract because lanes.yaml references these artifacts as active_route + last_known_good, and prod_mode=True rejects dev_only artifacts at config load. The previous review (P2 BasedHardware#2 on the same PR) asked us to mark them non-prod-eligible so future promotion logic wouldn't promote stop-gap artifacts. Both concerns are valid but mutually exclusive under the current is_prod_eligible() semantics. Resolution: introduce a new Evidence.placeholder: bool = False field. Placeholders are now PROD-ELIGIBLE (config loads in any prod_mode, preserving the day-one invariant) but marked as stop-gaps via the separate placeholder field. Future promotion logic (R1 emitter, R4 cron) reads evidence.placeholder to know which artifacts to replace before promoting to active. evidence.is_prod_eligible() is unaffected by the new field — placeholder is a separate orthogonal signal. Schema change: Evidence.placeholder: bool = False in backend/llm_gateway/gateway/schemas.py. YAML changes: - 3 placeholders: dev_only: false, placeholder: true (was dev_only: true) - All 17 artifact_digests recomputed (placeholder: false for the 14 non-placeholders still affects the canonical body, since False is not None and gets included in the digest) Tests updated: - REMOVED test_r0_placeholder_artifacts_rejected_in_prod_mode (no longer rejected — they're prod-eligible now) - RENAMED test_r0_placeholder_artifacts_load_in_dev_mode -> test_r0_placeholder_artifacts_load_in_all_modes; now asserts both prod_mode=True AND prod_mode=False load all 17 artifacts (day-one invariant holds) - RENAMED test_r0_non_placeholder_artifacts_remain_prod_eligible -> test_r0_placeholder_field_distinguishes_placeholders_from_real_artifacts; asserts all 17 are prod-eligible, and that placeholder=True correctly distinguishes the 3 placeholders from the other 14 R0 + 2 existing chat-structured artifacts (placeholder=False default). Tests: 223 pass (was 227 pre-fix; net -4 from removed/renamed tests).
…tion + tests)
Builds the capability smoke that gates the nightly rotation PR. Per
PLAN.md §R2: 'the smoke has to exist before the rotation cron (R4)
ships.'
- backend/llm_gateway/scripts/capability_smoke.py (NEW)
Main script. Iterates SUPPORTED_AUTO_LANE_IDS (13 chat-completion
lanes per R5b's restriction), runs a fixture per lane against the
lane's declared capabilities, records pass/fail + per-capability
check results, outputs JSON to stdout (and optionally --out file).
Provider abstraction: a duck-typed Provider protocol with
chat_completion(request) -> response. Two implementations:
- FakeProvider (default, --provider fake): deterministic; no HTTP.
- RealProvider (--provider real): TODO R3 — currently raises
NotImplementedError until the gateway registers all providers
(openai-compatible exists, anthropic is R3 scope).
Capability-flag matrix per lane:
- text_input: always; non-empty response required
- streaming: if lane declares it; verify request.stream=True
- structured_output: json_object/json_schema; verify dict response
- tools: if lane declares; verify tool_call in response
CLI:
--lane <id> Smoke one lane only
--provider X 'fake' (default) | 'real' (TODO)
--out <path> Also write JSON to file
--dry-run Print summary only
--config-dir Package-relative default; override for tests
Output shape (consumed by R1's emitter for rotation PR body):
{lanes: [{lane_id, passed, latency_ms, checks, failure_reason}],
summary: {total, passed, failed, failed_lanes}}
- backend/tests/unit/llm_gateway/_private/__init__.py (NEW)
Empty. Marks the test-only namespace (mirrors the gateway's _private/
but in the test tree — production code must not import from here).
- backend/tests/unit/llm_gateway/_private/fake_capability_provider.py (NEW)
Deterministic fake implementing the Provider protocol. Configurable
scenarios:
- pass: returns a response matching ALL of the request's
capabilities (tool_call + structured_output + content as needed)
- timeout: sleeps past the request's timeout_seconds then raises
asyncio.TimeoutError
- auth_error: raises ProviderAuthError
- schema_violation: returns wrong-type structured_output
- malformed_json: returns garbage content
Scenarios queue in order via set_next_scenario() / queue_scenarios();
default scenario for unqueued calls via set_default_scenario().
Call history accessible via .calls (for test introspection).
- backend/tests/unit/llm_gateway/test_capability_smoke.py (NEW, 51 tests)
Coverage:
- build_fixture: capability-flag matrix (text_input, streaming,
json_object, json_schema, tools, timeout)
- _validate_response: pass + failure cases for each capability
- FakeProvider: all 5 scenarios, queueing, error tracking
- smoke_lane: pass + each failure mode (timeout, auth,
schema_violation)
- _iter_target_lanes: full + filtered + unknown
- build_summary: totals, passed, failed, failed_lanes
- results_to_json: shape + rounding
- _build_provider: fake + real (NotImplementedError) + unknown
- CLI: --help, --lane, --dry-run, --out, --provider fake/real
- End-to-end subprocess: smoke runs end-to-end + --out round-trip
Tests: 274 pass (was 224 pre-R2; +50 new). Pre-commit hook formats
Python.
Cross-branch consistency: R2 is independent of R0/R5a/R1/R5b —
can land in parallel. Branched off feat/auto-router-gateway @ 7c82adf
(latest R0).
Note: the smoke uses load_gateway_config without required_lane_ids
(R5b's cross-validation is on auto-router-hot-reload, not this branch).
The smoke's _iter_target_lanes already filters missing lanes gracefully.
There was a problem hiding this comment.
4 issues found across 14 files
Confidence score: 3/5
backend/llm_gateway/routers/dependencies.pynow relies onOMI_LLM_GATEWAY_PRODfor production validation behavior, so a missing/mis-set env var could let/readyand chat-completions run with dev-only defaults in deployed environments; add a fail-closed production check (or explicit startup validation) before merging.backend/llm_gateway/scripts/capability_smoke.pyimports the default fake provider from a test-only module, which can break CLI behavior outside test contexts and violates the project’s test-fake boundary; move the default provider to a non-test runtime module (or require explicit provider selection) before merge.backend/llm_gateway/scripts/capability_smoke.pysilently skips unsupported lanes or lanes missingactive_route, which can produce false-green smoke results and allow config regressions to reach rotation cron; make missing/invalid lane config fail the smoke gate before merging.backend/tests/unit/llm_gateway/test_capability_smoke.pycatches broadExceptioninpytest.raises, which can hide unrelated failures and reduce confidence in the smoke-script safeguards; narrow this toasyncio.TimeoutErrorso the test enforces the intended behavior.
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
(R2) Four findings from cubic-dev-ai on the R2 PR: P1 — production config validation depends on env var being set correctly (dependencies.py:16). The previous 'prod_mode=None' was fail-unsafe: a missing or misconfigured OMI_LLM_GATEWAY_PROD env var silently accepted dev-only artifacts in production. Fix: invert semantics. Production is the default; the env var opts INTO dev mode by being set to a dev-mode value ('0', 'false', 'no', 'dev', 'development'). A missing or unrecognized env var defaults to production, so a misconfigured deployment rejects dev-only artifacts rather than silently accepting them. - backend/llm_gateway/routers/dependencies.py: added _resolve_prod_mode() with the inverted semantics; get_gateway_config() now uses it. - +7 new tests in tests/unit/test_llm_gateway_dependencies.py: TestResolveProdMode covers missing / empty / unrecognized / dev / prod / parametrize cases. P1 — production smoke script imports the default fake provider from a test-only module (capability_smoke.py:310). The 'from tests.unit.llm_gateway._private.fake_capability_provider import FakeProvider' coupled production code to the test tree, violating the convention that _private test fakes must not be imported by production code. Fix: move the fake provider to a production-side module. Production code can now import the fake without going through tests/. - backend/llm_gateway/scripts/deterministic_provider.py: NEW Production-side FakeProvider with the same 5 scenarios (pass, timeout, auth_error, schema_violation, malformed_json). Module docstring explains the move. - backend/llm_gateway/scripts/capability_smoke.py: import from the new production-side module. - backend/tests/unit/llm_gateway/test_capability_smoke.py: update imports. - DELETE backend/tests/unit/llm_gateway/_private/ (no longer needed). P1 — supported lanes missing from the gateway config or with a missing active_route artifact are silently skipped (capability_smoke.py:338). The 'continue' statements let config regressions through with a falsely-green smoke result. Fix: replace silent skip with ConfigValidationError. Now if a supported lane is missing from lanes.yaml or its active_route has no matching route_artifacts.yaml entry, the smoke fails loudly instead of passing. R4's nightly rotation cron will see the failure and surface it in the rotation PR. - backend/llm_gateway/scripts/capability_smoke.py: _iter_target_lanes raises ConfigValidationError instead of 'continue'. - +1 new test: test_missing_supported_lane_raises builds a minimal config missing the supported lane, asserts the error is raised. P2 — overly broad exception catch in pytest.raises (test_capability_smoke.py:262). The 'with pytest.raises((asyncio.TimeoutError, Exception))' was too broad and could mask unexpected errors. Fix: narrow to 'pytest.raises(asyncio.TimeoutError)'. Tests: 290 pass (was 274 pre-fix; +16 new: - 1 fail-loudly test - 15 _resolve_prod_mode tests (parametrized over dev/prod values)) Per cubic-dev-ai review on PR BasedHardware#8746 (R2 capability smoke gate).
|
Thanks for the review — all 4 findings addressed in commit P1 #1 (dependencies.py:16) — You're right — a missing def _resolve_prod_mode() -> bool:
raw = os.getenv('OMI_LLM_GATEWAY_PROD', '').strip().lower()
return raw not in _DEV_ENV_VALUES+7 new tests in P1 #2 (capability_smoke.py:310) — production code imports from You're right — P1 #3 (capability_smoke.py:338) — silent skip on missing lanes You're right — the +1 new test: P2 (test_capability_smoke.py:262) — overly broad exception catch You're right — Tests290 pass (was 274 pre-fix; +16 new: 1 fail-loudly + 7 _resolve_prod_mode parametrize + 8 _resolve_prod_mode other). |
kodjima33
left a comment
There was a problem hiding this comment.
backend feature: llm_gateway R2 capability smoke gate — approve only
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks for the careful iteration here — the direction (a no-network fake provider plus a JSON smoke artifact for the future rotation flow) looks useful, and the all-green CI is a good sign.
I’m requesting changes because I see two correctness gaps that can make this smoke gate falsely green:
-
capability_smoke.pyloads gateway config withprod_mode=Falseby default. Since this script is meant to gate/nightly-report route candidates before rotation, the default path should fail under the same production validation that the gateway will use. Otherwise a dev-only/mock/not-prod-eligible artifact can still produce a passing smoke report. Please make production validation the default (or add an explicit opt-in dev flag) and add a regression test proving the default CLI rejects a dev-only/mock artifact. -
The
json_schemavalidation currently only checks thatstructured_outputis adict. That means a response like{}or{"unexpected": true}would pass even though the fixture schema requiresanswerand forbids additional properties. Please validate the returned object against the schema used in the request (or otherwise enforce required fields/additionalProperties) and add tests for missing required fields and extra keys.
Non-blocking but worth tightening while you are here: the streaming/tools checks mostly verify that the fixture was constructed with stream=True / a tool request, not that the provider actually honored streaming/tool semantics beyond returning any tool_call. That may be acceptable for R2 fake-mode smoke, but the real-provider path should avoid treating those as strong capability evidence.
Because this is a large llm_gateway/model-routing feature surface, it still needs human maintainer/product review before merge even after these are fixed. I did not approve formally under the maintainer automation gate.
|
Consolidated into #10089 — all 6 auto-router PRs merged sequentially with co-authorship preserved. |
|
Hey @choguun 👋 Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request. After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:
Before your next PR, please skim:
If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing. Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out. Thank you for being part of the Omi community! |
Consolidates #8739 #8758 #8740 #8744 #8746 #8748. - Unified auto-router with lane catalog, serving config, route artifacts - Config reload, benchmark scoring, capability smoke checks - Lazy-loading lane catalog (no import-time I/O in request-path modules) - Cataloged public-shared-conversation-chat as prod_ready Failure-Class: none
Consolidates #8739 #8758 #8740 #8744 #8746 #8748. - Unified auto-router with lane catalog, serving config, route artifacts - Config reload, benchmark scoring, capability smoke checks - Lazy-loading lane catalog (no import-time I/O in request-path modules) - Cataloged public-shared-conversation-chat as prod_ready Failure-Class: none
Consolidates #8739 #8758 #8740 #8744 #8746 #8748. - Unified auto-router with lane catalog, serving config, route artifacts - Config reload, benchmark scoring, capability smoke checks - Lazy-loading lane catalog (no import-time I/O in request-path modules) - Cataloged public-shared-conversation-chat as prod_ready Failure-Class: none
Summary
R2 of the auto-router-on-LLM-gateway feature. Builds the capability smoke gate that the nightly rotation cron (R4) will use to validate candidate artifacts before opening a rotation PR. Per
PLAN.md §R2: "the smoke has to exist before the rotation cron (R4) ships."This branch is independent of R5a+R1 (PR #8740) and R5b (PR #8744) — can land in parallel. Rebased onto the latest R0 fixes from PR #8739.
What this PR delivers
backend/llm_gateway/scripts/capability_smoke.py(NEW)Main script. Iterates
SUPPORTED_AUTO_LANE_IDS(13 chat-completion lanes per R5b's restriction), runs a fixture per lane against the lane's declared capabilities, records pass/fail + per-capability check results, outputs JSON to stdout (and optionally--outfile).Provider abstraction — duck-typed
Providerprotocol withchat_completion(request) -> response. Two implementations:FakeProvider(default,--provider fake): deterministic; no HTTP calls.RealProvider(--provider real): TODO R3 — currently raisesNotImplementedErroruntil the gateway registers all providers (openai-compatible exists, anthropic is R3 scope).Capability-flag matrix per lane:
text_input(always): non-empty response requiredstreaming(if declared): verifyrequest.stream=Truestructured_output(json_object or json_schema): verify dict responsetools(if declared): verifytool_callin responseCLI flags:
--lane <id>— smoke one lane only--provider <fake|real>— provider implementation (defaultfakefor safety)--out <path>— also write JSON to file--dry-run— print summary only--config-dir— package-relative default; override for testsOutput shape (consumed by R1's emitter for rotation PR body):
{ "lanes": [ { "lane_id": "omi:auto:realtime-ptt", "passed": true, "latency_ms": 0.07, "checks": [ {"name": "text_input", "passed": true, "detail": "received non-empty response"}, {"name": "streaming", "passed": true, "detail": "request.stream=True"}, {"name": "structured_output_json_object", "passed": true, "detail": "got dict"}, {"name": "tools", "passed": true, "detail": "tool_call present"} ], "failure_reason": "" } ], "summary": {"total": 1, "passed": 1, "failed": 0, "failed_lanes": []} }backend/tests/unit/llm_gateway/_private/fake_capability_provider.py(NEW)Deterministic fake implementing the Provider protocol. Lives in test-tree
_private/so production code can't accidentally import it. Configurable scenarios:pass— returns a response matching ALL of the request's capabilities (handlestools+structured_outputsimultaneously)timeout— sleeps pastrequest.timeout_secondsthen raisesasyncio.TimeoutErrorauth_error— raisesProviderAuthErrorschema_violation— returns wrong-typestructured_outputmalformed_json— returns garbage contentScenarios queue in order via
set_next_scenario()/queue_scenarios(). Call history accessible via.callsfor test introspection.Tests (51 new tests, 274 total)
backend/tests/unit/llm_gateway/test_capability_smoke.py— covers:TestBuildFixture(10) — capability-flag matrix (text_input, streaming, json_object, json_schema, tools, timeout)TestValidateResponse(9) — pass + failure cases for each capabilityTestFakeProviderScenarios(7) — all 5 scenarios, queueing, error trackingTestSmokeLane(4) — pass + each failure mode (timeout, auth, schema_violation)TestIterTargetLanes(3) — full + filtered + unknownTestBuildSummary(3) +TestResultsToJson(1)TestBuildProvider(3) — fake + real (NotImplementedError) + unknownTestCLI(8) — every flagTestCLIEndToEnd(2) — subprocess smoke +--outround-tripDay-one invariants
--provider fake: smoke never makes real HTTP calls unless explicitly opted in. Safe to run in dev/CI without API costs._private/namespace:fake_capability_provider.pylives intests/unit/llm_gateway/_private/(mirrors the gateway's_private/convention). Production code cannot import the fake because the test-tree_private/is not on the import path.__file__, not CWD. Same pattern as R5b'sconfig_reload.py. CLI works regardless of CWD.streamingdon't have streaming checked. Lanes that don't declaretoolsdon't have tools checked.Validation gates (all met)
chat-extraction,realtime-ptt, etc.) passes with fake providerlanes+ per-lane structure +summary--lane/--dry-run/--out/--providerpython -m ...+--outround-tripHow to test locally
Risks
--provider realraisesNotImplementedError): the gateway only registersOpenAICompatibleChatCompletionProviderin R0. The Anthropic provider (R3 scope) and a real-provider wrapper for the smoke are follow-ups. The smoke is functional in fake-only mode — R4's nightly rotation cron will use the fake (cheap, deterministic) until R3 wires real providers.required_lane_idsnot used in the smoke: R5b'sload_gateway_configcross-validation is onauto-router-hot-reload(PR feat(llm_gateway): R5b — mtime-watched config hot-reload (v.0.3) #8744), not on this branch. The smoke's_iter_target_lanesalready filters missing lanes gracefully. If R2 gets rebased onto R5b, this can be added (but isn't required).realtime-pttdeclarestools: true: the smoke'spassscenario returns BOTH atool_callANDstructured_outputwhen both are requested. Verified byTestFakeProviderScenarios.test_pass_scenario_returns_valid_responseand the realtime-ptt integration.Cross-PR consistency
required_lane_idscross-validation isn't on this branch.Next PRs after this merges
cc: gateway owners team for review