@@ -493,8 +493,12 @@ func (s State) ContinuationContent() (string, error) {
493
493
}
494
494
495
495
func (r *Runner) resume(callCtx engine.Context, monitor Monitor, env []string, state *State) (retState *State, retErr error) {
496
+ handleOutput := true
497
+
496
498
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
+ }
498
502
}()
499
503
500
504
if state.Continuation == nil {
@@ -521,21 +525,33 @@ func (r *Runner) resume(callCtx engine.Context, monitor Monitor, env []string, s
521
525
522
526
if state.Continuation.Result != nil && len(state.Continuation.Calls) == 0 && state.SubCallID == "" && state.ResumeInput == nil {
523
527
progressClose()
524
- monitor.Event(Event{
525
- Time: time.Now(),
526
- CallContext: callCtx.GetCallContext(),
527
- Type: EventTypeCallFinish,
528
- Content: getEventContent(*state.Continuation.Result, callCtx),
529
- })
530
528
if callCtx.Tool.Chat {
531
- return &State{
529
+ retState = &State{
532
530
Continuation: state.Continuation,
533
531
ContinuationToolID: callCtx.Tool.ID,
534
- }, nil
532
+ }
533
+ } else {
534
+ retState = &State{
535
+ Result: state.Continuation.Result,
536
+ }
535
537
}
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
539
555
}
540
556
541
557
monitor.Event(Event{
0 commit comments