fix(docker): honor PR_AF_MODEL in the opencode harness config#50
Merged
Conversation
The opencode harness config (~/.config/opencode/opencode.json) was baked into the image with a hardcoded model and a single-model provider whitelist (moonshotai/kimi-k2.5). As a result PR_AF_MODEL was effectively ignored by the opencode provider: the harness passes the model via `-m`, but opencode still fell back to — and restricted itself to — the baked model, so setting PR_AF_MODEL to e.g. openrouter/z-ai/glm-5.2 had no effect. Move config generation to a runtime entrypoint that writes opencode.json from PR_AF_MODEL, deriving the provider model key by stripping the "openrouter/" prefix. When PR_AF_MODEL is unset the generated config is byte-identical to the previous baked default, so behavior is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
The opencode harness config (
~/.config/opencode/opencode.json) is baked into the image at build time with a hardcoded model and a single-model provider whitelist:{"model":"openrouter/moonshotai/kimi-k2.5","small_model":"openrouter/moonshotai/kimi-k2.5", "provider":{"openrouter":{"models":{"moonshotai/kimi-k2.5":{}}}}}Because of this, setting
PR_AF_MODELhad no effect on the opencode provider. The harness does pass the model via-m(sdk .../providers/opencode.py), but opencode still fell back to — and restricted itself to — the baked model/whitelist. So e.g.PR_AF_MODEL=openrouter/z-ai/glm-5.2was silently ignored.Fix
Generate
opencode.jsonat container start fromPR_AF_MODELvia a small entrypoint script, deriving the provider model key by stripping theopenrouter/prefix. The env var now wins when set; when unset it falls back to the same benchmarked default.PR_AF_MODEL=openrouter/z-ai/glm-5.2→model/small_model= that model, whitelist keyz-ai/glm-5.2.PR_AF_MODELunset → generated config is byte-identical to the previous baked default (verified), so no behavior change.Validation contract
PR_AF_MODELset → configmodel,small_model, and provider whitelist all reflect itPR_AF_MODELunset → config identical to prior baked defaultapiKeytemplating{env:OPENROUTER_API_KEY}preservedexecs the CMD (PID 1 / signals / exit code pass through)Tested by running the real
docker-entrypoint.shunder both env states and parsing the emitted JSON.Note
Full image build + a live review run against a real PR is still pending (blocked on Railway access on my side); this change is verified at the config-generation layer.
🤖 Generated with Claude Code