Commit 5727930
authored
🤖 fix: send queued messages on tool-call-end (#665)
Queued messages are now sent as soon as a tool completes execution,
rather than waiting for the entire stream to finish.
## Problem
Previously, queued messages were only sent on `stream-end`. In
tool-using flows, this meant users had to wait for:
1. Tool execution to complete
2. LLM to process the tool result
3. LLM to finish streaming its response
This created unnecessary latency when queueing messages during tool
execution.
## Solution
Extracted a shared `sendQueuedMessages()` method called from both:
- `tool-call-end`: Sends queued messages immediately when tool completes
- `stream-end`: Continues to handle non-tool streams
The first handler to fire clears the queue, so no duplicate sends occur.
Non-tool streams continue to work exactly as before.
## Changes
- Added `sendQueuedMessages()` private method
- Updated `tool-call-end` handler to auto-send
- Refactored `stream-end` handler to use shared method
Net: +18 lines
_Generated with `mux`_1 parent bb97a71 commit 5727930
1 file changed
+20
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
408 | 408 | | |
409 | 409 | | |
410 | 410 | | |
411 | | - | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
412 | 416 | | |
413 | 417 | | |
414 | 418 | | |
415 | 419 | | |
416 | 420 | | |
417 | 421 | | |
418 | | - | |
419 | | - | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
| 422 | + | |
425 | 423 | | |
426 | 424 | | |
427 | 425 | | |
| |||
529 | 527 | | |
530 | 528 | | |
531 | 529 | | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
532 | 544 | | |
533 | 545 | | |
534 | 546 | | |
| |||
0 commit comments