Skip to content

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

@robposch

Description

@robposch

Bug report

Describe the bug

When configuring a custom model with only modalities.input, opencode crashes on startup:

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

The modalities block is Schema.optional as a whole, but once provided, both input and output are required inside the struct. There is no documentation explaining this, and the error message gives no hint that output is required or what values it accepts.

To reproduce

// opencode.jsonc
{
  "provider": {
    "lmstudio": {
      "npm": "@ai-sdk/openai-compatible",
      "options": { "baseURL": "http://localhost:1234/v1", "apiKey": "lm-studio" },
      "models": {
        "google/gemma-4-e4b": {
          "modalities": { "input": ["image"] }
        }
      }
    }
  }
}

Start opencode → ConfigInvalidError: Missing key at [...]["modalities"]["output"]

Expected behavior

Specifying only modalities.input (or only modalities.output) should be valid. The consuming code in provider.ts already accesses both fields via ?. with fallback defaults, so there is no runtime requirement for both to be present.

Workaround

Add "output": ["text"] to the modalities block.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions