Repository navigation
Commit 26e73fa
fix(gateway): separate finish_reason from content chunks in streaming responses
Per OpenAI streaming spec, finish_reason must appear only on the final
chunk at choices[0] level with an empty delta, not mixed into content
chunks. Split writeAssistantContentChunk (always finish_reason: null)
from a new writeAssistantFinishChunk (empty delta, finish_reason: stop).
Emit the finish chunk from the lifecycle end handler, the error path,
and the finally fallback path.
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>1 parent 828c64e commit 26e73fa
2 files changed
Lines changed: 52 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
792 | 792 | | |
793 | 793 | | |
794 | 794 | | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
795 | 810 | | |
796 | 811 | | |
797 | 812 | | |
| |||
857 | 872 | | |
858 | 873 | | |
859 | 874 | | |
860 | | - | |
861 | | - | |
862 | | - | |
863 | | - | |
864 | | - | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
865 | 883 | | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
866 | 890 | | |
867 | 891 | | |
868 | 892 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | | - | |
| 149 | + | |
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
160 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
161 | 177 | | |
162 | 178 | | |
163 | 179 | | |
| |||
586 | 602 | | |
587 | 603 | | |
588 | 604 | | |
589 | | - | |
590 | 605 | | |
591 | 606 | | |
592 | 607 | | |
| |||
597 | 612 | | |
598 | 613 | | |
599 | 614 | | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
600 | 618 | | |
601 | 619 | | |
602 | 620 | | |
| |||
629 | 647 | | |
630 | 648 | | |
631 | 649 | | |
632 | | - | |
633 | 650 | | |
634 | 651 | | |
635 | 652 | | |
| |||
641 | 658 | | |
642 | 659 | | |
643 | 660 | | |
644 | | - | |
645 | 661 | | |
| 662 | + | |
646 | 663 | | |
647 | 664 | | |
648 | 665 | | |
| |||
653 | 670 | | |
654 | 671 | | |
655 | 672 | | |
| 673 | + | |
656 | 674 | | |
657 | 675 | | |
658 | 676 | | |
| |||
0 commit comments