Commit 854a6db
committed
feat(streaming): stream answer text live during tool loops via turn_end protocol
The live tool loops buffered all answer text per model turn (classification
of intermediate vs final is only known at turn end), so gated surfaces saw
thinking stream, then dead air with the thinking chrome stuck open, then the
whole answer at once.
Loops now emit text deltas live as `turn: 'pending'` plus a `turn_end`
event per turn. The pump buffers pending text and projects it to the byte
path (answerText/logs/memory/legacy clients) only on a final turn_end, so
all settled semantics are unchanged. Gated surfaces render the pending text
as it streams and reconcile with a reset when a turn resolves to tools:
- public chat: live `chunk` frames from the sink + dual-gated `chunk_reset`;
byte-path frame emission is suppressed to avoid duplicates (kept for
response-format transformed streams via clientStreamTransformed)
- canvas: forwarder emits live `stream:chunk` + `stream:chunk_reset`; the
execute route and HITL resume readers stop re-emitting byte chunks; panel
chat tracks per-block segments and replaces content on flush
- chat client: per-block text segments, chunk_reset handling, and thinking
chrome now settles on tool start as well as first answer chunk1 parent 807ae80 commit 854a6db
33 files changed
Lines changed: 905 additions & 119 deletions
File tree
- apps
- docs/content/docs/en/workflows/deployment
- sim
- app
- (interfaces)/chat/hooks
- api/workflows/[id]/execute
- workspace/[workspaceId]/w/[workflowId]
- components/chat
- hooks
- executor
- execution
- hooks
- lib/workflows
- executor
- streaming
- providers
- anthropic
- bedrock
- gemini
- openai-compat
- stores/chat
Lines changed: 12 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
42 | | - | |
| 43 | + | |
43 | 44 | | |
44 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
45 | 51 | | |
46 | 52 | | |
47 | 53 | | |
48 | 54 | | |
49 | 55 | | |
50 | 56 | | |
51 | 57 | | |
52 | | - | |
| 58 | + | |
53 | 59 | | |
54 | 60 | | |
55 | 61 | | |
56 | 62 | | |
57 | 63 | | |
58 | 64 | | |
59 | 65 | | |
60 | | - | |
| 66 | + | |
| 67 | + | |
61 | 68 | | |
62 | 69 | | |
63 | 70 | | |
| |||
Lines changed: 76 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
150 | 226 | | |
151 | 227 | | |
152 | 228 | | |
| |||
Lines changed: 39 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
182 | 183 | | |
183 | 184 | | |
184 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
185 | 194 | | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
186 | 199 | | |
187 | 200 | | |
188 | 201 | | |
| |||
356 | 369 | | |
357 | 370 | | |
358 | 371 | | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
359 | 377 | | |
360 | 378 | | |
361 | 379 | | |
| |||
531 | 549 | | |
532 | 550 | | |
533 | 551 | | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
534 | 567 | | |
535 | 568 | | |
536 | 569 | | |
| |||
543 | 576 | | |
544 | 577 | | |
545 | 578 | | |
546 | | - | |
547 | | - | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
548 | 585 | | |
549 | 586 | | |
550 | 587 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
92 | 95 | | |
93 | 96 | | |
94 | 97 | | |
| |||
1725 | 1728 | | |
1726 | 1729 | | |
1727 | 1730 | | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
1728 | 1737 | | |
1729 | 1738 | | |
1730 | 1739 | | |
1731 | 1740 | | |
1732 | 1741 | | |
1733 | 1742 | | |
| 1743 | + | |
1734 | 1744 | | |
1735 | 1745 | | |
1736 | 1746 | | |
| |||
1749 | 1759 | | |
1750 | 1760 | | |
1751 | 1761 | | |
| 1762 | + | |
| 1763 | + | |
1752 | 1764 | | |
1753 | 1765 | | |
1754 | 1766 | | |
| |||
Lines changed: 50 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
238 | 238 | | |
239 | 239 | | |
240 | 240 | | |
| 241 | + | |
241 | 242 | | |
242 | 243 | | |
243 | 244 | | |
| |||
256 | 257 | | |
257 | 258 | | |
258 | 259 | | |
| 260 | + | |
259 | 261 | | |
260 | 262 | | |
261 | 263 | | |
| |||
495 | 497 | | |
496 | 498 | | |
497 | 499 | | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
498 | 508 | | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
499 | 512 | | |
500 | 513 | | |
501 | | - | |
| 514 | + | |
502 | 515 | | |
503 | 516 | | |
504 | 517 | | |
| |||
512 | 525 | | |
513 | 526 | | |
514 | 527 | | |
515 | | - | |
516 | | - | |
517 | | - | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
518 | 531 | | |
519 | 532 | | |
520 | 533 | | |
| |||
534 | 547 | | |
535 | 548 | | |
536 | 549 | | |
537 | | - | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
538 | 556 | | |
539 | 557 | | |
540 | 558 | | |
541 | 559 | | |
542 | | - | |
| 560 | + | |
543 | 561 | | |
544 | 562 | | |
545 | 563 | | |
| |||
548 | 566 | | |
549 | 567 | | |
550 | 568 | | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
551 | 579 | | |
552 | | - | |
553 | | - | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
554 | 588 | | |
555 | 589 | | |
556 | 590 | | |
| |||
578 | 612 | | |
579 | 613 | | |
580 | 614 | | |
581 | | - | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
582 | 623 | | |
583 | 624 | | |
584 | 625 | | |
| |||
0 commit comments