Skip to content

tweak (config): make modalities input/output fields optional so that u can specify one without both being required #29268

Merged
rekram1-node merged 1 commit into
anomalyco:devfrom
robposch:fix/modalities-output-optional
May 25, 2026
Merged

tweak (config): make modalities input/output fields optional so that u can specify one without both being required #29268
rekram1-node merged 1 commit into
anomalyco:devfrom
robposch:fix/modalities-output-optional

Conversation

@robposch
Copy link
Copy Markdown
Contributor

@robposch robposch commented May 25, 2026

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:

ConfigInvalidError: Missing key
  at ["provider"]["lmstudio"]["models"]["google/gemma-4-e4b"]["modalities"]["output"]

The entire modalities block is Schema.optional, but once provided, both input and output are required fields inside the struct. The error gives no hint that output is 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.optional so users can specify just the fields relevant to them:

"modalities": { "input": ["image"] }  // now valid

Why this is safe

All consuming code in provider.ts already accesses both fields via optional chaining (?.) with explicit fallback defaults.

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"]`.
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels May 25, 2026
@github-actions
Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

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.

@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.

@rekram1-node
Copy link
Copy Markdown
Collaborator

The entire modalities block is Schema.optional, but once provided, both input and output are required fields inside the struct. The error gives no hint that output is required or what values it accepts. Workaround is to add "output": ["text"] — but users have no way to discover this.

uh the error says it right here haha:

ConfigInvalidError: Missing key
at ["provider"]["lmstudio"]["models"]["google/gemma-4-e4b"]["modalities"]["output"]

@rekram1-node
Copy link
Copy Markdown
Collaborator

but i think this is reasonable

@rekram1-node rekram1-node changed the title fix(config): make modalities input/output fields optional tweak (config): make modalities input/output fields optional so that u can specify one without both being required May 25, 2026
@rekram1-node rekram1-node merged commit 0bfa55b into anomalyco:dev May 25, 2026
14 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

Hey! Your PR title tweak (config): make modalities input/output fields optional so that u can specify one without both being required doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:compliance This means the issue will auto-close after 2 hours. needs:title

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: modalities.output required even though all consuming code handles undefined

2 participants