Skip to content

fix(docker): honor PR_AF_MODEL in the opencode harness config#50

Merged
AbirAbbas merged 1 commit into
mainfrom
fix/opencode-model-from-env
Jul 8, 2026
Merged

fix(docker): honor PR_AF_MODEL in the opencode harness config#50
AbirAbbas merged 1 commit into
mainfrom
fix/opencode-model-from-env

Conversation

@AbirAbbas

Copy link
Copy Markdown
Contributor

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_MODEL had 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.2 was silently ignored.

Fix

Generate opencode.json at container start from PR_AF_MODEL via a small entrypoint script, deriving the provider model key by stripping the openrouter/ 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.2model/small_model = that model, whitelist key z-ai/glm-5.2.
  • PR_AF_MODEL unset → generated config is byte-identical to the previous baked default (verified), so no behavior change.

Validation contract

Behavior Result
PR_AF_MODEL set → config model, small_model, and provider whitelist all reflect it
PR_AF_MODEL unset → config identical to prior baked default ✅ (byte-diff clean)
apiKey templating {env:OPENROUTER_API_KEY} preserved
Entrypoint execs the CMD (PID 1 / signals / exit code pass through)

Tested by running the real docker-entrypoint.sh under 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

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>
@AbirAbbas AbirAbbas merged commit 91da587 into main Jul 8, 2026
2 checks passed
@AbirAbbas AbirAbbas deleted the fix/opencode-model-from-env branch July 8, 2026 16:44
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