Skip to content

fix(agent): honor model:inherit in subagent frontmatter - #17888

Closed
flacks wants to merge 1 commit into
anomalyco:devfrom
flacks:fix/subagents
Closed

fix(agent): honor model:inherit in subagent frontmatter#17888
flacks wants to merge 1 commit into
anomalyco:devfrom
flacks:fix/subagents

Conversation

@flacks

@flacksflacks commented Mar 17, 2026

Copy link
Copy Markdown

Issue for this PR

Closes#17890.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

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/).

How did you verify your code works?

Tested with get-shit-done global install (~/.config/opencode/agents/).

Screenshots / recordings

image

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

CopilotAI review requested due to automatic review settings March 17, 2026 02:31
@github-actionsgithub-actionsBot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Mar 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 sets model: "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 /agents dialog to use listAll() 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.

FileDescription
packages/opencode/src/cli/cmd/tui/context/local.tsxAdds listAll() and improves set() warnings to distinguish subagents vs missing agents.
packages/opencode/src/cli/cmd/tui/component/dialog-agent.tsxSwitches dialog options to listAll() and categorizes agents for grouping.
packages/opencode/src/agent/agent.tsTreats 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)
@github-actionsgithub-actionsBot removed the needs:compliance This means the issue will auto-close after 2 hours. label Mar 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@ariane-emory

Copy link
Copy Markdown
Contributor

Subagents are not meant to show up in the modal dialogue that the /agents command produces as they cannot be selected for use.

@flacksflacks changed the title fix(agent): honor model:inherit and show subagents in /agents dialogfix(agent): honor model:inherit in subagent frontmatterMar 17, 2026
@flacks

Copy link
Copy Markdown
Author

Subagents are not meant to show up in the modal dialogue that the /agents command produces as they cannot be selected for use.

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/).
marcusrbrown added a commit to marcusrbrown/systematic that referenced this pull request May 5, 2026
* 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
@rekram1-node

Copy link
Copy Markdown
Collaborator

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

Sign up for freeto 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.

model: inherit in agent frontmatter causes ProviderModelNotFoundError; subagents hidden from /agents dialog

4 participants

@flacks@ariane-emory@rekram1-node