Commit 16c54e9
committed
fix(reasoning): skip duplicate callback for <think>-extracted reasoning 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.1 parent b51db2b commit 16c54e9
1 file changed
Lines changed: 10 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4494 | 4494 | | |
4495 | 4495 | | |
4496 | 4496 | | |
| 4497 | + | |
4497 | 4498 | | |
4498 | 4499 | | |
4499 | 4500 | | |
| |||
4509 | 4510 | | |
4510 | 4511 | | |
4511 | 4512 | | |
4512 | | - | |
4513 | | - | |
4514 | | - | |
4515 | | - | |
| 4513 | + | |
| 4514 | + | |
| 4515 | + | |
| 4516 | + | |
| 4517 | + | |
| 4518 | + | |
| 4519 | + | |
| 4520 | + | |
| 4521 | + | |
4516 | 4522 | | |
4517 | 4523 | | |
4518 | 4524 | | |
| |||
0 commit comments