Streaming: all deltas labeled 'reasoning' when the rendered prompt contains a (pre-closed) thinking marker — non-streaming parses the same output correctly
メンテナーはふだん 3 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Issue にはソースファイルもテストも記載されていません。提供されたモデル YAML とストリーミング curl リクエストを使って動作を再現し、次にストリーミングパーサーを特定して、その分類を非ストリーミングのパスと比較してください。事前に閉じられた thinking チャネルから生成された出力が reasoning デルタではなく content デルタを生成し、通常の thinking 出力は引き続き正しく分類されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
LocalAI version: v4.7.1 (b224c96), localai/localai:latest-gpu-vulkan (docker), llama-cpp backend
Model: Gemma-4-12B-it (GGUF, Q8_0)
Summary
Gemma-4's official chat template disables thinking by ending the generation prompt with a pre-closed thought channel:
<|turn>model
<|channel>thought
<channel|>
With the channel already closed, the model emits plain answer text only — no thinking tokens at all. The non-streaming endpoint handles this correctly (message.content filled, no reasoning field). But in streaming mode, every single delta is emitted as delta.reasoning and delta.content stays null for the entire stream. The stream parser apparently enters the reasoning state because the prompt contains <|channel>thought, without checking that it is immediately closed — and never leaves that state, since the model (correctly) never emits a close marker itself.
Any correctly-templated "thinking disabled" Gemma-4 request triggers this, so OpenAI-compatible clients that read delta.content receive a completely empty stream while the server generates a full answer.
Reproduction
Model YAML (explicit template mirroring the GGUF's embedded jinja for the thinking-off case):
name: gemma-4-12b-it
backend: llama-cpp
parameters:
model: gemma-4-12b-it-Q8_0.gguf
gpu_layers: 99
stopwords:
- "<turn|>"
template:
chat_message: |-
<|turn>{{if eq .RoleName "assistant"}}model{{else}}{{.RoleName}}{{end}}
{{ if .Content }}{{.Content}}{{ end }}<turn|>
chat: |-
{{.Input -}}
<|turn>model
<|channel>thought
<channel|>
Non-streaming — correct:
curl -s http://localhost:8080/v1/chat/completions -H 'Content-Type: application/json' \
-d '{"model":"gemma-4-12b-it","max_tokens":40,"messages":[{"role":"user","content":"Say READY."}]}'
# → "message":{"role":"assistant","content":"READY. …"} (no reasoning field, finish_reason stop)
Streaming — broken (same request + "stream": true):
"delta":{"role":"assistant","content":null}
"delta":{"content":null,"reasoning":"READY"}
"delta":{"content":null,"reasoning":"."}
... ← 100 % of tokens arrive as reasoning; not a single content delta
Expected
The stream parser should only enter the reasoning state when the model emits a thinking-open marker (or should recognize that the marker in the prompt is immediately followed by its close <channel|>). Streaming and non-streaming should classify identical output identically.
Workarounds tried (no effect on the stream labeling)
- request level:
chat_template_kwargs: {enable_thinking: false},thinking: false,reasoning_format: "none",disable_thinking: true - model YAML:
disable_thinking: true,thinking_start_tokens: ["<NEVER_EMITTED>"],logit_bias(appears to be ignored on the llama-cpp path) - Removing the pre-close from the template is not viable: Gemma-4 then opens the thought channel itself (that pre-close is the model's official "thinking off" mechanism).
- 主要言語
- Go
- スター
- 49.2k
- フォーク
- 4.5k
- 平均マージ
- 1日 7時間
- マージ済み PR(30日)
- 340
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
mudler/LocalAI のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
mudler/LocalAI#11995 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
mudler/LocalAI#11991 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
fish-speech: make compile:true usable on Blackwell sm_121 by honouring the CUDA toolkit's ptxasオープンenhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
mudler/LocalAI#11348 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
feat: add automatic MCP transport selection for 2024-11-05 / 2025-03-26 / 2025-06-18 vs 2025-11-25オープンenhancement
難易度 3/5 1〜2日 初心者へのやさしさ 65/100
mudler/LocalAI#12262 · コメント 2 件 ·
メンテナーはふだん 3 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
メンテナーはふだん 3 日以内に返信
似ている issue
-
Remove CAAPFオープンkind/chore kind/cleanup needs-area
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
rancher/turtles#2848 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
priority: low 🌱 type: enhancement 💅🏼
難易度 2/5 半日 初心者へのやさしさ 84/100
nebari-dev/llm-serving-pack#199 ·
メンテナーはふだん 3 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
kedacore/keda#8225 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信