Skip to content

[BUG] Bug Report: Opencode Go Provider Incorrectly Overrides Hardcoded contextWindow with API-Returned Value 200K #723

Description

@SpiritLiberation

Bug Report: Opencode Go Provider Incorrectly Overrides Hardcoded contextWindow with API-Returned Value

Environment

  • Extension: Zoo Code (community edition of Roo Code)
  • Version: 3.63.100191
  • File: dist/extension.js
  • Provider: opencode-go
  • Model: deepseek-v4-flash (natively supports 1M context window)

Summary

When using the opencode-go provider, the $Zo() function (model info merger) incorrectly allows the API response's context_window field to override the hardcoded default value from the f3i table. Since the Opencode Go API (https://opencode.ai/zen/go/v1/models) returns context_window: 200000 as a default for all models, models that are correctly defined in f3i with contextWindow: 1e6 (1M) end up being constrained to 200K.

Root Cause

Code Path

wye (opencode-go provider) → bS.fetchModel() → Rv() → R7n() → cHn() → $Zo()
  1. wye class extends bS base class — handles opencode-go provider
  2. bS.fetchModel() calls Rv({provider:"opencode-go", ...}) which fetches models via cHn()
  3. cHn() sends GET to https://opencode.ai/zen/go/v1/models and parses each model entry through $Zo()
  4. $Zo() merges hardcoded defaults (from fur()f3i map) with API response data

The Bug (in $Zo)

// BEFORE FIX (buggy):
$Zo = t => {
  let e = fur(t.id),                         // hardcoded defaults from f3i
      r = t.context_window ?? t.context_length, // API response
      a = t.max_output_tokens ?? t.max_tokens,
      o = t.supports_images;
  return e ? {
    ...e,                                          // spread hardcoded (correct contextWindow: 1e6)
    ...r !== void 0 && {contextWindow: r},          // ← BUG: API's 200K OVERRIDES hardcoded 1M
    ...a !== void 0 && {maxTokens: a},
    ...o !== void 0 && {supportsImages: o},
    description: t.description ?? t.name ?? e.description
  } : {
    maxTokens: a ?? Lie.maxTokens,
    contextWindow: r ?? Lie.contextWindow,
    // ...
  };
};

When a model IS in the hardcoded f3i table (like deepseek-v4-flash with contextWindow: 1e6), the line ...r !== void 0 && {contextWindow: r} unconditionally overwrites the context window with whatever the API returns. The Opencode Go API returns context_window: 200000 for all models, destroying the correct 1M value.

The Fix

// AFTER FIX:
$Zo = t => {
  let e = fur(t.id),
      r = t.context_window ?? t.context_length,
      a = t.max_output_tokens ?? t.max_tokens,
      o = t.supports_images;
  return e ? {
    ...e,                                          // hardcoded contextWindow: 1e6 preserved
    ...a !== void 0 && {maxTokens: a},
    ...o !== void 0 && {supportsImages: o},
    description: t.description ?? t.name ?? e.description
  } : {
    maxTokens: a ?? Lie.maxTokens,
    contextWindow: r ?? Lie.contextWindow,          // API value still used for UNKNOWN models
    // ...
  };
};

Change: Removed ...r !== void 0 && {contextWindow: r} from the e (hardcoded model) branch. When a model has hardcoded defaults in f3i, the hardcoded contextWindow is now authoritative. The API-provided contextWindow is still used for unknown models (the fallback branch after :).

Additional Data: Cached File

The cached model file at:

~/.config/Code/User/globalStorage/zoocodeorganization.zoo-code/cache/opencode-go_models.json

contained ALL models with contextWindow: 200000, confirming the API returns a blanket 200K for every model:

{"deepseek-v4-flash": {"maxTokens":32768,"contextWindow":200000,...},...}

Impact

All models served via the opencode-go provider that are defined in the f3i hardcoded table with larger context windows than 200K are affected. This includes:

  • deepseek-v4-flash (should be 1M → was 200K)
  • deepseek-v4-pro (should be 1M → was 200K)
  • minimax-m3 (should be 1M → was 200K)
  • glm-5.2 (should be 1M → was 200K)
  • mimo-v2.5 (should be 1M → was 200K)
  • qwen3.6-plus / qwen3.7-plus / qwen3.7-max (should be 1M → was 200K)

Proposed Fix Upstream

In dist/extension.js, the $Zo function should be modified to not override the hardcoded contextWindow with the API-provided value when the model exists in the f3i table. The fix is a one-line removal.

Suggested patch:

- return e ? {...e, ...r !== void 0 && {contextWindow: r}, ...a !== void 0 && {maxTokens: a}, ...o !== void 0 && {supportsImages: o}, description: t.description ?? t.name ?? e.description}
+ return e ? {...e, ...a !== void 0 && {maxTokens: a}, ...o !== void 0 && {supportsImages: o}, description: t.description ?? t.name ?? e.description}

Report generated on 2026-06-25

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions