anomalyco / anomalyco/opencode

run --agent ignores the agent's declared model and silently resolves the global default — banner misleads headless runs

Open
#42,561 2 comments 1 reaction 1 assignee View on GitHub

@rekram1-node is already working on this.

Since Aug 14, 2026.

2.0
Dominant language
TypeScript
Stars
209k
Forks
27.5k
Avg merge
7h 2m
Merged PRs (30d)
384

Description

run --agent ignores the agent's declared model and silently resolves the global default — banner misleads headless runs

Summary

When an agent file declares its own model:, opencode2 run --agent <name> does not use it for headless sessions. The session model silently resolves to the global config default instead, and the run banner advertises that default with no indication that the agent's declared model was ignored. In an interactive TUI this might be noticed; in headless automation (CI, benchmarking, agent harnesses) it is completely silent — runs happen on an unintended model with zero error or warning.

Reproduction

Global config ~/.config/opencode/opencode.jsonc:

{
  "model": { "providerID": "opencode", "model": "deepseek-v4-flash-free" }
}

Agent file .opencode/agents/modelprobe.md:

---
description: "Model resolution probe"
mode: primary
model: opencode/nemotron-3.5-lightning-free
---
Reply with exactly: OK

Run:

$ opencode2 run --agent modelprobe --auto "Reply with exactly: OK"
> modelprobe · deepseek-v4-flash-free
OK

Expected: > modelprobe · nemotron-3.5-lightning-free (the agent's declared model). Actual: the global default, silently.

The agent's model is not a parse failureopencode2 debug agents resolves it correctly:

$ opencode2 debug agents
agent name: modelprobe
agent model field: {"id": "nemotron-3.5-lightning-free", "providerID": "opencode"}

Contrast — the explicit CLI override IS honored:

$ opencode2 run --agent modelprobe --model opencode/nemotron-3.5-lightning-free --auto "Reply with exactly: OK"
> modelprobe · nemotron-3.5-lightning-free
OK

Impact

  • Headless harnesses (CI, benchmarking, agent pipelines) silently run on the wrong model — no error, no warning, no exit-code difference, and the banner actively confirms the wrong model without helping.
  • Model choice changes tool-call behavior: in our harness, the wrongly resolved default (a local OpenAI-compatible endpoint) refused tool calls and hallucinated tool names (google:search, etc.), contaminating multiple probe runs before the mismatch was finally noticed via the banner.

Expected behavior

  • run --agent should use the agent's declared model: first, with --model as an explicit override (the override path already works).
  • If the agent's model cannot be used for any reason, emit a visible warning on stderr/banner explaining what was resolved instead — never substitute silently.

Environment

  • opencode2 0.0.0-next-17430 (channel next; observed on 17403 in the same session before upgrade)
  • macOS Darwin 25.5.0 arm64 (Apple Silicon)
  • Shell zsh, terminal ghostty; user plugin notify.ts present
  • Config layout: global ~/.config/opencode/opencode.jsonc (default model), project .opencode/agents/*.md (agent model)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.