Skip to content

fix: allow custom provider models in generated config schema - #46271

Open
BetterAndBetterII wants to merge 1 commit into
anomalyco:devfrom
BetterAndBetterII:schema-custom-model
Open

fix: allow custom provider models in generated config schema#46271
BetterAndBetterII wants to merge 1 commit into
anomalyco:devfrom
BetterAndBetterII:schema-custom-model

Conversation

@BetterAndBetterII

@BetterAndBetterII BetterAndBetterII commented Aug 30, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #46248

Type of change

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

What does this PR do?

restoreModelRefs in packages/opencode/script/schema.ts was applying $ref: https://models.dev/model-schema.json#/$defs/Model as a sibling on every model / small_model string field. That $defs/Model is a closed enum, so a valid custom provider id such as internal/Qwen/Qwen3-Coder-30B-A3B-Instruct failed generated-schema validation even though runtime ConfigV1.model is a plain string.

This change emits anyOf: [{ type: "string" }, { $ref }] instead of the sibling $ref, so custom ids validate and the models.dev branch can still be used for autocomplete. The same helper covers top-level model / small_model and nested agent/command model fields.

How did you verify your code works?

cd packages/opencode && bun test test/script/schema.test.ts

3 tests: generated Config.model / small_model keep a string branch (no closed-enum-only $ref); the issue's custom provider model validates; a normal models.dev id still validates.

Screenshots / recordings

If this is a UI change, please include a screenshot or recording.

Checklist

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

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Aug 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

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

schema rejects valid custom provider model in top-level model field

1 participant