Skip to content

Catalog variants are not package-aware: overriding a provider's package breaks built-in variants #55226

Open

Description

@StepharoAgent

Description

Version: 2.0.28

The bundled catalog defines variants for zai/glm-5.3 (low/high/max with
settings.thinking = {type:"enabled", clear_thinking:false} and reasoningEffort). When the provider is pointed at
the Anthropic-compatible endpoint ("package": "@opencode/ai/providers/anthropic", settings.baseURL), selecting
variant low fails at request time:

provider.invalid-request: Missing key at ["thinking"]["budgetTokens"] … Expected "disabled" | "between_tools" at ["thinking"]["type"]

Expected: either variants are validated against the effective package at config load (clear error), or
catalog variants are dropped/adapted when the package is overridden.

Workaround: define own variant ids with package-correct settings (thinking: {type:"enabled", budgetTokens}).

OpenCode version

2.0.28

Operating System

Linux x64 (Ubuntu)

Activity

  1. opencode-agent commented on Oct 13, 2026

    @opencode-agent
    Contributor

    Thanks for the clear report. I reproduced this on 2.0.28, and it still happens on the latest dev (1163e6cd).

    What I did:

    • Pointed the zai provider at "package": "@opencode/ai/providers/anthropic", with settings.baseURL set to a local mock server. I didn't add any model entries, so glm-5.3 and its variants come from the bundled catalog.
    • opencode run -m 'zai/glm-5.3#low' hello fails before any request goes out, with the error you reported: Missing key at ["thinking"]["budgetTokens"] … Expected "disabled" | "between_tools" at ["thinking"]["type"].
    • Without a variant, Anthropic-format requests do reach the endpoint. So the package override works, and only the catalog variants (in zai's thinking format) are wrong for the new package.

    The script below reproduces it. Your workaround (defining your own variants with budgetTokens) should still work for now. A related report with a similar mismatch: #53756 (Bedrock inference-profile ARNs getting the wrong effort variants).

    Reproduction script (repro.sh)
    #!/usr/bin/env bash
    # Reproduces #55226: catalog zai variants applied after overriding provider package to Anthropic.
    # Usage: ./repro.sh            (uses `opencode` from PATH)
    #        OC_DEV=/path/to/repo ./repro.sh   (runs from source)
    set -u
    DIR=$(mktemp -d); cd "$DIR"
    export OPENCODE_PASSWORD=repro-pass
    export XDG_CONFIG_HOME="$DIR/cfg" XDG_DATA_HOME="$DIR/data" XDG_STATE_HOME="$DIR/state" XDG_CACHE_HOME="$DIR/cache"
    mkdir -p proj
    # mock server just logs what reaches it
    bun -e 'Bun.serve({port:4555,async fetch(r){console.error("MOCK GOT",new URL(r.url).pathname,(await r.text()).slice(0,1500));return new Response(JSON.stringify({error:{type:"invalid_request_error",message:"mock"}}),{status:400,headers:{"content-type":"application/json"}})}})' & MOCK=$!
    sleep 1
    cat > proj/opencode.json <<'JSON'
    {
      "providers": {
        "zai": {
          "package": "@opencode/ai/providers/anthropic",
          "settings": { "baseURL": "http://127.0.0.1:4555/v1", "apiKey": "test-key" }
        }
      }
    }
    JSON
    cd proj
    if [ -n "${OC_DEV:-}" ]; then
      OC=(bun --conditions=browser --preload="$OC_DEV/packages/tui/node_modules/@opentui/solid/scripts/preload.js" "$OC_DEV/packages/cli/src/index.ts")
    else OC=(opencode); fi
    "${OC[@]}" --version
    MODE=(--standalone)
    if [ -n "${OC_DEV:-}" ]; then
      # from source, the spawned standalone server misses the preload, so run the server ourselves
      "${OC[@]}" serve --port 4600 >"$DIR/serve.log" 2>&1 & SRV=$!
      for i in $(seq 60); do curl -s -o /dev/null http://127.0.0.1:4600 && break; sleep 1; done
      MODE=(--server http://127.0.0.1:4600)
    fi
    echo "=== variant low ==="
    timeout 90 "${OC[@]}" run "${MODE[@]}" -m 'zai/glm-5.3#low' "hello" 2>&1 | tail -20
    echo "=== no variant (control) ==="
    timeout 90 "${OC[@]}" run "${MODE[@]}" -m 'zai/glm-5.3' "hello" 2>&1 | tail -20
    kill $MOCK ${SRV:-}

    Run it: bash repro.sh

  2. self-assigned this
    on Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions