Commit 5835a5a
committed
fix: cache tool call names in streaming to handle providers with incomplete chunks
- Added toolCallNameCache map in combineStreamingChatResponse to store tool call names by ID
- Modified updateToolCall to accept nameCache parameter and restore missing names from cache
- Fixed streaming callback errors when providers omit function names in subsequent chunks (e.g., GPT-4.1 via OpenRouter)
- Added unit tests for name caching logic covering first chunk caching and subsequent chunk restoration
- Added integration tests for different streaming formats (GPT-4 style multi-chunk, Gemini style single-chunk, parallel tool calls)
This ensures streaming tool calls work correctly with all provider formats, including those that send function names only in the first chunk.1 parent 649d2f5 commit 5835a5a
2 files changed
Lines changed: 453 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
691 | 691 | | |
692 | 692 | | |
693 | 693 | | |
694 | | - | |
695 | | - | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
696 | 697 | | |
697 | 698 | | |
698 | 699 | | |
| |||
748 | 749 | | |
749 | 750 | | |
750 | 751 | | |
751 | | - | |
| 752 | + | |
752 | 753 | | |
753 | 754 | | |
754 | 755 | | |
| |||
805 | 806 | | |
806 | 807 | | |
807 | 808 | | |
808 | | - | |
809 | | - | |
| 809 | + | |
| 810 | + | |
810 | 811 | | |
811 | 812 | | |
812 | 813 | | |
| |||
837 | 838 | | |
838 | 839 | | |
839 | 840 | | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
840 | 844 | | |
841 | 845 | | |
842 | 846 | | |
843 | 847 | | |
| 848 | + | |
844 | 849 | | |
845 | 850 | | |
846 | 851 | | |
847 | 852 | | |
848 | 853 | | |
849 | 854 | | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
850 | 863 | | |
851 | 864 | | |
852 | 865 | | |
| |||
0 commit comments