fix(ollama): propagate supportsTools, disable idle watchdog, fix thinking and keep_alive#81915
fix(ollama): propagate supportsTools, disable idle watchdog, fix thinking and keep_alive#81915velteyn wants to merge 1 commit into
Conversation
…king and keep_alive - buildOllamaModelDefinition: compat always includes supportsTools, defaulting to true when capabilities are unknown (Ollama's /api/chat universally supports tool calls) - AgentModelEntryConfig: add optional compat override path - resolveLlmIdleTimeoutMs: move isLocalProviderBaseUrl check to top so local providers always get idleTimeout=0 (network silence during prompt evaluation is not a hang signal) - createConfiguredOllamaCompatStreamWrapper: guard think parameter with model.reasoning check; non-reasoning models get think:false forced - buildOllamaChatRequest: add keep_alive: "1h" default with requestParams spread override so model-level config can customize
|
Codex review: needs real behavior proof before merge. Summary Reproducibility: unclear. for the claimed live qwen2.5/tool and idle-timeout failures because the PR only asserts live verification without artifacts. Source inspection gives a high-confidence path for the PR-introduced regressions against current docs and tests. Real behavior proof Next step before merge Security Review findings
Review detailsBest possible solution: Rework this into narrower Ollama fixes that preserve explicit timeout and request params, use the existing provider-model compat surface unless a fully wired new config surface is intentionally approved, and drop the now-covered thinking overlap. Do we have a high-confidence way to reproduce the issue? Unclear for the claimed live qwen2.5/tool and idle-timeout failures because the PR only asserts live verification without artifacts. Source inspection gives a high-confidence path for the PR-introduced regressions against current docs and tests. Is this the best way to solve the issue? No. The branch mixes useful Ollama fixes with contract changes and a no-op config surface; the safer path is a narrow request/compat fix that preserves documented user configuration. Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against caf8fa2ebf39. |
|
Maintainer repro update: I could only reproduce one issue from this PR on current main. The reproduced issue is the Ollama fallback path: when OpenClaw cannot read Ollama capabilities, it leaves supportsTools unset, so tools can be hidden even though native Ollama chat supports tool schemas. I could not reproduce the other claims as current-main bugs. Current main already disables the default local-provider idle watchdog while preserving explicit timeouts, already avoids sending truthy thinking to non-thinking Ollama models, and keep_alive is currently documented as a per-model opt-in rather than a default. I could not push a cleanup commit to this contributor branch because GitHub rejected the fork push with 403, so I opened a focused replacement PR with only the reproduced fix: #84055 |
|
Closing, see earlier comment by @dutifulbob |
Summary
Four fixes for Ollama model compatibility in OpenClaw, making tool-using agents (librarian) work reliably with local Ollama models:
supportsTools propagation —
buildOllamaModelDefinitionnow always setscompat.supportsTools, defaulting totruewhen capabilities are unknown (Ollama's/api/chatuniversally supports tool calls). Addedcompat?: ModelCompatConfigtoAgentModelEntryConfigas a static override path.Idle watchdog disabled for local providers —
resolveLlmIdleTimeoutMsnow checksisLocalProviderBaseUrlbefore any configured timeout clamping. Local providers (Ollama, LM Studio, llama.cpp) always getidleTimeout=0because network silence during prompt evaluation/thinking is legitimate, not a hang signal. The overall run timeout still applies at the agent level.Thinking parameter fix — Non-reasoning Ollama models (e.g., qwen2.5:3b, mistral:7b) now get
think: falseforced regardless of runtime think level, preventing Ollama's 400 error.keep_alive default —
buildOllamaChatRequestnow sendskeep_alive: "1h"by default, keeping the model loaded in memory between calls. Overridable via model configparams.keep_alive.Verification
idleTimedOut: falseafter fix (wastruebefore)Files changed
extensions/ollama/src/provider-models.ts— supportsTools default + reasoning booleanextensions/ollama/src/stream.ts— think guard + keep_alive defaultsrc/agents/pi-embedded-runner/run/llm-idle-timeout.ts— local provider check moved to topsrc/agents/pi-embedded-runner/run/llm-idle-timeout.test.ts— updated expectationssrc/config/types.agent-defaults.ts— added compat to AgentModelEntryConfigsrc/config/zod-schema.agent-defaults.ts— added compat schemasrc/config/zod-schema.core.ts— exported ModelCompatSchema