Skip to content

Commit 6cfebdc

Browse files
committed
fix(ollama): show full thinking levels for discovered reasoning models
1 parent 7b74d73 commit 6cfebdc

4 files changed

Lines changed: 25 additions & 5 deletions

File tree

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,19 @@ describe("ollama provider policy public artifact", () => {
6565
levels: [{ id: "off" }, { id: "low" }, { id: "medium" }, { id: "high" }, { id: "max" }],
6666
defaultLevel: "off",
6767
});
68+
});
69+
70+
it("keeps off-only thinking for catalog non-reasoning models", () => {
6871
expect(resolveThinkingProfile({ reasoning: false })).toEqual({
6972
levels: [{ id: "off" }],
7073
defaultLevel: "off",
7174
});
7275
});
76+
77+
it("falls back to model heuristics when catalog reasoning is not available", () => {
78+
expect(resolveThinkingProfile({ modelId: "deepseek-r1:14b" })).toEqual({
79+
levels: [{ id: "off" }, { id: "low" }, { id: "medium" }, { id: "high" }, { id: "max" }],
80+
defaultLevel: "off",
81+
});
82+
});
7383
});

extensions/ollama/provider-policy-api.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import type { ProviderThinkingProfile } from "openclaw/plugin-sdk/plugin-entry";
33
import type { ModelProviderConfig } from "openclaw/plugin-sdk/provider-model-types";
44
import { OLLAMA_DEFAULT_BASE_URL } from "./src/defaults.js";
5+
import { isReasoningModelHeuristic } from "./src/reasoning-models.js";
56

67
type OllamaProviderConfigDraft = Partial<ModelProviderConfig>;
78

@@ -52,9 +53,15 @@ export function normalizeConfig({
5253
}
5354

5455
export function resolveThinkingProfile({
56+
modelId,
5557
reasoning,
5658
}: {
59+
modelId?: string;
5760
reasoning?: boolean;
5861
}): ProviderThinkingProfile {
59-
return reasoning ? OLLAMA_REASONING_THINKING_PROFILE : OLLAMA_NON_REASONING_THINKING_PROFILE;
62+
const supportsReasoning =
63+
reasoning ?? (modelId !== undefined ? isReasoningModelHeuristic(modelId) : false);
64+
return supportsReasoning
65+
? OLLAMA_REASONING_THINKING_PROFILE
66+
: OLLAMA_NON_REASONING_THINKING_PROFILE;
6067
}

extensions/ollama/src/provider-models.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import {
88
OLLAMA_DEFAULT_COST,
99
OLLAMA_DEFAULT_MAX_TOKENS,
1010
} from "./defaults.js";
11+
import { isReasoningModelHeuristic } from "./reasoning-models.js";
12+
13+
export { isReasoningModelHeuristic } from "./reasoning-models.js";
1114

1215
export type OllamaTagModel = {
1316
name: string;
@@ -238,10 +241,6 @@ export async function enrichOllamaModelsWithContext(
238241
return enriched;
239242
}
240243

241-
export function isReasoningModelHeuristic(modelId: string): boolean {
242-
return /r1|reasoning|think|reason/i.test(modelId);
243-
}
244-
245244
function isKnownOllamaCloudReasoningModel(modelId: string): boolean {
246245
const normalized = modelId.trim().toLowerCase();
247246
return /^deepseek-v4-(?:flash|pro):cloud$/.test(normalized);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Lightweight Ollama model-name heuristics shared by discovery and policy surfaces.
2+
export function isReasoningModelHeuristic(modelId: string): boolean {
3+
return /r1|reasoning|think|reason/i.test(modelId);
4+
}

0 commit comments

Comments
 (0)