fix(opencode-review): native OpenAI backend as lead review model (unblock org-wide merge freeze)#350
Open
seonghobae wants to merge 1 commit into
Open
fix(opencode-review): native OpenAI backend as lead review model (unblock org-wide merge freeze)#350seonghobae wants to merge 1 commit into
seonghobae wants to merge 1 commit into
Conversation
Root cause of the org-wide merge freeze: the required `opencode-review`
check has failed 100% of recent runs across all repos, leaving 12+ PRs
stuck at REVIEW_REQUIRED and every run hanging to the 350-min timeout.
The embedded OpenCode config routed EVERY model in the pool through the
single `github-models` provider (`{env:STRIX_GITHUB_MODELS_TOKEN}` at
https://models.github.ai/inference). GitHub Models rate-limits ("Too many
requests") and caps request bodies at ~4000 tokens (413
tokens_limit_reached), so the reviewer never produced a verdict on any
model and the pool exhausted the whole step without approving.
Fix: give the reviewer a working, un-throttled backend by adding a native
OpenAI provider that hits api.openai.com directly with the org
`OPENAI_API_KEY` secret, and lead the model pool with it.
- opencode.jsonc config: add `provider.openai` (npm @ai-sdk/openai,
baseURL https://api.openai.com/v1, apiKey {env:OPENAI_API_KEY}) with
gpt-5 and gpt-5-mini defined reasoning=true / reasoningEffort=high so
they satisfy assert_opencode_reasoning_effort.py; add "openai" to
enabled_providers.
- OPENCODE_MODEL_CANDIDATES: prepend `openai/gpt-5 openai/gpt-5-mini` as
the lead candidates. The pool passes --model per attempt, so candidate
order (not the config `model` default) is the real lead; the existing
github-models entries are kept unchanged as fallbacks.
- Expose OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} in both env blocks
that invoke opencode with this config (the model-pool step and the
approve/failed-check-diagnosis step) so {env:OPENAI_API_KEY} resolves.
The config `model`/`small_model` defaults are intentionally left on
github-models/deepseek: they are overridden at runtime by the pool's
explicit --model, and static self-tests pin those strings. This unblocks
real reviews without weakening the review gate — if the OpenAI key is
absent or a direct call fails, the pool falls through to the existing
github-models candidates exactly as before.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AxU2xaupAjp912oDNFuWyd
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.
Org-wide merge freeze
The required
opencode-reviewcheck is failing 100% of recent runs across all repos. 12+ open PRs (3 repos) are stuck atREVIEW_REQUIRED, and every review run hangs to the 350-minute step timeout. No PR in the org can merge.Root cause
The embedded OpenCode config in
.github/workflows/opencode-review.ymlrouted every model in the pool through the singlegithub-modelsprovider:GitHub Models rate-limits (
Too many requests) and caps request bodies at ~4000 tokens (413 tokens_limit_reached). So no model in the candidate pool ever produced a review verdict — the pool churned through every fallback and exhausted the whole step without approving. The gate never opens.Fix
Give the reviewer a working, un-throttled backend by adding a native OpenAI provider (hits
api.openai.comdirectly using the orgOPENAI_API_KEYsecret) and making it the lead of the model pool. GitHub Models entries are kept unchanged as fallbacks.opencode.jsoncconfig: addedprovider.openai—npm: @ai-sdk/openai,baseURL: https://api.openai.com/v1,apiKey: {env:OPENAI_API_KEY}, withgpt-5andgpt-5-mini(reasoning: true,reasoningEffort: high, matchingassert_opencode_reasoning_effort.py). Added"openai"toenabled_providers.OPENCODE_MODEL_CANDIDATES: prependedopenai/gpt-5 openai/gpt-5-minias the lead candidates. The pool passes--modelexplicitly per attempt, so candidate order is the real lead — not the configmodeldefault. The full github-models list follows unchanged.OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}to both env blocks that invoke opencode with this config (the model-pool step and the approve / failed-check-diagnosis step) so{env:OPENAI_API_KEY}resolves.Why the config
model/small_modeldefaults were left on github-models/deepseekThey are overridden at runtime by the pool's explicit
--model, and static self-tests pin those exact strings. Changing them would break tests for zero runtime benefit. The "lead" is controlled entirely by the candidate list, which is what this PR reorders.Does not weaken the gate
This only changes which backend the reviewer talks to — the review contract, approve gate, agents, and permissions are untouched. If
OPENAI_API_KEYis absent or a direct call fails, the pool falls through to the existing github-models candidates exactly as today (at worst one wasted lead attempt before fallback).Cost implication
PR reviews will now consume the org OpenAI API key (billed to
api.openai.com) for the leadgpt-5/gpt-5-miniattempts on every reviewed PR, instead of the free-but-broken GitHub Models quota. This is the tradeoff that makes reviews actually complete. Reviewers should confirm this billing is acceptable before merge.Validation
python3 -c "import yaml; yaml.safe_load(...)"→ yaml okpython3 -m json.tool→ valid JSON;provider.openaipresent with correct baseURL/apiKey/models;enabled_providers = [openai, github-models].assert_opencode_reasoning_effort.py→ all candidates pass (incl.openai/gpt-5,openai/gpt-5-mini).test_strix_quick_gate.sh: every substring it pins that was already passing still passes; the full-order candidate asserts it "fails" on were already failing on the pre-change file (that test is out of sync and is not the merge gate).Needs review before merge
This gates all org merges. Please verify: (1) the org
OPENAI_API_KEYsecret is available to this workflow'spull_request_targetcontext, (2) the OpenAI billing cost is acceptable, and (3)gpt-5/gpt-5-miniare the intended model ids for the org's OpenAI account. Do not merge until confirmed.🤖 Generated with Claude Code