Skip to content

fix(opencode): respect HARNESS_MODEL in baked-in opencode.json (small_model path)#24

Merged
AbirAbbas merged 1 commit into
mainfrom
fix/opencode-respect-harness-model
May 7, 2026
Merged

fix(opencode): respect HARNESS_MODEL in baked-in opencode.json (small_model path)#24
AbirAbbas merged 1 commit into
mainfrom
fix/opencode-respect-harness-model

Conversation

@AbirAbbas
Copy link
Copy Markdown
Contributor

Summary

The baked-in `~/.config/opencode/opencode.json` hardcoded both `model` and `small_model` to a literal `openrouter/moonshotai/kimi-k2.5`. The main model is fine — the Python harness provider passes `-m $HARNESS_MODEL` to `opencode run`, which overrides config. But OpenCode's `small_model` (used for session titles, summarization, prompt compaction) reads from config, not the CLI flag. Result: a deployer setting `HARNESS_MODEL=X` on Railway gets X for the main model and `kimi-k2.5` for small_model — env var silently bypassed.

OpenCode supports `{env:VAR}` interpolation in string fields. This PR switches `model` and `small_model` to `{env:HARNESS_MODEL}` so both paths read from the same env var the rest of the pr-af stack already respects.

What changes

```diff

  • "model":"openrouter/moonshotai/kimi-k2.5",
  • "small_model":"openrouter/moonshotai/kimi-k2.5",
  • "provider":{"openrouter":{"options":{"apiKey":"{env:OPENROUTER_API_KEY}"},"models":{"moonshotai/kimi-k2.5":{}}}}
  • "model":"{env:HARNESS_MODEL}",
  • "small_model":"{env:HARNESS_MODEL}",
  • "provider":{"openrouter":{"options":{"apiKey":"{env:OPENROUTER_API_KEY}"}}}
    ```

The Dockerfile already sets `HARNESS_MODEL=openrouter/moonshotai/kimi-k2.5` as the image default, so a fresh container with no env overrides still has a value to interpolate. Railway / docker-compose env injection wins because it lands after the image's ENV layer.

The `models` registration block was dropped — OpenCode auto-handles unknown model names from a configured provider, and pinning a specific name there broke the moment `HARNESS_MODEL` changed.

Why this isn't the same as #23 (closed)

#23 was bumping the literal `kimi-k2.5` → `kimi-k2.6` in the same files. That was cosmetic — env vars already overrode the main-model path. This PR fixes the actual env-var bypass: the small_model field that env vars couldn't override at all.

Test plan

  • `docker build .` succeeds
  • On staging deploy with `HARNESS_MODEL` set, verify OpenRouter dashboard shows zero traffic to non-$HARNESS_MODEL models from this service's key

🤖 Generated with Claude Code

The baked-in opencode.json hardcoded both model and small_model to a
literal kimi-k2.5 string, so OpenCode's small_model path (used for
session titles and prompt compaction) silently bypassed whatever
HARNESS_MODEL the deployer set on Railway. Per-call -m on `opencode run`
already pins the main model from HARNESS_MODEL via the Python harness
provider; this aligns the small_model path the same way.

OpenCode supports {env:VAR} interpolation in string fields. Switch
model and small_model to {env:HARNESS_MODEL} so they track the env var
the rest of the pr-af stack already reads. The Dockerfile already sets
HARNESS_MODEL=openrouter/moonshotai/kimi-k2.5 as the image default, so
fresh containers without overrides still have a value to interpolate.

Also drops the now-redundant `models` registration block — OpenCode
auto-handles unknown model names from a configured provider, and pinning
a specific name there broke the moment HARNESS_MODEL changed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@AbirAbbas AbirAbbas merged commit a350c74 into main May 7, 2026
2 checks passed
@AbirAbbas AbirAbbas deleted the fix/opencode-respect-harness-model branch May 7, 2026 00:35
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