@@ -493,8 +493,12 @@ func (s State) ContinuationContent() (string, error) {
493493}
494494
495495func (r * Runner ) resume (callCtx engine.Context , monitor Monitor , env []string , state * State ) (retState * State , retErr error ) {
496+ handleOutput := true
497+
496498 defer func () {
497- retState , retErr = r .handleOutput (callCtx , monitor , env , state , retState , retErr )
499+ if handleOutput {
500+ retState , retErr = r .handleOutput (callCtx , monitor , env , state , retState , retErr )
501+ }
498502 }()
499503
500504 if state .Continuation == nil {
@@ -521,21 +525,33 @@ func (r *Runner) resume(callCtx engine.Context, monitor Monitor, env []string, s
521525
522526 if state .Continuation .Result != nil && len (state .Continuation .Calls ) == 0 && state .SubCallID == "" && state .ResumeInput == nil {
523527 progressClose ()
524- monitor .Event (Event {
525- Time : time .Now (),
526- CallContext : callCtx .GetCallContext (),
527- Type : EventTypeCallFinish ,
528- Content : getEventContent (* state .Continuation .Result , callCtx ),
529- })
530528 if callCtx .Tool .Chat {
531- return & State {
529+ retState = & State {
532530 Continuation : state .Continuation ,
533531 ContinuationToolID : callCtx .Tool .ID ,
534- }, nil
532+ }
533+ } else {
534+ retState = & State {
535+ Result : state .Continuation .Result ,
536+ }
535537 }
536- return & State {
537- Result : state .Continuation .Result ,
538- }, nil
538+ handleOutput = false
539+ retState , retErr = r .handleOutput (callCtx , monitor , env , state , retState , nil )
540+ if retErr == nil {
541+ var content string
542+ if retState .Continuation != nil && retState .Continuation .Result != nil {
543+ content = * retState .Continuation .Result
544+ } else if retState .Result != nil {
545+ content = * retState .Result
546+ }
547+ monitor .Event (Event {
548+ Time : time .Now (),
549+ CallContext : callCtx .GetCallContext (),
550+ Type : EventTypeCallFinish ,
551+ Content : getEventContent (content , callCtx ),
552+ })
553+ }
554+ return retState , retErr
539555 }
540556
541557 monitor .Event (Event {
0 commit comments