[PR #12021] [MERGED] thinking: fix double emit when no opening tag #13689

Closed
opened 2026-04-13 00:32:52 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/12021
Author: @drifkin
Created: 8/22/2025
Status: Merged
Merged: 8/22/2025
Merged by: @drifkin

Base: mainHead: drifkin/thinking-double-emit


📝 Commits (1)

  • 2cb0a58 thinking: fix double emit when no opening tag

📊 Changes

2 files changed (+12 additions, -1 deletions)

View changed files

📝 thinking/parser.go (+3 -1)
📝 thinking/parser_test.go (+9 -0)

📄 Description

The thinking parser will automatically transition to being a pass-through if non-whitespace is seen before an opening tag. However, we weren't clearing the buffer after the first non-whitespace input, so in practice the first token would be emitted twice.

Added a test that demonstrated this, and then fixed the bug.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/12021 **Author:** [@drifkin](https://github.com/drifkin) **Created:** 8/22/2025 **Status:** ✅ Merged **Merged:** 8/22/2025 **Merged by:** [@drifkin](https://github.com/drifkin) **Base:** `main` ← **Head:** `drifkin/thinking-double-emit` --- ### 📝 Commits (1) - [`2cb0a58`](https://github.com/ollama/ollama/commit/2cb0a580f34377c8b014ce20d8fdb370cfc2a12e) thinking: fix double emit when no opening tag ### 📊 Changes **2 files changed** (+12 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `thinking/parser.go` (+3 -1) 📝 `thinking/parser_test.go` (+9 -0) </details> ### 📄 Description The thinking parser will automatically transition to being a pass-through if non-whitespace is seen before an opening tag. However, we weren't clearing the buffer after the first non-whitespace input, so in practice the first token would be emitted twice. Added a test that demonstrated this, and then fixed the bug. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-13 00:32:52 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#13689