Skip to content

fix(ollama): remove Ollama from isReasoningTagProvider (#2279)#16191

Merged
steipete merged 2 commits intoopenclaw:mainfrom
Glucksberg:fix/ollama-reasoning-tag-2279
Feb 14, 2026
Merged

fix(ollama): remove Ollama from isReasoningTagProvider (#2279)#16191
steipete merged 2 commits intoopenclaw:mainfrom
Glucksberg:fix/ollama-reasoning-tag-2279

Conversation

@Glucksberg
Copy link
Contributor

@Glucksberg Glucksberg commented Feb 14, 2026

Summary

Fixes #2279

Problem

All Ollama models return (no output) when used through OpenClaw. The TUI and messaging channels show no response even though the models produce valid output via direct API calls.

Root Cause

isReasoningTagProvider() in src/utils/provider-utils.ts returns true for Ollama, which causes:

  1. enforceFinalTag: truestripBlockTags() enforces strict <final> tag extraction. Since Ollama models don't emit <final> tags, all text content is discarded.

  2. System prompt injection<think>/<final> format instructions are injected, which most Ollama models don't follow reliably.

Why Ollama Doesn't Need Tag Enforcement

Ollama's OpenAI-compatible endpoint already handles reasoning natively via the reasoning field in streaming chunks:

{"choices":[{"delta":{"content":"","reasoning":"The user said hello"}}]}
{"choices":[{"delta":{"content":"Hello! How can I help?"}}]}

The pi-ai library correctly maps reasoning → thinking blocks and content → text blocks. Tag-based enforcement is unnecessary and actively harmful.

Fix

Remove "ollama" from the isReasoningTagProvider() check.

Tests

Added comprehensive test suite for isReasoningTagProvider() covering all providers.

Greptile Overview

Greptile Summary

Removes "ollama" from isReasoningTagProvider() in src/utils/provider-utils.ts to fix #2279, where all Ollama models returned (no output). The root cause was that isReasoningTagProvider("ollama") returned true, which triggered enforceFinalTag: true and injected <think>/<final> format instructions. Since Ollama models don't emit <final> tags, stripBlockTags() discarded all text content. Ollama's OpenAI-compatible endpoint already handles reasoning natively via the reasoning field in streaming chunks, making tag-based enforcement both unnecessary and harmful.

  • Removed "ollama" from the provider list in isReasoningTagProvider() with a clear explanatory comment
  • Added comprehensive test suite for isReasoningTagProvider() covering all provider branches (Ollama, Google variants, Minimax, null/undefined/empty, and standard providers)
  • Impact is well-scoped: the function is consumed in 5 files (get-reply-run.ts, compact.ts, attempt.ts, agent-runner-utils.ts, and indirectly via the test), and removing Ollama from the check correctly prevents both enforceFinalTag and reasoning tag system prompt injection for Ollama sessions

Confidence Score: 5/5

  • This PR is safe to merge — it's a minimal, well-targeted bug fix with comprehensive tests.
  • The change is a single-line removal in a pure function with no side effects beyond its return value. The fix is well-justified: Ollama handles reasoning natively via its reasoning field, making tag enforcement both unnecessary and actively harmful (causing all output to be discarded). The new test file covers all code paths in the function. I traced all 5 downstream consumers and confirmed the change correctly prevents both enforceFinalTag: true and reasoningTagHint: true for Ollama sessions without affecting other providers.
  • No files require special attention.

Last reviewed commit: 45de9e8

@openclaw-barnacle openclaw-barnacle bot added size: S experienced-contributor Contributor with 10+ merged PRs labels Feb 14, 2026
@steipete steipete self-assigned this Feb 14, 2026
Glucksberg and others added 2 commits February 14, 2026 14:08
Ollama's OpenAI-compatible endpoint handles reasoning natively via the
`reasoning` field in streaming chunks. Treating Ollama as a
reasoning-tag provider incorrectly forces <think>/<final> tag
enforcement, which causes stripBlockTags() to discard all output
(since Ollama models don't emit <final> tags), resulting in
'(no output)' for every Ollama model.

This fix removes 'ollama' from the isReasoningTagProvider() check,
allowing Ollama models to work correctly through the standard
content/reasoning field separation.
@steipete steipete force-pushed the fix/ollama-reasoning-tag-2279 branch from 45de9e8 to 4f49f9e Compare February 14, 2026 13:14
@steipete steipete merged commit 7d3e578 into openclaw:main Feb 14, 2026
23 checks passed
@steipete
Copy link
Contributor

Landed via temp rebase onto main.

  • Gate: pnpm check; pnpm test
  • Land commit: 4f49f9e
  • Merge commit: 7d3e578

Thanks @Glucksberg!

hamidzr pushed a commit to hamidzr/openclaw that referenced this pull request Feb 14, 2026
openperf pushed a commit to openperf/moltbot that referenced this pull request Feb 14, 2026
openperf pushed a commit to openperf/moltbot that referenced this pull request Feb 14, 2026
BigUncle pushed a commit to BigUncle/openclaw that referenced this pull request Feb 14, 2026
mverrilli pushed a commit to mverrilli/openclaw that referenced this pull request Feb 14, 2026
GwonHyeok pushed a commit to learners-superpumped/openclaw that referenced this pull request Feb 15, 2026
Benkei-dev pushed a commit to Benkei-dev/openclaw that referenced this pull request Feb 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

experienced-contributor Contributor with 10+ merged PRs size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ollama models return '(no output)' — enforceFinalTag incorrectly applied to all Ollama models

2 participants