Skip to content

When the key is `limit`, the input field clears automatically in OpenCode

Quick fix

Because the cc-switch interface treats limit as reserved, edit opencode.json directly to configure model context and output limits.

Error output
当key输入为limit时,输入框内容会被自动清空,且界面没有给出明确错误提示
English translation

When the key is `limit`, the input field clears automatically, and the interface shows no clear error message.

When editing an OpenCode provider in cc-switch, the source file opencodeFormUtils.ts lists `limit` as a reserved key, and OpenCodeFormFields.tsx immediately returns when it encounters `limit`. As a result, the GUI does not let users save it as a model property key. Some users may also see the dialog “读取OpenCode运行时模型失败,已仅展示已配置供应商模型” while editing a provider. This is usually because an invalid underlying model configuration could not be parsed.

OpenCode 1.4.0 strengthened validation of the `maxOutputTokens` field. A custom model without `limit` configured, including both `context` and `output`, will trigger an error. Since cc-switch does not currently support configuring this field in the GUI, edit the configuration file directly to work around the interface.

  1. Close cc-switch and OpenCode to prevent the configuration from being overwritten.

  2. Find and open OpenCode's configuration file, opencode.json.

  3. Under the relevant model configuration, manually add the `limit` property and set its `context` and `output` values.

    // opencode.json
    "models": {
    "gpt-5.4": {
    "name": "GPT-5.4",
    "limit": {
    "context": 256000,
    "output": 64000
    }
    }
    }
ToolOpenCode
Version1.4.0
PlatformsLinuxWindowsmacOS
Why does a model need `limit` configured?
OpenCode strengthened validation of the `maxOutputTokens` field in version 1.4.0. If a custom model has no context and output limits configured (the `limit` field), it will trigger a runtime error.
Why does cc-switch currently prevent setting `limit`?
The cc-switch source treats `limit` as a reserved key. The interface intercepts and clears it when entered, so for now you can work around this restriction only by editing the JSON configuration file directly.
Why does the OpenCode version shown in the interface differ from the actual version?
This is expected. The local environment check in cc-switch reads the OpenCode CLI version, not the version of the OpenCode Desktop application.

This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.