]> git.giacomolli.uk - onechat/blobdiff - subagent_run.go
Complete context on forwarded local errors
[onechat] / subagent_run.go
index e96975c90abd0cec2a59519b2bbcab18811ebcd4..54fa4304fe9312b55506ea58aa28b9a8fa867acb 100644 (file)
@@ -177,11 +177,16 @@ func (r *SubagentRuns) create(ctx context.Context, note, task string, view []str
                return "", fmt.Errorf("create work directory: %w", err)
        }
 
-       return subagent.name, r.start(ctx, &SubagentRun{
+       err = r.start(ctx, &SubagentRun{
                subagent: subagent,
                view:     view,
                effort:   effort,
        })
+       if err != nil {
+               return subagent.name, fmt.Errorf("start created worker: %w", err)
+       }
+
+       return subagent.name, nil
 }
 
 // start runs run in the background and logs its start. Its context keeps the
@@ -369,7 +374,12 @@ func (r *SubagentRuns) chain(ctx context.Context, run *SubagentRun) (string, err
                },
        }
 
-       return chain.Run(ctx, input)
+       text, err := chain.Run(ctx, input)
+       if err != nil {
+               return text, fmt.Errorf("run worker chain: %w", err)
+       }
+
+       return text, nil
 }
 
 // take returns the messages of Tell that wait for a request of run, and removes
@@ -440,7 +450,12 @@ func (r *SubagentRuns) Resume(ctx context.Context) error {
        r.mutex.Lock()
        defer r.mutex.Unlock()
 
-       return r.save()
+       err = r.save()
+       if err != nil {
+               return fmt.Errorf("save resumed workers: %w", err)
+       }
+
+       return nil
 }
 
 // load reads the names of work.json. A missing file names none.