@@ -277,14 +277,10 @@ export class OpenAIProvider extends Provider {
277277 protected async processNormalizedChunk (
278278 normalizedChunk : NormalizedChunk ,
279279 ) : Promise < void > {
280- await super . processNormalizedChunk ( normalizedChunk ) ;
281-
282- // Backward compatibility
280+ // Backward compatibility: keep logs but avoid duplicating state updates
283281 if ( normalizedChunk . type === "tool_call_start" ) {
284282 const toolName = normalizedChunk . data . toolName ;
285283 if ( toolName ) {
286- this . usedTools . push ( toolName ) ;
287-
288284 if ( ! this . config . silent ) {
289285 process . stdout . write (
290286 JSON . stringify ( {
@@ -294,55 +290,21 @@ export class OpenAIProvider extends Provider {
294290 } ) + "\n"
295291 ) ;
296292 }
297-
298- if ( ! this . toolCalls [ toolName ] ) {
299- this . toolCalls [ toolName ] = [ ] ;
300- }
301-
302- this . toolCalls [ toolName ] . push ( {
303- args : normalizedChunk . data . toolArgs || { } ,
304- result : null ,
305- } ) ;
306293 }
307294 } else if ( normalizedChunk . type === "tool_call_done" ) {
308295 const toolName = normalizedChunk . data . toolName ;
309- if (
310- toolName &&
311- this . toolCalls [ toolName ] &&
312- this . toolCalls [ toolName ] . length > 0
313- ) {
314- const lastCall =
315- this . toolCalls [ toolName ] [ this . toolCalls [ toolName ] . length - 1 ] ;
316- if ( lastCall ) {
317- lastCall . result = { id : `result_${ Date . now ( ) } ` , status : "completed" } ;
318-
319- if ( ! this . config . silent ) {
320- process . stdout . write (
321- JSON . stringify ( {
322- type : "model_stream" ,
323- model : this . currentModel ,
324- text : `Tool ${ toolName } completed\n` ,
325- } ) + "\n"
326- ) ;
327- }
328- }
296+ if ( ! this . config . silent && toolName ) {
297+ process . stdout . write (
298+ JSON . stringify ( {
299+ type : "model_stream" ,
300+ model : this . currentModel ,
301+ text : `Tool ${ toolName } completed\n` ,
302+ } ) + "\n"
303+ ) ;
329304 }
330305 }
331306
332- // Handle OpenAI-specific chunk types
333- if ( normalizedChunk . originalChunk ?. type === "response.output_item.added" ) {
334- const handlers = this . getChunkHandlers ( ) ;
335- if ( handlers . openai ?. onResponseOutputItemAdded ) {
336- await handlers . openai . onResponseOutputItemAdded ( normalizedChunk . originalChunk ) ;
337- }
338- }
339-
340- if ( normalizedChunk . originalChunk ?. type === "response.output_item.done" ) {
341- const handlers = this . getChunkHandlers ( ) ;
342- if ( handlers . openai ?. onResponseOutputItemDone ) {
343- await handlers . openai . onResponseOutputItemDone ( normalizedChunk . originalChunk ) ;
344- }
345- }
307+ // Provider-specific handlers are invoked centrally by the normalizer
346308
347309 // Handle text delta accumulation
348310 if ( normalizedChunk . type === "text_delta" ) {
0 commit comments