Skip to content

Commit 996d7b7

Browse files
committed
fix(opencode-go): register model catalog via applyProviderConfigWithModelCatalog
Previously, applyOpencodeGoProviderConfig was an empty no-op that returned cfg unchanged. This meant the opencode-go plugin's static model catalog (including correct contextWindow values like deepseek-v4-pro: 1M) was never registered into the runtime model context window cache. As a result, resolveContextTokensForModel() failed to look up any opencode-go model and fell back to the hardcoded 200K default, causing premature compaction (threshold 156K instead of 956K). Changes: - Export OPENCODE_GO_MODELS and OPENCODE_GO_OPENAI_BASE_URL from extensions/opencode-go/provider-catalog.ts - Implement applyOpencodeGoProviderConfig to call applyProviderConfigWithModelCatalog with the full static model catalog, matching the pattern used by deepseek and other built-in providers. Fixes: agent compaction triggering at ~156K tokens on 1M context models Refs: #92912
1 parent e99ab38 commit 996d7b7

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

extensions/opencode-go/onboard.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
// Opencode Go setup module handles plugin onboarding behavior.
22
import {
33
applyAgentDefaultModelPrimary,
4+
applyProviderConfigWithModelCatalog,
45
type OpenClawConfig,
56
} from "openclaw/plugin-sdk/provider-onboard";
7+
import { OPENCODE_GO_OPENAI_BASE_URL, OPENCODE_GO_MODELS } from "./provider-catalog";
68

79
export const OPENCODE_GO_DEFAULT_MODEL_REF = "opencode-go/kimi-k2.6";
810

911
export function applyOpencodeGoProviderConfig(cfg: OpenClawConfig): OpenClawConfig {
10-
return cfg;
12+
return applyProviderConfigWithModelCatalog(cfg, {
13+
agentModels: {
14+
...cfg.agents?.defaults?.models,
15+
},
16+
providerId: "opencode-go",
17+
api: "openai-completions",
18+
baseUrl: OPENCODE_GO_OPENAI_BASE_URL,
19+
catalogModels: OPENCODE_GO_MODELS,
20+
});
1121
}
1222

1323
export function applyOpencodeGoConfig(cfg: OpenClawConfig): OpenClawConfig {

extensions/opencode-go/provider-catalog.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type {
1313

1414
const PROVIDER_ID = "opencode-go";
1515

16-
const OPENCODE_GO_OPENAI_BASE_URL = "https://opencode.ai/zen/go/v1";
16+
export const OPENCODE_GO_OPENAI_BASE_URL = "https://opencode.ai/zen/go/v1";
1717
const OPENCODE_GO_ANTHROPIC_BASE_URL = "https://opencode.ai/zen/go";
1818
const OPENCODE_GO_KIMI_NO_REASONING_MODEL_IDS = new Set(["kimi-k2.5", "kimi-k2.6"]);
1919
const OPENCODE_GO_MODELS_ENDPOINT = "https://opencode.ai/zen/go/v1/models";
@@ -27,7 +27,7 @@ type OpencodeGoModelDefinition = ModelDefinitionConfig & {
2727
input: Array<"text" | "image">;
2828
};
2929

30-
const OPENCODE_GO_MODELS = (
30+
export const OPENCODE_GO_MODELS = (
3131
[
3232
{
3333
id: "deepseek-v4-pro",

0 commit comments

Comments
 (0)