tweak (config): make modalities input/output fields optional so that u can specify one without both being required #29268
Conversation
Providing only `modalities.input` (e.g. to enable image support on a
custom model) caused a startup crash:
ConfigInvalidError: Missing key
at ["provider"]["..."]["modalities"]["output"]
Both fields were required by the struct even though the consuming code
already uses optional chaining (`?.`) with sensible defaults throughout.
Making each field independently optional means users can write:
"modalities": { "input": ["image"] }
without being forced to redundantly specify `"output": ["text"]`.
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
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. |
uh the error says it right here haha:
|
|
but i think this is reasonable |
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
Fixes #29269
Problem
When configuring a custom model with only
modalities.input(the common case — e.g. enabling image support on a local LM Studio model), opencode crashes on startup:The entire
modalitiesblock isSchema.optional, but once provided, bothinputandoutputare required fields inside the struct. The error gives no hint thatoutputis required or what values it accepts. Workaround is to add"output": ["text"]— but users have no way to discover this.Fix
Wrap each field in
Schema.optionalso users can specify just the fields relevant to them:Why this is safe
All consuming code in
provider.tsalready accesses both fields via optional chaining (?.) with explicit fallback defaults.