Repository navigation
Description
Summary
A markdown agent with mode: all and a frontmatter model: (no #variant) has its configured model silently ignored when invoked via the subagent tool — the child session inherits the parent session's model. The same agent works correctly when its frontmatter says mode: subagent. Same symptom family as #50849, but a distinct trigger (see Additional Context).
Environment
- opencode version: 2.0.10
- OS: Linux 7.0.14-17-pve (linux x64)
- Terminal: xterm-256color (headless
opencode serve+ TUI session;TERM_PROGRAMnot set) - Shell: /bin/bash
- Install/channel: latest
- Active plugins: none in config (custom plugin files exist in
plugins-v2/but are not referenced from config)
Reproduction
Two custom openai-compatible providers (npm: "@ai-sdk/openai-compatible"), each with a declared model in its models map; both models resolvable (present in GET /api/model). Two agents under ~/.config/opencode/agents/, both using legacy (v1) frontmatter keys (permission: map, temperature):
A.md:mode: subagent,model: <providerA/modelA>B.md:mode: all,model: <providerB/modelB>
Parent session runs model M (different from both). For each configuration, invoke the subagent tool with only agent/description/prompt (no model parameter), then inspect the child via GET /api/session/{childID} and the assistant message metadata in the session store.
| # | agent | mode | configured model | child actually ran on |
|---|---|---|---|---|
| 1 | B | all |
providerB/modelB | M (parent) ✗ |
| 2 | A | subagent |
providerA/modelA | providerA/modelA ✓ |
| 3 | A (model swapped to providerB/modelB) | subagent |
providerB/modelB | providerB/modelB ✓ |
| 4 | B (mode flipped to subagent) |
subagent |
providerB/modelB | providerB/modelB ✓ |
Each row was a fresh spawn; only the single named variable changed between rows.
Expected Behavior
Case 1 should run on providerB/modelB — the configured model: applies at spawn regardless of the agent's mode.
Actual Behavior
Case 1 creates the child session with the parent's model M. No error, no warning, nothing in the server log. GET /api/agent/B correctly reports the configured model, so parsing/registry is fine — only spawn-time resolution is wrong.
Additional Context
- Consistently reproducible (2/2 spawns in case 1, v2.0.10, Linux,
opencode serve). - Distinct from core: legacy Markdown agent silently drops "model: provider/model#variant" — subagent inherits parent model #50849 (opened 2026-09-23): that issue is the v1-migration
modelSelection()regex rejecting embeddedmodel: provider/model#variant. Here the model string contains no#(so it passes that regex), and the failure tracks the agent'smode— amode: subagentagent with the identical model string and identical legacy frontmatter resolves correctly (rows 2–4). If the v1 migration path also mishandlesmode: all, the two would share an upstream location. - Related family: Legacy agent Markdown loses a separate model variant #47413 (separate
variant:key dropped, fixed by f1eed8b), Subagent spawned via Task tool without its own variant inherits parent's variant concatenated onto model ID (model#variant), causing "Model not found" errors #50698 (parent variant concatenated onto subagent model ID). - Not tested:
mode: allwith native (non-legacy) v2 frontmatter — unclear whether the legacy keys interact. - Workaround: set
mode: subagenton the agent (verified, row 4). - Impact:
mode: allis intended for agents usable both as primary and as subagent; the silent fallback to the parent's model makes misconfiguration hard to notice (subagents quietly run on a different/larger model than configured, with no diagnostic anywhere).
Activity
csyio commentedon Oct 6, 2026
Can't reproduce this on current v2: a
mode: allagent withmodel:set spawns its child on the configured model. Could you check if it still happens on the latest release?rekram1-node commentedon Oct 21, 2026
Closing since we could not reproduce this on current V2 and have not heard back. Please reopen if a
mode: allagent still ignores itsmodel:on 2.1.x.