@@ -341,7 +341,7 @@ func RunOpenAIChatStep(
341341 if chat .APIType != chatOpts .Config .APIType {
342342 return nil , nil , nil , fmt .Errorf ("API type mismatch: chat has %s, chatOpts has %s" , chat .APIType , chatOpts .Config .APIType )
343343 }
344- if ! areModelsCompatible ( chat .Model , chatOpts .Config .Model ) {
344+ if ! uctypes . AreModelsCompatible ( chat . APIType , chat .Model , chatOpts .Config .Model ) {
345345 return nil , nil , nil , fmt .Errorf ("model mismatch: chat has %s, chatOpts has %s" , chat .Model , chatOpts .Config .Model )
346346 }
347347 if chat .APIVersion != chatOpts .Config .APIVersion {
@@ -357,7 +357,7 @@ func RunOpenAIChatStep(
357357
358358 // Validate continuation if provided
359359 if cont != nil {
360- if ! areModelsCompatible ( chatOpts .Config .Model , cont .Model ) {
360+ if ! uctypes . AreModelsCompatible ( chat . APIType , chatOpts .Config .Model , cont .Model ) {
361361 return nil , nil , nil , fmt .Errorf ("cannot continue with a different model, model:%q, cont-model:%q" , chatOpts .Config .Model , cont .Model )
362362 }
363363 }
@@ -383,7 +383,7 @@ func RunOpenAIChatStep(
383383 }
384384 }
385385
386- req , err := buildOpenAIHTTPRequest (ctx , inputs , chatOpts )
386+ req , err := buildOpenAIHTTPRequest (ctx , inputs , chatOpts , cont )
387387 if err != nil {
388388 return nil , nil , nil , err
389389 }
@@ -594,12 +594,15 @@ func handleOpenAIEvent(
594594 case "message" :
595595 // Message item - content parts will be handled in streaming events
596596 case "function_call" :
597- // Track function call info for later use
597+ // Track function call info and notify frontend
598+ id := uuid .New ().String ()
598599 state .blockMap [ev .Item .Id ] = & openaiBlockState {
599600 kind : openaiBlockToolUse ,
601+ localID : id ,
600602 toolCallID : ev .Item .CallId ,
601603 toolName : ev .Item .Name ,
602604 }
605+ _ = sse .AiMsgToolInputStart (ev .Item .CallId , ev .Item .Name )
603606 }
604607 return nil , nil
605608
@@ -614,6 +617,9 @@ func handleOpenAIEvent(
614617 switch st .kind {
615618 case openaiBlockReasoning :
616619 _ = sse .AiMsgReasoningEnd (st .localID )
620+ case openaiBlockToolUse :
621+ // Tool input completion notification was already sent in function_call_arguments.done
622+ // This just marks the end of the tool item itself
617623 }
618624 }
619625 return nil , nil
@@ -839,20 +845,3 @@ func extractMessageAndToolsFromResponse(resp openaiResponse) ([]*OpenAIChatMessa
839845 return allMessages , toolCalls
840846}
841847
842- func areModelsCompatible (model1 , model2 string ) bool {
843- if model1 == model2 {
844- return true
845- }
846-
847- gpt5Models := map [string ]bool {
848- "gpt-5" : true ,
849- "gpt-5-mini" : true ,
850- "gpt-5-nano" : true ,
851- }
852-
853- if gpt5Models [model1 ] && gpt5Models [model2 ] {
854- return true
855- }
856-
857- return false
858- }
0 commit comments