Skip to content

fix(OMN-12664): preserve full Gemini endpoint path in bifrost gateway - #1859

Merged
jonahgabriel merged 1 commit into
devfrom
jonah/omn-12664-bifrost-gemini-endpoint
Jun 4, 2026
Merged

jonahgabriel merged 1 commit into
devfrom
jonah/omn-12664-bifrost-gemini-endpoint

Conversation

@jonahgabriel

@jonahgabriel jonahgabriel commented Jun 4, 2026 •

Copy link
Copy Markdown
Collaborator

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/openai path and posted to /v1/chat/completions, producing a 404. The bifrost gateway fed every backend URL through ModelLlmInferenceRequest.base_url, so the OpenAI-compatible handler (_build_url) appended /v1/chat/completions even when the configured URL was already a complete chat endpoint. Two 404 variants resulted:

  • bare-origin base -> https://generativelanguage.googleapis.com/v1/chat/completions
  • /v1beta/openai base -> https://generativelanguage.googleapis.com/v1beta/openai/v1/chat/completions

The registered endpoint is https://generativelanguage.googleapis.com/v1beta/openai/chat/completions.

Changes

  1. handler_bifrost_gateway.py::_build_inference_request — when a backend's configured base_url is already a complete chat endpoint (ends in /chat/completions or /completions), route it through endpoint_url so _build_url posts it verbatim with no second path append. Structural URL-shape check, not a provider sniff. _build_url itself is unchanged (it was already correct, OMN-10489).
  2. config_loader_bifrost.py — the Gemini default now resolves to the full https://generativelanguage.googleapis.com/v1beta/openai/chat/completions endpoint instead of the bare origin. Gemini-only; local and GLM backends are untouched and keep their legacy base_url append 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 verbatim
    • test_no_double_append_for_full_chat_endpoint — the /v1beta/openai/v1/chat/completions 404 variant is NOT produced
    • test_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 path
    • test_local_openai_backend_unaffected, test_local_full_endpoint_routes_through_endpoint_url, test_trailing_slash_full_endpoint_detected — non-Gemini / structural-detection coverage
  • tests/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 passed
  • new + config-loader regression tests -> 19 passed
  • uv 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 issues
  • pre-commit run --files <changed files> -> all hooks Passed
  • Full suite uv 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) and test_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 is https://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

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.
@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@jonahgabriel, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d2dcc891-956d-491e-ab3b-84b3465a28ef

📥 Commits

Reviewing files that changed from the base of the PR and between d30f05d and b60665c.

📒 Files selected for processing (4)
  • src/omnibase_infra/nodes/node_llm_inference_effect/handlers/bifrost/config_loader_bifrost.py
  • src/omnibase_infra/nodes/node_llm_inference_effect/handlers/bifrost/handler_bifrost_gateway.py
  • tests/unit/nodes/node_llm_inference_effect/handlers/bifrost/test_bifrost_endpoint_preservation.py
  • tests/unit/nodes/node_llm_inference_effect/handlers/bifrost/test_config_loader_bifrost.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jonah/omn-12664-bifrost-gemini-endpoint

Comment @coderabbitai help to get the list of available commands and usage tips.

@jonahgabriel
jonahgabriel enabled auto-merge June 4, 2026 03:10
@jonahgabriel
jonahgabriel added this pull request to the merge queue Jun 4, 2026
Merged via the queue into dev with commit 73af6fa Jun 4, 2026
71 of 74 checks passed
@jonahgabriel
jonahgabriel deleted the jonah/omn-12664-bifrost-gemini-endpoint branch June 4, 2026 03:40
Zeeeepa pushed a commit to Zeeeepa/omnibase_infra that referenced this pull request Jun 14, 2026
… gateway (OmniNode-ai#1859)" (OmniNode-ai#1863)

This reverts commit 73af6fa.

Co-authored-by: jonahgabriel <jonahgabriel@users.noreply.github.com>
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