Skip to content

fix(reasoning): skip duplicate callback for <think>-extracted reasoning during streaming - #3116

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-7d7ac769
Mar 26, 2026
Merged

fix(reasoning): skip duplicate callback for <think>-extracted reasoning during streaming#3116
teknium1 merged 1 commit into
mainfrom
hermes/hermes-7d7ac769

Conversation

@teknium1

Copy link
Copy Markdown
Collaborator

Local models (Ollama, LM Studio) embed reasoning in <think> tags in delta.content. During streaming, _stream_delta() already displays these blocks. Then _build_assistant_message() extracts them again and fires reasoning_callback, causing duplicate reasoning display.

Track whether reasoning came from structured fields (reasoning_content) vs <think> tag extraction. Only fire the callback for <think>-extracted reasoning when stream_delta_callback is NOT active. Structured reasoning always fires regardless.

Salvaged from PR #2076 by @dusterbloom (Fix A only — Fix B was already covered by PR #3013's _current_reasoning_callback() centralization). Closes #2069.

…ng during streaming

Local models (Ollama, LM Studio) embed reasoning in <think> tags in
delta.content. During streaming, _stream_delta() already displays these
blocks. Then _build_assistant_message() extracts them again and fires
reasoning_callback, causing duplicate display.

Track whether reasoning came from structured fields (reasoning_content)
vs <think> tag extraction. Only fire the callback for <think>-extracted
reasoning when stream_delta_callback is NOT active. Structured reasoning
always fires regardless.

Salvaged from PR #2076 by dusterbloom (Fix A only — Fix B was already
covered by PR #3013's _current_reasoning_callback centralization).
Closes #2069.
@teknium1
teknium1 merged commit 156b503 into main Mar 26, 2026
3 of 4 checks passed
outsourc-e pushed a commit to outsourc-e/hermes-agent that referenced this pull request Mar 26, 2026
…ng during streaming (NousResearch#3116)

Local models (Ollama, LM Studio) embed reasoning in <think> tags in
delta.content. During streaming, _stream_delta() already displays these
blocks. Then _build_assistant_message() extracts them again and fires
reasoning_callback, causing duplicate display.

Track whether reasoning came from structured fields (reasoning_content)
vs <think> tag extraction. Only fire the callback for <think>-extracted
reasoning when stream_delta_callback is NOT active. Structured reasoning
always fires regardless.

Salvaged from PR NousResearch#2076 by dusterbloom (Fix A only — Fix B was already
covered by PR NousResearch#3013's _current_reasoning_callback centralization).
Closes NousResearch#2069.
angelburgosrosado pushed a commit to angelburgosrosado/hermes-agent that referenced this pull request Apr 27, 2026
…ng during streaming (NousResearch#3116)

Local models (Ollama, LM Studio) embed reasoning in <think> tags in
delta.content. During streaming, _stream_delta() already displays these
blocks. Then _build_assistant_message() extracts them again and fires
reasoning_callback, causing duplicate display.

Track whether reasoning came from structured fields (reasoning_content)
vs <think> tag extraction. Only fire the callback for <think>-extracted
reasoning when stream_delta_callback is NOT active. Structured reasoning
always fires regardless.

Salvaged from PR NousResearch#2076 by dusterbloom (Fix A only — Fix B was already
covered by PR NousResearch#3013's _current_reasoning_callback centralization).
Closes NousResearch#2069.
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
…ng during streaming (NousResearch#3116)

Local models (Ollama, LM Studio) embed reasoning in <think> tags in
delta.content. During streaming, _stream_delta() already displays these
blocks. Then _build_assistant_message() extracts them again and fires
reasoning_callback, causing duplicate display.

Track whether reasoning came from structured fields (reasoning_content)
vs <think> tag extraction. Only fire the callback for <think>-extracted
reasoning when stream_delta_callback is NOT active. Structured reasoning
always fires regardless.

Salvaged from PR NousResearch#2076 by dusterbloom (Fix A only — Fix B was already
covered by PR NousResearch#3013's _current_reasoning_callback centralization).
Closes NousResearch#2069.
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
…ng during streaming (NousResearch#3116)

Local models (Ollama, LM Studio) embed reasoning in <think> tags in
delta.content. During streaming, _stream_delta() already displays these
blocks. Then _build_assistant_message() extracts them again and fires
reasoning_callback, causing duplicate display.

Track whether reasoning came from structured fields (reasoning_content)
vs <think> tag extraction. Only fire the callback for <think>-extracted
reasoning when stream_delta_callback is NOT active. Structured reasoning
always fires regardless.

Salvaged from PR NousResearch#2076 by dusterbloom (Fix A only — Fix B was already
covered by PR NousResearch#3013's _current_reasoning_callback centralization).
Closes NousResearch#2069.
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
…ng during streaming (NousResearch#3116)

Local models (Ollama, LM Studio) embed reasoning in <think> tags in
delta.content. During streaming, _stream_delta() already displays these
blocks. Then _build_assistant_message() extracts them again and fires
reasoning_callback, causing duplicate display.

Track whether reasoning came from structured fields (reasoning_content)
vs <think> tag extraction. Only fire the callback for <think>-extracted
reasoning when stream_delta_callback is NOT active. Structured reasoning
always fires regardless.

Salvaged from PR NousResearch#2076 by dusterbloom (Fix A only — Fix B was already
covered by PR NousResearch#3013's _current_reasoning_callback centralization).
Closes NousResearch#2069.
melon-xf added a commit to melon-xf/hermes-agent that referenced this pull request Sep 3, 2026
…ng during streaming (NousResearch#3116)

Local models (Ollama, LM Studio) embed reasoning in <think> tags in
delta.content. During streaming, _stream_delta() already displays these
blocks. Then _build_assistant_message() extracts them again and fires
reasoning_callback, causing duplicate display.

Track whether reasoning came from structured fields (reasoning_content)
vs <think> tag extraction. Only fire the callback for <think>-extracted
reasoning when stream_delta_callback is NOT active. Structured reasoning
always fires regardless.

Salvaged from PR NousResearch#2076 by dusterbloom (Fix A only — Fix B was already
covered by PR NousResearch#3013's _current_reasoning_callback centralization).
Closes NousResearch#2069.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Some combo of streaming + reasoning on local model spams thinking words on a new line each

1 participant