Skip to content

fix(core): keep commands whose model is not provider/model - #52195

Closed
simonether wants to merge 1 commit into
anomalyco:devfrom
simonether:command-model-warning
Closed

simonether wants to merge 1 commit into
anomalyco:devfrom
simonether:command-model-warning

Conversation

@simonether

Copy link
Copy Markdown

Issue for this PR

Closes #52065

Type of change

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

What does this PR do?

A command .md file with a model that isn't provider/model in its frontmatter (for example model: opus) was dropped without any log. decode() in config/plugin/command.ts validated all of the frontmatter with one schema, so a bad model made the whole decode fail and the command never showed up.

Now the loader checks model on its own first. If it isn't a valid provider/model reference, it logs a warning with the file path and the value, drops the field, and loads the command without a model override, so it runs on the session's model (or the command agent's, if it sets one), as the issue suggests. Invalid values in other fields behave as before.

How did you verify your code works?

Added a test to packages/core/test/config/command.test.ts that loads a real commands/hello.md with model: opus. It checks that the command is listed, runs without switching the model, and logs one warning naming the file and opus. Without the fix it fails because the command list is empty.

In packages/core, bun run test test/config/ passes (209 tests), and typecheck, prettier and oxlint are clean. I ran this on Linux arm64 and didn't try it in the TUI.

Screenshots / recordings

Not a UI change.

Checklist

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

A command file with a model like `opus` failed to decode and was dropped without a log. Now the invalid model is ignored with a warning, so the command loads and uses the default model.
@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.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@github-actions

Copy link
Copy Markdown
Contributor

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 free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

commands: unresolvable model in frontmatter silently drops the command

1 participant