Skip to content

opencode-go plugin: model contextWindow not loaded, all models fall back to 200K #92912

Description

@kumaxs

Summary

The opencode-go plugin defines a static model catalog with 19+ models including correct contextWindow values (e.g., deepseek-v4-pro: 1_000_000). However, the plugin does NOT register these into the runtime model context window cache, so resolveContextTokensForModel() falls back to 200K.

Impact

Every agent using opencode-go models has premature compaction — the threshold is calculated as contextWindow - reserveTokens - softThresholdTokens, which becomes 156K instead of 956K (6x too frequent).

$ openclaw models list | grep deepseek
opencode-go/deepseek-v4-pro   text   195k   # should be 977k (1M)
opencode-go/deepseek-v4-flash text   195k   # should be 977k (1M)

Root Cause

  1. Plugin catalog (provider-catalog.js) defines correct contextWindow: 1e6
  2. resolveContextTokensForModel() looks up lookupContextTokens("opencode-go/deepseek-v4-pro") → miss
  3. Falls back to ?? 2e5 (200K) in resolveMemoryFlushContextWindowTokens()

The plugin openclaw.plugin.json includes modelCatalog.providers.opencode-go but the onboarding pipeline does not populate the MODEL_CONTEXT_TOKEN_CACHE from the plugin catalog.

Evidence

Source (provider-catalog-BakzcJID.js:12-35):

const OPENCODE_GO_MODELS = [
  { id: "deepseek-v4-pro",  contextWindow: 1e6,   maxTokens: 384e3 },
  { id: "deepseek-v4-flash", contextWindow: 1e6,   maxTokens: 384e3 },
  // ... 17 more models, all with correct contextWindow
];

Runtime (context-fjzFpTQH.js:215-252):

function resolveContextTokensForModel(params) {
  const bareResult = lookupContextTokens(params.model, ...);
  // "deepseek-v4-pro" -> NOT in cache -> undefined
  return params.fallbackContextTokens; // not passed
}

Caller (agent-runner.runtime-Duta-cpW.js:244-251):

function resolveMemoryFlushContextWindowTokens(params) {
  return resolveContextTokensForModel({...}) ?? 2e5; // 200K fallback
}

Real-world data from live gateway (agent:main session, 2026-06-14):

  • deepseek-v4-pro shows contextTokens: 1000000 in systemPromptReport
  • Compaction fired at 204K tokens instead of ~956K (confirmed from compactionCheckpoints)
  • 2 compactions in 24 minutes with high-density conversation

Workaround

Manually add models.providers.opencode-go in openclaw.json with full model list including contextWindow.

Proposed Fix

The plugin onboarding pipeline should register model contextWindow values into the runtime cache so lookupContextTokens returns correct values for all plugin-provided models, without requiring manual config overrides.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.no-staleExclude from stale automation

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions