Skip to content

fix: improve Ollama thinking profile resolution for live-discovered reasoning models using name heuristic#94362

Closed
lizanle521 wants to merge 1 commit into
openclaw:mainfrom
lizanle521:fix-93835
Closed

fix: improve Ollama thinking profile resolution for live-discovered reasoning models using name heuristic#94362
lizanle521 wants to merge 1 commit into
openclaw:mainfrom
lizanle521:fix-93835

Conversation

@lizanle521

@lizanle521 lizanle521 commented Jun 18, 2026

Copy link
Copy Markdown

Problem

Telegram /think menu shows only off for live-discovered Ollama thinking models (no catalog entry), but /think <level> accepts them.

Root Cause

For models discovered at runtime (not in static config/catalog), reasoning flag passed to resolveThinkingProfile is undefined. The Ollama plugin previously returned an off-only profile when reasoning was not explicitly true.

Solution

Modified resolveThinkingProfile in extensions/ollama/provider-policy-api.ts to also consider model name heuristics when reasoning is not explicitly false. We now treat a model as reasoning if either:

  • reasoning === true (catalog explicitly says it's a reasoning model)
  • isReasoningModelHeuristic(modelId) returns true (based on common reasoning model naming patterns)

This ensures that live-discovered Ollama models with reasoning capabilities (e.g. deepseek-r1, qwen3:...thinker) get the full thinking level menu, while still respecting explicit non-reasoning flags.

Fixes #93835

Real behavior proof

Setup

  • OpenClaw instance running with Telegram extension enabled.
  • Ollama provider configured and reachable.
  • Model list includes at least one reasoning model not present in the static catalog (e.g. deepseek-r1:latest or qwen3:14b).

Steps

  1. Ensure the model is discovered live (not in config.yaml model catalog).
  2. In a Telegram chat with the bot, issue /think to view the menu.
  3. Observe the available thinking levels.

Expected after fix

  • The /think menu displays multiple reasoning levels (e.g., off, low, medium, high or similar) for the live-discovered reasoning model.
  • Previously only off was shown; now the full list appears.

Optional verification

  • Run unit tests for isReasoningModelHeuristic with known reasoning model name patterns.
  • Execute listThinkingLevels(provider='ollama', model='deepseek-r1', catalog={}) and confirm it returns a non-off-only profile.

(If you have runtime logs or screenshots, attach them here.)

@openclaw-barnacle openclaw-barnacle Bot added extensions: ollama size: XS triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 18, 2026
@clawsweeper

clawsweeper Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close as superseded: the open runtime-catalog PR is the stronger canonical fix for the same live-discovered Ollama /think menu bug, while this provider-side heuristic does not cover the reported glm-5.2:cloud case and lacks real behavior proof.

Root-cause cluster
Relationship: superseded
Canonical: #94067
Summary: The cluster centers on live-discovered Ollama reasoning metadata missing from native /think menus; this PR is a provider-side heuristic candidate, while the canonical PR fixes the caller layer by passing runtime catalog metadata into native menu resolution.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Canonical path: Keep the remaining work on #94067 and #93835, where runtime catalog metadata remains authoritative for native /think menus.

So I’m closing this here and keeping the remaining discussion on #94067 and #93835.

Review details

Best possible solution:

Keep the remaining work on #94067 and #93835, where runtime catalog metadata remains authoritative for native /think menus.

Do we have a high-confidence way to reproduce the issue?

Yes. The linked issue gives concrete OpenClaw 2026.6.8 Telegram/Ollama steps, and current main shows native menus can fall back to configured-only catalog metadata while Ollama discovery records reasoning: true; I did not run a live Telegram/Ollama endpoint in this read-only review.

Is this the best way to solve the issue?

No. This branch is a plausible provider-policy mitigation for heuristic-matching models, but the best fix is to pass the existing runtime catalog into native /think menu and autocomplete resolution so live Ollama capability metadata stays authoritative.

Security review:

Security review cleared: The diff changes provider policy logic and imports an existing local helper; it does not touch dependencies, lockfiles, workflows, secrets, package resolution, or other supply-chain surfaces.

AGENTS.md: found and applied where relevant.

What I checked:

  • Repository policy applied: Root and extension policies were read; provider routing/fallback behavior is compatibility-sensitive and extension public artifacts should stay lightweight and owned by plugin boundaries. (AGENTS.md:34, f18ff7551edc)
  • Current PR uses name heuristic for unknown reasoning: The PR computes effective reasoning from reasoning === true || isReasoningModelHeuristic(modelId), so live-discovered models without catalog metadata depend on regex name matching. (extensions/ollama/provider-policy-api.ts:66, 3f839fd679c9)
  • Heuristic misses the reported model: Current main's Ollama heuristic only matches r1, reasoning, think, or reason, which does not match the linked issue's glm-5.2:cloud model id. (extensions/ollama/src/provider-models.ts:241, f18ff7551edc)
  • Runtime capability metadata already exists: Ollama discovery maps /api/show capabilities to reasoning, using capabilities.includes("thinking") when capabilities are available. (extensions/ollama/src/provider-models.ts:257, f18ff7551edc)
  • Current menu fallback explains the bug: Native command menu resolution uses a supplied catalog when present, otherwise it falls back to buildConfiguredModelCatalog, which can omit live-discovered Ollama metadata. (src/auto-reply/commands-registry.ts:338, f18ff7551edc)
  • Current Telegram caller omits runtime catalog: Current main resolves provider/model context for native commands but calls resolveCommandArgMenu without a runtime catalog. (extensions/telegram/src/bot-native-commands.ts:1138, f18ff7551edc)

Likely related people:

  • openperf: Authored the open canonical runtime-catalog PR that targets the same live-discovered Ollama /think menu bug across Telegram, Slack, and Discord native surfaces. (role: likely follow-up owner; confidence: high; commits: a2aed9e4ffc4; files: extensions/telegram/src/bot-native-commands.ts, extensions/slack/src/monitor/slash.ts, extensions/discord/src/monitor/native-command.ts)
  • steipete: Authored the merged Ollama live catalog metadata work that supplies reasoning: true from capability discovery, which the native menu path should consume. (role: adjacent provider/catalog contributor; confidence: high; commits: af79cd6a9d35, 2bfe4dfb703b; files: extensions/ollama/index.ts, extensions/ollama/src/provider-models.ts, src/agents/model-catalog.ts)
  • yfge: Commit history shows this author added the Ollama provider-policy thinking profile surface whose undefined-reasoning behavior is implicated by this PR. (role: introduced provider policy surface; confidence: medium; commits: 7a9efc138998; files: extensions/ollama/provider-policy-api.ts, extensions/ollama/index.ts)
  • thewilloftheshadow: Commit history ties the shared dynamic argument-menu framework used by /think choices to this author, making them relevant for the caller-layer behavior. (role: introduced dynamic command menu framework; confidence: medium; commits: 74bc5bfd7cae; files: src/auto-reply/commands-registry.ts)

Codex review notes: model internal, reasoning high; reviewed against f18ff7551edc.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P2 Normal backlog priority with limited blast radius. labels Jun 18, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Jun 18, 2026
@steipete

Copy link
Copy Markdown
Contributor

Superseded by #94067, landed in e3ccf87.

The canonical fix uses the discovered model's declared reasoning capability through the runtime catalog across Telegram, Slack, and Discord. This avoids a GLM/model-name heuristic and keeps the behavior correct for any live-discovered reasoning model. Thanks @lizanle521 for the investigation and patch.

@steipete steipete closed this Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: ollama mantis: telegram-visible-proof Mantis should capture Telegram visible proof. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Telegram /think menu shows only off for live-discovered Ollama thinking models, but /think <level> accepts them

2 participants