Skip to content

Commit 037287b

Browse files
committed
perf(models): skip Ollama row runtime loading
1 parent faaeebe commit 037287b

3 files changed

Lines changed: 67 additions & 3 deletions

File tree

‎extensions/ollama/index.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ describe("ollama tool-schema compatibility", () => {
153153
});
154154
}
155155
});
156+
157+
it("keeps configured-row projection aligned with absent runtime model normalizers", () => {
158+
for (const provider of registerProvidersWithPluginConfig({})) {
159+
expect(provider.normalizeResolvedModel).toBeUndefined();
160+
}
161+
});
156162
});
157163

158164
function createOllamaResetValidationContext(

‎extensions/ollama/provider-policy-api.test.ts‎

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
// Ollama tests cover provider policy api plugin behavior.
22
import type { ModelDefinitionConfig } from "openclaw/plugin-sdk/provider-model-types";
33
import { describe, expect, it } from "vitest";
4-
import { normalizeConfig, resolveThinkingProfile } from "./provider-policy-api.js";
4+
import {
5+
normalizeConfig,
6+
projectConfiguredModelRow,
7+
resolveThinkingProfile,
8+
} from "./provider-policy-api.js";
59
import { OLLAMA_DEFAULT_BASE_URL } from "./src/defaults.js";
610

711
function createModel(id: string, name: string): ModelDefinitionConfig {
@@ -60,6 +64,48 @@ describe("ollama provider policy public artifact", () => {
6064
).toStrictEqual({});
6165
});
6266

67+
it.each(["ollama", " OLLAMA-CLOUD "])("skips runtime row normalization for %s", (provider) => {
68+
expect(
69+
projectConfiguredModelRow({
70+
provider,
71+
modelId: "qwen3.5:9b",
72+
model: {
73+
provider: provider.trim().toLowerCase(),
74+
id: "qwen3.5:9b",
75+
api: "ollama",
76+
baseUrl: OLLAMA_DEFAULT_BASE_URL,
77+
input: ["text"],
78+
name: "Qwen 3.5 9B",
79+
reasoning: true,
80+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
81+
contextWindow: 128_000,
82+
maxTokens: 8_192,
83+
},
84+
}),
85+
).toBeNull();
86+
});
87+
88+
it("keeps unrelated providers on the runtime normalization path", () => {
89+
expect(
90+
projectConfiguredModelRow({
91+
provider: "openai",
92+
modelId: "gpt-5.5",
93+
model: {
94+
provider: "openai",
95+
id: "gpt-5.5",
96+
api: "openai-responses",
97+
baseUrl: "https://api.openai.com/v1",
98+
input: ["text"],
99+
name: "GPT-5.5",
100+
reasoning: true,
101+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
102+
contextWindow: 128_000,
103+
maxTokens: 8_192,
104+
},
105+
}),
106+
).toBeUndefined();
107+
});
108+
63109
it("exposes max thinking for reasoning-capable models without full plugin activation", () => {
64110
expect(resolveThinkingProfile({ reasoning: true })).toEqual({
65111
levels: [{ id: "off" }, { id: "low" }, { id: "medium" }, { id: "high" }, { id: "max" }],

‎extensions/ollama/provider-policy-api.ts‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
// Ollama API module exposes the plugin public contract.
2-
import type { ProviderThinkingProfile } from "openclaw/plugin-sdk/plugin-entry";
2+
import type {
3+
ProviderNormalizeResolvedModelContext,
4+
ProviderThinkingProfile,
5+
} from "openclaw/plugin-sdk/plugin-entry";
36
import type { ModelProviderConfig } from "openclaw/plugin-sdk/provider-model-types";
4-
import { OLLAMA_DEFAULT_BASE_URL } from "./src/defaults.js";
7+
import { OLLAMA_CLOUD_PROVIDER_ID, OLLAMA_DEFAULT_BASE_URL } from "./src/defaults.js";
58

69
type OllamaProviderConfigDraft = Partial<ModelProviderConfig>;
710

@@ -51,6 +54,15 @@ export function normalizeConfig({
5154
return next;
5255
}
5356

57+
/**
58+
* Ollama's local and cloud providers do not normalize resolved models.
59+
* Skip full plugin activation when the model-list path asks for that no-op.
60+
*/
61+
export function projectConfiguredModelRow(ctx: ProviderNormalizeResolvedModelContext) {
62+
const provider = ctx.provider.trim().toLowerCase();
63+
return provider === "ollama" || provider === OLLAMA_CLOUD_PROVIDER_ID ? null : undefined;
64+
}
65+
5466
export function resolveThinkingProfile({
5567
reasoning,
5668
}: {

0 commit comments

Comments
 (0)