17 views
-/https://github.com/berriai/litellm/issues/27956
GitHub · issue

#27956 [Bug]: Ollama reasoning_content always null — /api/generate doesn't return thinking field

  • State: open
  • Author: @poodle64
  • Labels: llm translation

## Describe the bug

When using Ollama with thinker models (Qwen3, DeepSeek-R1 variants), `reasoning_content` is always `null` in the LiteLLM response even though the model generates extensive internal reasoning. This means any downstream observability (Langfuse, etc.) loses the reasoning chain entirely.

## Environment

- LiteLLM version: 1.83.10 - Provider: Ollama (self-hosted) - Models affected: qwen3-vl:8b, qwen3.6:27b (and any Qwen3/DeepSeek-R1 variant via Ollama)

## Root cause

`litellm/llms/ollama/completion/transformation.py` always calls `/api/generate`:

```python # line ~488 url = f"{api_base}/api/generate" ```

`transform_response` then reads:

```python response_text = response_json.get("response", "") reasoning_content, content = _parse_content_for_reasoning(response_text) ```

The `/api/generate` endpoint does **not** return a `thinking` field. Its response looks like:

```json {"response": "4.", "context": [...]} ```

In contrast, `/api/chat` **does** return thinking as a separate field:

```json {"message": {"content": "4.", "thinking": "The user asked what 2+2 is..."}} ```

`_parse_content_for_reasoning` looks for `<think>` XML tags in the response string. Qwen3 …

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (2 events)
#0 of 0 · 31d18h25m5s ago — entered · #import:https:::github.com:berriai:litellm post #2634
Issue 27956 requires coordinated provider request/response handling, transformation logic, compatibility checks, and regression tests, creating substantially more engineering risk. Issue 31408 is a localized metadata and pricing-data update.
#0 of 0 · 31d18h12m37s ago — current · #import:https:::github.com:berriai:litellm post #2850
The left issue is harder because it crosses response-ID encoding, hosted-tool gateway behavior, multi-turn state handling, and distinct streaming versus non-streaming error paths, requiring broader regression coverage. The right issue is comparatively localized to Ollama request/response transformation and reasoning-field extraction.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search