fix(agent): honor model:inherit in subagent frontmatter#17888
fix(agent): honor model:inherit in subagent frontmatter#17888flacks wants to merge 1 commit intoanomalyco:devfrom
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
There was a problem hiding this comment.
Pull request overview
Fixes agent/model handling and improves the agent-selection UX in the TUI so subagents are visible and “model inheritance” behaves as intended.
Changes:
- Skip
Provider.parseModel()when an agent config setsmodel: "inherit", allowing the agent to fall back to the session/parent model. - Expose
listAll()on the TUI local agent context to return all non-hidden agents (including subagents). - Update the
/agentsdialog to uselistAll()and group entries into “Primary” vs “Subagents”.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/opencode/src/cli/cmd/tui/context/local.tsx | Adds listAll() and improves set() warnings to distinguish subagents vs missing agents. |
| packages/opencode/src/cli/cmd/tui/component/dialog-agent.tsx | Switches dialog options to listAll() and categorizes agents for grouping. |
| packages/opencode/src/agent/agent.ts | Treats model: "inherit" as “no explicit model” by skipping parseModel. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| value: item.name, | ||
| title: item.name, | ||
| description: item.native ? "native" : item.description, | ||
| category: item.mode === "subagent" ? "Subagents" : "Primary", |
| native: false, | ||
| } | ||
| if (value.model) item.model = Provider.parseModel(value.model) | ||
| if (value.model && value.model !== "inherit") item.model = Provider.parseModel(value.model) |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Subagents are not meant to show up in the modal dialogue that the |
Agreed, fixed. |
Agents with `model: inherit` had "inherit" passed to Provider.parseModel(),
producing { providerID: "inherit", modelID: "" }. The non-null result caused
task.ts to skip its ?? fallback to the parent session's model, resulting in
a ProviderModelNotFoundError on every subagent invocation.
Fix: skip parseModel when model value is "inherit", leaving item.model
undefined so the parent model is inherited as intended.
Tested with get-shit-done global install (~/.config/opencode/agents/).
* fix(agents): omit model field from all 50 bundled agents OpenCode's docs say subagents with no model field inherit the invoking primary agent's model — the desired portable behavior. The literal `model: inherit` was undocumented and produced ProviderModelNotFoundError on OpenCode older than ~v1.13.x (pre anomalyco/opencode#17888). Omitting the field works on every OpenCode version. Strip model: inherit from all 50 bundled agents. Flip the content-integrity gate: previously required `model: inherit`, now requires the field to be absent. Update the violation message to explain the why and link to the OpenCode docs and upstream PR. Update test fixtures for both directions: - writeAgent helper now writes agents without a model field - the suite that previously asserted "missing/non-inherit/empty/null" as violations now asserts "any present model value (including the literal 'inherit')" as violations - the integration test that constructed an agent fixture with no model field to trigger a violation now constructs one with `model: inherit` (which, post-flip, is a violation) Refs: https://opencode.ai/docs/agents/, anomalyco/opencode#17888 * docs(writing-systematic-skills): reverse model: inherit guidance The skill spec previously mandated model: inherit for bundled agents. Update the spec to require omitting the model field instead. The why is the same as the agent change: subagents with no model field inherit from the invoking primary agent per OpenCode's docs, which is the portable behavior. model: inherit was undocumented and broken on OpenCode pre anomalyco/opencode#17888. Updates: - SKILL.md: reverse Identity Defaults section, common-mistakes table, validator rule list, and the spec summary bullet. - references/foundation-conventions.md: same reversal in the long-form Identity Defaults section, plus update the optional-fields table to show a non-inherit example for skill-level model overrides. The auto-generated docs/src/content/docs/reference/* files are gitignored and re-generated by bun run docs:generate during build. Refs: https://opencode.ai/docs/agents/, anomalyco/opencode#17888 * docs(AGENTS): document bundled-agent model omission policy Surface the no-model-field convention in repo-level AGENTS.md so contributors discover it at authoring time, not at CI failure. Cites the OpenCode docs (subagents inherit when model is unset) and the upstream PR that special-cased the literal "inherit" string in March 2026. The content-integrity gate already enforces this; this commit is a discoverability mirror for human contributors and AI agents reading AGENTS.md before authoring. Refs: https://opencode.ai/docs/agents/, anomalyco/opencode#17888
Issue for this PR
Closes #17890.
Type of change
What does this PR do?
Agents with
model: inherithad "inherit" passed to Provider.parseModel(), producing { providerID: "inherit", modelID: "" }. The non-null result caused task.ts to skip its ?? fallback to the parent session's model, resulting in a ProviderModelNotFoundError on every subagent invocation.Fix: skip parseModel when model value is "inherit", leaving item.model undefined so the parent model is inherited as intended.
Tested with get-shit-done global install (~/.config/opencode/agents/).
How did you verify your code works?
Tested with get-shit-done global install (~/.config/opencode/agents/).
Screenshots / recordings
Checklist