Commit 0144c1a
金双
fix: merge per-token reasoning chunks into single part for GLM models
Some models (e.g., zhipu/glm) emit a separate reasoning-start/delta/end
cycle for every single token, causing each token to render as an
independent 'Thinking:' line in the TUI.
Fix by tracking the last reasoning part and reusing it when consecutive
reasoning-start events arrive, instead of creating a new part each time.
The merged part is finalized at text-start or finish-step.
Also normalize newlines in ReasoningPart render as defense-in-depth.1 parent d0a4088 commit 0144c1a
3 files changed
Lines changed: 42 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
323 | 323 | | |
324 | 324 | | |
325 | 325 | | |
326 | | - | |
| 326 | + | |
| 327 | + | |
327 | 328 | | |
328 | 329 | | |
329 | 330 | | |
| |||
Lines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1436 | 1436 | | |
1437 | 1437 | | |
1438 | 1438 | | |
1439 | | - | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
1440 | 1450 | | |
1441 | 1451 | | |
1442 | 1452 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
214 | 225 | | |
215 | 226 | | |
216 | 227 | | |
217 | 228 | | |
218 | 229 | | |
219 | 230 | | |
220 | 231 | | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
221 | 243 | | |
222 | 244 | | |
223 | 245 | | |
| |||
227 | 249 | | |
228 | 250 | | |
229 | 251 | | |
| 252 | + | |
| 253 | + | |
230 | 254 | | |
231 | 255 | | |
232 | 256 | | |
| |||
245 | 269 | | |
246 | 270 | | |
247 | 271 | | |
248 | | - | |
249 | | - | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
250 | 275 | | |
251 | | - | |
252 | 276 | | |
253 | 277 | | |
254 | 278 | | |
| |||
351 | 375 | | |
352 | 376 | | |
353 | 377 | | |
| 378 | + | |
354 | 379 | | |
355 | 380 | | |
356 | 381 | | |
| |||
398 | 423 | | |
399 | 424 | | |
400 | 425 | | |
| 426 | + | |
401 | 427 | | |
402 | 428 | | |
403 | 429 | | |
| |||
0 commit comments