Repository navigation
fix(OMN-12664): preserve full Gemini endpoint path in bifrost gateway - #1859
Conversation
The bifrost gateway fed every backend URL through ModelLlmInferenceRequest.base_url, so the OpenAI-compatible handler appended /v1/chat/completions even when the configured URL was already a complete chat endpoint. For cloud Gemini this produced 404s: - bare origin base -> .../v1/chat/completions - /v1beta/openai base -> .../v1beta/openai/v1/chat/completions The registered endpoint is .../v1beta/openai/chat/completions. Fix: - _build_inference_request now routes a configured base_url that is already a complete chat endpoint (ends in /chat/completions or /completions) through endpoint_url, which _build_url posts verbatim (no second path append). This is a structural URL-shape check, not a provider sniff; no new router/adapter. - The Gemini default in config_loader_bifrost now resolves to the full /v1beta/openai/chat/completions endpoint instead of the bare origin. Gemini-only; local and GLM backends keep their bare base_url and the legacy append path. Adds regression tests covering both 404 variants, no-double-append, no truncation, and confirms non-Gemini backends are unaffected.
|
Warning Review limit reached
More reviews will be available in 19 minutes and 6 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
… gateway (OmniNode-ai#1859)" (OmniNode-ai#1863) This reverts commit 73af6fa. Co-authored-by: jonahgabriel <jonahgabriel@users.noreply.github.com>
OMN-12664: Preserve full Gemini endpoint path in bifrost gateway (omnibase_infra side)
Workstream A of
docs/plans/2026-06-03-late-day-contractor-live-path-stabilization.md. Cross-repo with the omnimarket side.Problem
The cloud-tier Gemini call dropped the registered
/v1beta/openaipath and posted to/v1/chat/completions, producing a 404. The bifrost gateway fed every backend URL throughModelLlmInferenceRequest.base_url, so the OpenAI-compatible handler (_build_url) appended/v1/chat/completionseven when the configured URL was already a complete chat endpoint. Two 404 variants resulted:https://generativelanguage.googleapis.com/v1/chat/completions/v1beta/openaibase ->https://generativelanguage.googleapis.com/v1beta/openai/v1/chat/completionsThe registered endpoint is
https://generativelanguage.googleapis.com/v1beta/openai/chat/completions.Changes
handler_bifrost_gateway.py::_build_inference_request— when a backend's configuredbase_urlis already a complete chat endpoint (ends in/chat/completionsor/completions), route it throughendpoint_urlso_build_urlposts it verbatim with no second path append. Structural URL-shape check, not a provider sniff._build_urlitself is unchanged (it was already correct, OMN-10489).config_loader_bifrost.py— the Gemini default now resolves to the fullhttps://generativelanguage.googleapis.com/v1beta/openai/chat/completionsendpoint instead of the bare origin. Gemini-only; local and GLM backends are untouched and keep their legacybase_urlappend path.No new router/adapter/module that selects behavior by provider (WS-A acceptance + ONEX_CANONICAL_ARCHITECTURE).
dod_evidence
What changed: 2 source files (
handler_bifrost_gateway.py,config_loader_bifrost.py) + 2 test files.Tests (new + updated):
tests/unit/.../bifrost/test_bifrost_endpoint_preservation.py(new):test_full_gemini_endpoint_routes_through_endpoint_url— full endpoint posts verbatimtest_no_double_append_for_full_chat_endpoint— the/v1beta/openai/v1/chat/completions404 variant is NOT producedtest_gemini_openai_base_is_not_a_full_endpoint— documents the 2nd 404 variant (why the default must be the complete endpoint)test_gemini_bare_origin_does_not_truncate_path— 1st 404 variant via legacy pathtest_local_openai_backend_unaffected,test_local_full_endpoint_routes_through_endpoint_url,test_trailing_slash_full_endpoint_detected— non-Gemini / structural-detection coveragetests/unit/.../bifrost/test_config_loader_bifrost.py(updated): Gemini default now carries/v1beta/openai/chat/completions; explicit override preserved; non-Gemini backends unchanged.Local gates (run in worktree, no -k filter):
uv run pytest tests/unit/nodes/node_llm_inference_effect/-> 466 passeduv run ruff format/ruff check --fix src/ tests/-> clean (warnings are pre-existing in unrelated files)uv run mypy <two touched src files> --strict-> Success, no issuespre-commit run --files <changed files>-> all hooks Passeduv run pytest tests/ -m "not slow and not integration and not kafka and not postgres and not consul and not chaos and not performance"-> 20998 passed, 2 failed. Both failures are pre-existing and unrelated to this change (neither test file is in this PR's diff):test_node_migration_discovery::test_sync_check_reports_in_sync(local omnimarket migration vendor drift) andtest_receipt_gate_install_guard(CI install-script content check).Transport-mode / URL proof: regression tests assert the resolved POST URL via
HandlerLlmOpenaiCompatible._build_url. For the Gemini full endpoint the resolved URL ishttps://generativelanguage.googleapis.com/v1beta/openai/chat/completions(posted as-is). No live.201/runtime mutation was performed (code+PR only per plan).Cross-repo
Sibling omnimarket PR: OmniNode-ai/omnimarket#1031
Evidence-Source: OCC#2141
Evidence-Ticket: OMN-12664