@@ -973,7 +973,7 @@ func (i *Invoker) stream(ctx context.Context, c kclient.WithWatch, thread *v1.Th
973973 go timeoutAfter (runCtx , cancelRun , timeout )
974974 if ! isEphemeral (run ) {
975975 // Don't watch thread abort for ephemeral runs
976- go watchThreadAbort (runCtx , c , thread , cancelRun )
976+ go i . watchThreadAbort (runCtx , c , thread , cancelRun , runResp )
977977 }
978978
979979 var (
@@ -1070,10 +1070,13 @@ func (i *Invoker) stream(ctx context.Context, c kclient.WithWatch, thread *v1.Th
10701070 }
10711071}
10721072
1073- func watchThreadAbort (ctx context.Context , c kclient.WithWatch , thread * v1.Thread , cancel context.CancelCauseFunc ) {
1073+ func ( i * Invoker ) watchThreadAbort (ctx context.Context , c kclient.WithWatch , thread * v1.Thread , cancel context.CancelCauseFunc , run * gptscript. Run ) {
10741074 _ , _ = wait .For (ctx , c , thread , func (thread * v1.Thread ) (bool , error ) {
10751075 if thread .Spec .Abort {
1076- cancel (fmt .Errorf ("thread was aborted, cancelling run" ))
1076+ if err := i .gptClient .AbortRun (ctx , run ); err != nil {
1077+ return false , err
1078+ }
1079+ go timeoutAfter (ctx , cancel , 30 * time .Second )
10771080 return true , nil
10781081 }
10791082 return false , nil
0 commit comments