Skip to content

Commit 7a45743

Browse files
committed
fix(ollama): honor native model capabilities
1 parent 8ba8253 commit 7a45743

5 files changed

Lines changed: 56 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Docs: https://docs.openclaw.ai
88

99
- Logging: write validated diagnostic trace context as top-level `traceId`, `spanId`, `parentSpanId`, and `traceFlags` fields in file-log JSONL records so traced requests and model calls are easier to correlate in log processors. Refs #40353. Thanks @liangruochong44-ui.
1010
- Logging/sessions: apply configured redaction patterns to persisted session transcript text and accept escaped character classes in safe custom redaction regexes, so transcript JSONL no longer keeps matching sensitive text in the clear. Fixes #42982. Thanks @panpan0000.
11+
- Providers/Ollama: honor `/api/show` capabilities when registering local models so non-tool Ollama models no longer receive the agent tool surface, and keep native Ollama thinking opt-in instead of enabling it by default. Fixes #64710 and duplicate #65343. Thanks @yuan-b, @netherby, @xilopaint, and @Diyforfun2026.
1112
- Auto-reply: poison inbound message dedupe after replay-unsafe provider/runtime failures so retries stay safe before visible progress but cannot duplicate messages after block output, tool side effects, or session progress. Fixes #69303; keeps #58549 and #64606 as duplicate validation. Thanks @martingarramon, @NikolaFC, and @zeroth-blip.
1213
- Agents/model fallback: jump directly to a known later live-session model redirect instead of walking unrelated fallback candidates, while preserving the already-landed live-session/fallback loop guard. Fixes #57471; related loop family already closed via #58496. Thanks @yuxiaoyang2007-prog.
1314
- Gateway/Bonjour: keep @homebridge/ciao cancellation handlers registered across advertiser restarts so late probing cancellations cannot crash Linux and other mDNS-churned gateways. Thanks @codex.

extensions/ollama/index.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,32 @@ describe("ollama plugin", () => {
528528
expect((payloadSeen?.options as Record<string, unknown> | undefined)?.think).toBeUndefined();
529529
});
530530

531+
it("keeps native Ollama thinking off by default while exposing an opt-in toggle", () => {
532+
const provider = registerProvider();
533+
534+
expect(
535+
provider.resolveThinkingProfile?.({
536+
provider: "ollama",
537+
modelId: "llama3.2:latest",
538+
reasoning: false,
539+
}),
540+
).toEqual({
541+
levels: [{ id: "off" }],
542+
defaultLevel: "off",
543+
});
544+
545+
expect(
546+
provider.resolveThinkingProfile?.({
547+
provider: "ollama",
548+
modelId: "gemma4:31b",
549+
reasoning: true,
550+
}),
551+
).toEqual({
552+
levels: [{ id: "off" }, { id: "low", label: "on" }],
553+
defaultLevel: "off",
554+
});
555+
});
556+
531557
it("wraps native Ollama payloads with top-level think=true when thinking is enabled", () => {
532558
const { baseStreamFn, payloadSeen } = captureWrappedOllamaPayload("low");
533559
expect(baseStreamFn).toHaveBeenCalledTimes(1);

extensions/ollama/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ export default definePluginEntry({
166166
contributeResolvedModelCompat: ({ model }) =>
167167
usesOllamaOpenAICompatTransport(model) ? { supportsUsageInStreaming: true } : undefined,
168168
resolveReasoningOutputMode: () => "native",
169+
resolveThinkingProfile: ({ reasoning }) => ({
170+
levels: reasoning === true ? [{ id: "off" }, { id: "low", label: "on" }] : [{ id: "off" }],
171+
defaultLevel: "off",
172+
}),
169173
wrapStreamFn: createConfiguredOllamaCompatStreamWrapper,
170174
createEmbeddingProvider: async ({ config, model, remote }) => {
171175
const { provider, client } = await createOllamaEmbeddingProvider({

extensions/ollama/src/provider-models.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,26 @@ describe("ollama provider models", () => {
203203
"vision",
204204
"completion",
205205
"tools",
206+
"thinking",
206207
]);
207208
expect(visionModel.input).toEqual(["text", "image"]);
209+
expect(visionModel.reasoning).toBe(true);
210+
expect(visionModel.compat?.supportsTools).toBe(true);
208211

209212
const textModel = buildOllamaModelDefinition("glm-5.1:cloud", 202752, ["completion", "tools"]);
210213
expect(textModel.input).toEqual(["text"]);
214+
expect(textModel.reasoning).toBe(false);
215+
expect(textModel.compat?.supportsTools).toBe(true);
211216

212217
const noCapabilities = buildOllamaModelDefinition("unknown-model", 65536);
213218
expect(noCapabilities.input).toEqual(["text"]);
219+
expect(noCapabilities.compat).toBeUndefined();
220+
});
221+
222+
it("disables tool support when Ollama capabilities omit tools", () => {
223+
const model = buildOllamaModelDefinition("embeddinggemma:latest", 2048, ["embedding"]);
224+
225+
expect(model.reasoning).toBe(false);
226+
expect(model.compat?.supportsTools).toBe(false);
214227
});
215228
});

extensions/ollama/src/provider-models.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,25 @@ export function buildOllamaModelDefinition(
218218
): ModelDefinitionConfig {
219219
const hasVision = capabilities?.includes("vision") ?? false;
220220
const input: ("text" | "image")[] = hasVision ? ["text", "image"] : ["text"];
221+
const reasoning =
222+
capabilities === undefined
223+
? isReasoningModelHeuristic(modelId)
224+
: capabilities.includes("thinking");
225+
const compat =
226+
capabilities === undefined
227+
? undefined
228+
: {
229+
supportsTools: capabilities.includes("tools"),
230+
};
221231
return {
222232
id: modelId,
223233
name: modelId,
224-
reasoning: isReasoningModelHeuristic(modelId),
234+
reasoning,
225235
input,
226236
cost: OLLAMA_DEFAULT_COST,
227237
contextWindow: contextWindow ?? OLLAMA_DEFAULT_CONTEXT_WINDOW,
228238
maxTokens: OLLAMA_DEFAULT_MAX_TOKENS,
239+
...(compat ? { compat } : {}),
229240
};
230241
}
231242

0 commit comments

Comments
 (0)