@@ -398,19 +398,6 @@ async function processOpenAICompletionsStream(
398398 chunkPushedEvent = true ;
399399 stream . push ( event ) ;
400400 } ;
401- const finishCurrentBlock = ( ) => {
402- if ( ! currentBlock ) {
403- return ;
404- }
405- if ( currentBlock . type === "toolCall" ) {
406- currentBlock . arguments = parseStreamingJson ( currentBlock . partialArgs ) ;
407- }
408- } ;
409- const finishAllToolCallBlocks = ( ) => {
410- for ( const block of toolCallBlocksByIndex . values ( ) ) {
411- block . arguments = parseStreamingJson ( block . partialArgs ) ;
412- }
413- } ;
414401 const queuePostToolCallDelta = ( next : CompletionsReasoningDelta ) => {
415402 const nextBytes = measureUtf8Bytes ( next . text ) ;
416403 if ( pendingPostToolCallBytes + nextBytes > MAX_POST_TOOL_CALL_BUFFER_BYTES ) {
@@ -434,7 +421,6 @@ async function processOpenAICompletionsStream(
434421 } ;
435422 const appendThinkingDeltaInternal = ( reasoningDelta : { signature : string ; text : string } ) => {
436423 if ( ! currentBlock || currentBlock . type !== "thinking" ) {
437- finishCurrentBlock ( ) ;
438424 currentBlock = {
439425 type : "thinking" ,
440426 thinking : "" ,
@@ -453,7 +439,6 @@ async function processOpenAICompletionsStream(
453439 } ;
454440 const appendTextDeltaInternal = ( text : string ) => {
455441 if ( ! currentBlock || currentBlock . type !== "text" ) {
456- finishCurrentBlock ( ) ;
457442 currentBlock = { type : "text" , text : "" } ;
458443 output . content . push ( currentBlock ) ;
459444 pushStreamEvent ( { type : "text_start" , contentIndex : blockIndex ( ) , partial : output } ) ;
@@ -506,7 +491,6 @@ async function processOpenAICompletionsStream(
506491 } ;
507492 const appendRecoveredToolCall = ( toolCall : RecoveredDeepSeekDsmlToolCall ) => {
508493 const switchingToolCall = currentBlock ?. type === "toolCall" ;
509- finishCurrentBlock ( ) ;
510494 if ( switchingToolCall ) {
511495 currentBlock = null ;
512496 flushPendingPostToolCallDeltas ( ) ;
@@ -731,7 +715,6 @@ async function processOpenAICompletionsStream(
731715 }
732716 if ( ! block ) {
733717 const switchingToolCall = currentBlock ?. type === "toolCall" ;
734- finishCurrentBlock ( ) ;
735718 if ( switchingToolCall ) {
736719 currentBlock = null ;
737720 flushPendingPostToolCallDeltas ( ) ;
@@ -793,7 +776,6 @@ async function processOpenAICompletionsStream(
793776 flushReasoningTagTextPartitionerAtEnd ( ) ;
794777 flushDeepSeekToolCallRecovererAtEnd ( ) ;
795778 flushDeepSeekTextFilterAtEnd ( ) ;
796- finishAllToolCallBlocks ( ) ;
797779 currentBlock = null ;
798780 flushPendingPostToolCallDeltas ( ) ;
799781 const hasToolCalls = output . content . some ( ( block ) => block . type === "toolCall" ) ;
0 commit comments