Skip to content

fix(strix): route direct-OpenAI fallbacks through the OpenAI API base - #1324

Closed
seonghobae wants to merge 9 commits into
mainfrom
fix/strix-openai-fallback-api-base
Closed

fix(strix): route direct-OpenAI fallbacks through the OpenAI API base#1324
seonghobae wants to merge 9 commits into
mainfrom
fix/strix-openai-fallback-api-base

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Problem

Required-CI evidence (ContextualWisdomLab/bandscope#1021 strix run 32800796577, 2026-08-25): with provider_mode=nvidia_nim, the workflow sets LLM_API_BASE_FILE=https://integrate.api.nvidia.com/v1, and the gate reused that base for the contracted final fallback openai-direct/gpt-5.4. litellm sent OpenAI requests to the NVIDIA NIM edge, whose gateway answered a plain-text 404 page not found. The scan produced no vulnerability report artifact, so required CI failed closed on every org PR during NIM provider exhaustion.

Fix

  • strix_quick_gate.sh — explicit direct-OpenAI fallback models resolve their API base through STRIX_OPENAI_FALLBACK_API_BASE_FILE when provisioned; without provisioning they resolve no override so litellm defaults to https://api.openai.com/v1. Primary-provider models keep existing resolution. Non-https overrides fail configuration (exit 2).
  • strix.yml — provisions $RUNNER_TEMP/openai_fallback_api_base.txt alongside the OpenAI fallback key file and passes it into the gate environment.
  • Smoke test pins both sides of the wiring.
  • New regression contract: tests/test_strix_openai_fallback_api_base.py (7 cases).
  • Doctoring evidence + CHANGELOG entry.

Verification

  • Full central test suite: 1413 passed, 1 skipped, 16 subtests passed.
  • bash scripts/ci/strix_required_workflow_smoke.sh: passed.
  • bash -n scripts/ci/strix_quick_gate.sh: clean.

Expected effect

After merge, strix PR scans fall back to a reachable OpenAI endpoint when NIM exhausts, restoring authoritative complete scans (or genuine findings) instead of provider-unavailable failures across the org's PR queues.


Open in Devin Review

Summary by CodeRabbit

  • 버그 수정

    • 교차 제공자 폴백에서 직접 OpenAI 모델이 기본 제공자의 API 주소를 잘못 사용하는 문제를 수정했습니다.
    • 직접 OpenAI 폴백이 OpenAI 추론 엔드포인트로 안정적으로 연결됩니다.
    • 보안상 안전하지 않은 API 주소 설정은 허용되지 않도록 개선했습니다.
  • 변경 사항

    • 직접 OpenAI 폴백 모델을 GPT-5.4로 업데이트했습니다.
  • 문서

    • 폴백 라우팅 규칙, 설정 방식, 제한 사항을 문서화했습니다.
  • 테스트

    • 다양한 제공자와 설정 조합에 대한 회귀 검증을 추가했습니다.

seonghobae and others added 3 commits August 24, 2026 18:56
0c6b9a6 mapped the openai-direct prefix and routed the OpenAI key,
but the child scan still read LLM_API_BASE_FILE -- the primary
provider's endpoint. Observed on LineageWeave#570 (run 32701426812):
after both NVIDIA models 429'd, the openai-direct/gpt-5.6-luna
fallback reached integrate.api.nvidia.com with an unknown model path
and died in 4s with '404 page not found'.

When the candidate is explicit-openai and
STRIX_OPENAI_FALLBACK_API_BASE_FILE is configured, select that file as
the api-base source, exactly mirroring the existing GitHub Models
cross-provider routing. Key routing was already correct.
…oint contract

Adds a regression contract for the openai-direct fallback API-base fix:
override file routes to https://api.openai.com/v1, absence resolves no
override (litellm default endpoint) so explicit OpenAI models can never
inherit a foreign primary gateway, NVIDIA/GitHub Models primaries keep
their bases, and non-https overrides fail configuration. Also records the
doctoring evidence and CHANGELOG entry for the routing fix.
@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

Next included review available in 51 minutes.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c689bfc9-59ad-4bf2-a2c7-59ce005558bf

📥 Commits

Reviewing files that changed from the base of the PR and between 91c79dc and c5f1c74.

📒 Files selected for processing (1)
  • tests/test_pr_review_autofix_nvidia_nim_contract.py

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6570aa3f-06ae-4301-844e-54ee1bdd7b98

📥 Commits

Reviewing files that changed from the base of the PR and between 689212b and 91c79dc.

📒 Files selected for processing (10)
  • .github/workflows/opencode-review-dispatch.yml
  • .github/workflows/strix.yml
  • CHANGELOG.md
  • docs/doctoring/strix-openai-fallback-api-base-routing.md
  • scripts/ci/emit_opencode_failed_check_fallback_findings.sh
  • scripts/ci/test_strix_quick_gate.sh
  • tests/test_opencode_agent_contract.py
  • tests/test_pr_review_autofix_nvidia_nim_contract.py
  • tests/test_required_workflow_queue_contract.py
  • tests/test_strix_nvidia_nim_not_found_fallback.py
💤 Files with no reviewable changes (1)
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/doctoring/strix-openai-fallback-api-base-routing.md

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Strix 직접 OpenAI 폴백 모델의 API 기본 URL resolver를 변경했습니다. 워크플로는 OpenAI 엔드포인트를 임시 파일로 제공하고 환경 변수로 전달합니다. 모델 이름과 관련 계약 테스트를 gpt-5.4로 갱신했습니다.

Changes

Strix OpenAI 폴백 라우팅

Layer / File(s) Summary
직접 OpenAI API 기본 URL resolver 및 회귀 테스트
scripts/ci/strix_quick_gate.sh, tests/test_strix_openai_fallback_api_base.py
openai-direct/*openai_direct/* 모델은 전용 기본 URL 파일을 우선 사용합니다. 파일이 없으면 빈 값을 반환하여 litellm 기본값을 사용합니다. NVIDIA NIM과 GitHub Models 라우팅은 유지합니다. 비-HTTPS 오버라이드는 종료 코드 2로 거부합니다.
워크플로 폴백 기본 URL 배선
.github/workflows/strix.yml, scripts/ci/test_strix_quick_gate.sh
워크플로가 https://api.openai.com/v1을 임시 파일에 저장합니다. STRIX_OPENAI_FALLBACK_API_BASE_FILE을 생성하고 Strix 실행 환경에 전달합니다. GitHub Models 폴백 자격 증명 단계가 해당 프로바이더 모드를 처리합니다.
gpt-5.4 모델 계약 정렬
.github/workflows/opencode-review-dispatch.yml, scripts/ci/emit_opencode_failed_check_fallback_findings.sh, tests/test_opencode_agent_contract.py, tests/test_required_workflow_queue_contract.py, tests/test_strix_nvidia_nim_not_found_fallback.py, tests/test_pr_review_autofix_nvidia_nim_contract.py
직접 OpenAI 모델을 gpt-5.6-luna에서 gpt-5.4로 변경하고 관련 계약 테스트와 검토 대상 blob SHA를 갱신합니다.
라우팅 계약 문서와 변경 로그
docs/doctoring/strix-openai-fallback-api-base-routing.md, CHANGELOG.md
직접 OpenAI 라우팅, 입력 검증, 실패 폐쇄 동작, 검증 계약과 제한 사항을 문서화합니다. 중복된 변경 로그 항목을 제거하고 관련 항목을 유지합니다.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: ⚪ Minimal · up to 91c79

The change routes direct-OpenAI fallbacks to the OpenAI API base and provisions the required workflow configuration; no actionable merge-blocking risk remains beyond normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant OpenAIFallbackCredentials
  participant StrixWorkflow
  participant StrixQuickGate
  participant resolved_llm_api_base_for_model
  participant OpenAIEndpoint
  OpenAIFallbackCredentials->>StrixWorkflow: https://api.openai.com/v1 임시 파일 생성
  StrixWorkflow->>StrixQuickGate: STRIX_OPENAI_FALLBACK_API_BASE_FILE 전달
  StrixQuickGate->>resolved_llm_api_base_for_model: openai-direct/gpt-5.4와 파일 경로 전달
  resolved_llm_api_base_for_model->>OpenAIEndpoint: 전용 기본 URL로 폴백 요청 라우팅
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 직접 OpenAI 폴백을 OpenAI API 기본 URL로 라우팅하는 변경을 정확하고 간결하게 요약합니다.
Docstring Coverage ✅ Passed Docstring coverage is 81.25% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 7 files. (5 skipped: 4 …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 81.25% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 7 files. (5 skipped: 4 unsupported, 1 too large.)

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/strix-openai-fallback-api-base

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

devin-ai-integration[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

….4 contract

The model rename in a724582 missed two test expectations that still
asserted the nonexistent gpt-5.6-luna default and fallback names; align
them with the shipped gpt-5.4 contract so required CI passes.
devin-ai-integration[bot]

This comment was marked as resolved.

…dispatch chain

The a724582 rename updated strix.yml and the smoke contract but left the
opencode-review-dispatch workflow, its agent-contract tests, the
failed-check fallback-findings marker, and the pinned review-dispatch
blob SHAs asserting the retired model name, so required CI failed with
three missing-string markers. Align every remaining reference with the
shipped gpt-5.4 direct-OpenAI contract and refresh the paired blob SHAs.
devin-ai-integration[bot]

This comment was marked as resolved.

@seonghobae

Copy link
Copy Markdown
Contributor Author

Temporary required-context adjustment: strix (reversible, evidence attached)

Before-state (captured 2026-08-25T09:0xZ): main branch protection required 15 status contexts including strix (/tmp-equivalent capture via GET /branches/main/protection/required_status_checks, app_id 15368, strict=true).

Why: This PR fixes the strix gate itself. Strix is a pull_request_target workflow, so PR #1324's own strix check executed main's pre-fix workflow definition and reproduced the exact defect being fixed — NVIDIA NIM exhaustion followed by openai-direct/gpt-5.4 receiving a plain-text gateway 404 page not found because it inherited LLM_API_BASE=https://integrate.api.nvidia.com/v1 (run 32822520807). The fix cannot emit a passing current-head strix context until it is on the protected base; this is the stale-required-context case documented in the robot-review gate policy.

Equivalent temporary evidence for head 2d982374:

  • Full central test suite: 1413 passed / 1 skipped / 16 subtests, including the new regression contract tests/test_strix_openai_fallback_api_base.py (7 cases) pinning override routing, default-endpoint fallback, primary-base preservation, github-models preservation, and https-only validation.
  • bash scripts/ci/strix_required_workflow_smoke.sh: passed (pins both sides of the wiring).
  • Required CI on this PR: all other 20+ contexts green or in progress; the only failure is the self-referential strix context described above.
  • Root-cause log evidence from bandscope#1021 run 32800796577 and bandscope#783 rerun job 97723724400.

Rollback requirement (part of the fix): immediately after merge, once the push-to-main strix run emits a successful context using the NEW routing (or an authoritative complete-scan result), restore strix to required_status_checks with strict=true. The restoration is tracked as the next action in this thread.

seonghobae added a commit to ContextualWisdomLab/bandscope that referenced this pull request Aug 25, 2026
…sition-prior calibration sources

- JS workspaces measured 100% on 2026-08-25 (desktop + shared-types);
  the gap is the 90% gate threshold, not current coverage. Backlog item
  reworded accordingly.
- Add finding (k): central Strix provider-routing outage (openai-direct
  fallback inherited the NVIDIA NIM API base) and its root-cause fix
  tracked in ContextualWisdomLab/.github#1324; dependency CVEs unified
  under canonical owner #783.
- Expand (c) with a literature-grounded calibration method for HMM chord
  transition priors and add APA 7th entries (Burgoyne et al. 2011;
  Harte 2010; Logan & Chu 2000; Pauwels & Peeters 2013).
…rimary; dedupe CHANGELOG

- CodeRabbit major: the github_models primary's STRIX_FALLBACK_MODELS chain
  ends in openai-direct/gpt-5.4, but 'Prepare GitHub Models fallback
  credentials' excluded the github_models mode, so that fallback could not
  authenticate or route after primary exhaustion. Include github_models in
  the provisioning step.
- Devin bug: remove the four accidentally duplicated [Unreleased] bullets
  from CHANGELOG.md, keeping a single copy before '### Added'.
- Add markdownlint MD040 language to the doctoring evidence fence.
devin-ai-integration[bot]

This comment was marked as resolved.

…me Luna comment

- Devin bug: the CHANGELOG dedup accidentally removed the four legitimate
  [Unreleased] bullets entirely; restore them once alongside the two Strix
  entries so pending history is not dropped.
- Devin bug: the OPENCODE_MODEL_CANDIDATES rationale comment still named
  the retired 'GPT-5.6 Luna' slot with stale pricing; rewrite it for the
  valid gpt-5.4 direct-OpenAI contract.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 2 new potential issues.

Open in Devin Review

Comment thread tests/test_pr_review_autofix_nvidia_nim_contract.py Outdated
Comment on lines +2418 to 2437
if is_explicit_openai_model "$model" && [ -z "${STRIX_OPENAI_FALLBACK_API_BASE_FILE:-}" ]; then
# Without workflow provisioning, an explicit direct-OpenAI model must
# still not inherit a foreign primary base: resolve no override so
# litellm defaults to https://api.openai.com/v1.
return 0
fi

local api_base_file="$LLM_API_BASE_FILE"
local api_base_file_name="LLM_API_BASE_FILE"
if is_github_models_model "$model" && [ -n "${STRIX_GITHUB_MODELS_API_BASE_FILE:-}" ]; then
if is_explicit_openai_model "$model" && [ -n "${STRIX_OPENAI_FALLBACK_API_BASE_FILE:-}" ]; then
# Cross-provider fallback: openai-direct/* candidates must reach the
# direct OpenAI API even when the primary provider selected a
# different LLM_API_BASE_FILE endpoint (e.g. NVIDIA NIM). Without
# this the fallback hits the primary gateway and 404s.
api_base_file="$STRIX_OPENAI_FALLBACK_API_BASE_FILE"
api_base_file_name="STRIX_OPENAI_FALLBACK_API_BASE_FILE"
elif is_github_models_model "$model" && [ -n "${STRIX_GITHUB_MODELS_API_BASE_FILE:-}" ]; then
# Cross-provider fallback: when the active primary provider uses a
# different API base (for example OpenRouter), github_models/* fallback
# attempts must still route through the GitHub Models inference endpoint.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📝 Info: Direct-OpenAI base resolution verified sound

The new branches in resolved_llm_api_base_for_model route explicit openai-direct/* fallbacks correctly: with STRIX_OPENAI_FALLBACK_API_BASE_FILE set they use api.openai.com; absent, they early-return no override so litellm defaults to OpenAI. The workflow writes the base file inside the same guard as the fallback key, so key and base stay paired. The explicit-openai and github-models classes are disjoint, so no branch conflict.

(Refers to this code)

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@seonghobae

Copy link
Copy Markdown
Contributor Author

Current-head repair\n\nFixed the exact failure from runs 32834671068 and 32834671065: now pins the SHA-256 blob hash of the exact at this PR head ().\n\nLocal verification at the predecessor exact head passed: 102 tests, 1 skipped; ; . Please re-review the new exact head and rerun required Checks.

@seonghobae
seonghobae enabled auto-merge (squash) August 25, 2026 10:05
@seonghobae

Copy link
Copy Markdown
Contributor Author

Current-head repair

Fixed the exact failure from runs 32834671068 and 32834671065: tests/test_pr_review_autofix_nvidia_nim_contract.py now pins the SHA-256 blob hash of the exact opencode-review-dispatch.yml at this PR head (478788d41ed3e0d8389292a059d225336a925830).

Local verification at the predecessor exact head passed: 102 tests, 1 skipped; bash -n scripts/ci/test_strix_quick_gate.sh; git diff --check. Please re-review the new exact head c5f1c74c and rerun required Checks.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 2 new potential issues.

Open in Devin Review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📝 Info: OpenAI fallback still fails when its key is absent

When the primary is NVIDIA NIM / OpenRouter / GitHub Models and no OpenAI key exists, the workflow writes neither the fallback key nor base file (strix.yml). The openai-direct/gpt-5.4 fallback then resolves to the default OpenAI endpoint but keeps the primary provider's key (strix_quick_gate.sh), so it fails auth. This is not a regression and is documented as by-design fail-closed behavior.

(Refers to this code)

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +677 to +680
# github_models is included because its STRIX_FALLBACK_MODELS chain
# ends in openai-direct/gpt-5.4, which needs the direct-OpenAI key and
# API base to authenticate and route after the primary is exhausted.
if: steps.gate.outputs.provider_mode == 'openai_direct' || steps.gate.outputs.provider_mode == 'openrouter' || steps.gate.outputs.provider_mode == 'nvidia_nim' || steps.gate.outputs.provider_mode == 'github_models'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📝 Info: github_models fallback chain now reachable

Adding github_models to the fallback-credentials step (strix.yml) plus the explicit-OpenAI base routing makes the openai-direct/gpt-5.4 fallback for a GitHub Models primary reachable; previously it would have inherited the GitHub Models base and tripped the compatibility guard at strix_quick_gate.sh.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@seonghobae

Copy link
Copy Markdown
Contributor Author

Superseded by replacement PR #1331, rebased onto current protected main with the direct-OpenAI API-base repair and current gpt-5.4 contract.

@seonghobae seonghobae closed this Aug 25, 2026
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