Skip to content

Pin the OpenCode build agent's model to the primary route - #269

Draft
FredLiu876 wants to merge 1 commit into
mainfrom
fix/opencode2-session-model-race
Draft

FredLiu876 wants to merge 1 commit into
mainfrom
fix/opencode2-session-model-race

Conversation

@FredLiu876

@FredLiu876 FredLiu876 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

OpenCode 2 resolves the session model before applying settings, so a cold start falls back to built-in free models instead of the configured route, causing flaky Test_Grid_OpenCodeServedModel_RealOpenCode2 failures.

  • grid setup now pins the build agent's model, which OpenCode consults before the global model key, to the primary route in both settings formats
  • agent.build.model is set in the original format
  • agents.build.model is set in the native OpenCode 2 format
  • Teardown removes the key only when it points at this provider
  • Setup in the native format retires the original format's copy

Testing shows go build, go vet, gofmt, and go mod tidy are clean, and go test passes for internal/harness and internal/cmd. The real-binary test passes in an isolated environment against @opencode/cli 2.3.0, though the race does not reproduce on fast machines.

Out of scope: pinning @opencode/cli in CI, changes to the served-model plugin, and releaseDate-based config.

OpenCode 2 can create a --prompt session and resolve its model before
it has applied the settings file, so on cold starts the session falls
back to OpenCode's built-in free models instead of the configured
route. OpenCode resolves the session model from the default (build)
agent before the global model setting, so setup now pins the build
agent's model alongside it in both settings formats.
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