Skip to content

Commit ae77e8a

Browse files
bug: no longer track synchronous runs in memory
1 parent fb55489 commit ae77e8a

File tree

2 files changed

+2
-33
lines changed

2 files changed

+2
-33
lines changed

pkg/controller/handlers/runs/runs.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (h *Handler) Resume(req router.Request, _ router.Response) error {
5858

5959
if run.Spec.PreviousRunName != "" {
6060
if err := req.Get(&v1.Run{}, run.Namespace, run.Spec.PreviousRunName); apierrors.IsNotFound(err) {
61-
run.Status.Error = fmt.Sprintf("run %s not found", run.Spec.PreviousRunName)
61+
run.Status.Error = fmt.Sprintf("run %s not found: %s", run.Spec.PreviousRunName, run.Status.Error)
6262
run.Status.State = gptscript.Error
6363
return nil
6464
} else if err != nil {
@@ -67,12 +67,7 @@ func (h *Handler) Resume(req router.Request, _ router.Response) error {
6767
}
6868

6969
if run.Spec.Synchronous {
70-
if h.invoker.IsSynchronousPending(run.Name) {
71-
return nil
72-
}
73-
run.Status.Error = "run was interrupted most likely due to a system reset"
74-
run.Status.State = gptscript.Error
75-
return req.Client.Status().Update(req.Ctx, run)
70+
return nil
7671
}
7772

7873
return h.invoker.Resume(req.Ctx, req.Client, &thread, run)

pkg/invoke/invoker.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -328,18 +328,6 @@ type runOptions struct {
328328
Timeout time.Duration
329329
}
330330

331-
var (
332-
synchronousPending = map[string]struct{}{}
333-
synchrounousLock sync.Mutex
334-
)
335-
336-
func (i *Invoker) IsSynchronousPending(runName string) bool {
337-
synchrounousLock.Lock()
338-
defer synchrounousLock.Unlock()
339-
_, ok := synchronousPending[runName]
340-
return ok
341-
}
342-
343331
func (i *Invoker) createRun(ctx context.Context, c kclient.WithWatch, thread *v1.Thread, tool any, input string, opts runOptions) (_ *Response, retErr error) {
344332
previousRunName := thread.Status.LastRunName
345333
if opts.PreviousRunName != "" {
@@ -383,20 +371,6 @@ func (i *Invoker) createRun(ctx context.Context, c kclient.WithWatch, thread *v1
383371
return nil, err
384372
}
385373

386-
if opts.Synchronous {
387-
synchrounousLock.Lock()
388-
synchronousPending[run.Name] = struct{}{}
389-
synchrounousLock.Unlock()
390-
}
391-
392-
defer func() {
393-
if retErr != nil {
394-
synchrounousLock.Lock()
395-
delete(synchronousPending, run.Name)
396-
synchrounousLock.Unlock()
397-
}
398-
}()
399-
400374
if !thread.Spec.SystemTask {
401375
err = retry.RetryOnConflict(retry.DefaultBackoff, func() error {
402376
// Ensure that, regardless of which client is being used, we get an uncached version of the thread for updating.

0 commit comments

Comments
 (0)