@@ -694,36 +694,31 @@ func (a *Agent[I, O]) Run(ctx context.Context, userInput *I, output *O, apiResp
694694 }
695695 return err
696696 }
697- mode := a .client .Mode ()
698- if mode == instructor .ModeToolCall || mode == instructor .ModeToolCallStrict {
699- a .memory .NewMessage (components .FunctionRole , * output )
700- } else {
701- msg := components .NewMessage (components .AssistantRole , * output )
702- msg .SetMode (a .client .Mode ())
703- switch t := apiResp .Details .(type ) {
704- case * openai.ChatCompletionResponse :
705- if len (t .Choices ) > 0 {
706- msg .SetRaw (t .Choices [0 ].Message .Content )
707- }
708- case * anthropic.CompleteResponse :
709- msg .SetRaw (t .Completion )
710- case * cohere.NonStreamedChatResponse :
711- msg .SetRaw (t .Text )
712- case * geminiAPI.GenerateContentResponse :
713- for _ , candidate := range t .Candidates {
714- if candidate == nil {
715- continue
716- }
717- for _ , part := range candidate .Content .Parts {
718- if txt := part .Text ; txt != "" {
719- msg .SetRaw (txt )
720- break
721- }
697+ msg := components .NewMessage (components .AssistantRole , * output )
698+ msg .SetMode (a .client .Mode ())
699+ switch t := apiResp .Details .(type ) {
700+ case * openai.ChatCompletionResponse :
701+ if len (t .Choices ) > 0 {
702+ msg .SetRaw (t .Choices [0 ].Message .Content )
703+ }
704+ case * anthropic.CompleteResponse :
705+ msg .SetRaw (t .Completion )
706+ case * cohere.NonStreamedChatResponse :
707+ msg .SetRaw (t .Text )
708+ case * geminiAPI.GenerateContentResponse :
709+ for _ , candidate := range t .Candidates {
710+ if candidate == nil {
711+ continue
712+ }
713+ for _ , part := range candidate .Content .Parts {
714+ if txt := part .Text ; txt != "" {
715+ msg .SetRaw (txt )
716+ break
722717 }
723718 }
724719 }
725- a .memory .AddMessage (msg )
726720 }
721+ a .memory .AddMessage (msg )
727722 if fn := a .endHook ; fn != nil {
728723 fn (ctx , a , userInput , output , apiResp )
729724 }
0 commit comments