From 1b2806d13931a839861817b7f744f5cb958b437e Mon Sep 17 00:00:00 2001 From: mudler Date: Sat, 12 Apr 2025 18:58:35 +0200 Subject: [PATCH] Better error handling during planning Signed-off-by: mudler --- core/agent/actions.go | 2 ++ core/agent/agent.go | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/agent/actions.go b/core/agent/actions.go index a9d5f8c..0ad7a61 100644 --- a/core/agent/actions.go +++ b/core/agent/actions.go @@ -265,6 +265,7 @@ func (a *Agent) handlePlanning(ctx context.Context, job *types.Job, chosenAction params, err := a.generateParameters(ctx, pickTemplate, subTaskAction, conv, subTaskReasoning, maxRetries) if err != nil { + xlog.Error("error generating action's parameters", "error", err) return conv, fmt.Errorf("error generating action's parameters: %w", err) } @@ -294,6 +295,7 @@ func (a *Agent) handlePlanning(ctx context.Context, job *types.Job, chosenAction result, err := a.runAction(ctx, subTaskAction, actionParams) if err != nil { + xlog.Error("error running action", "error", err) return conv, fmt.Errorf("error running action: %w", err) } diff --git a/core/agent/agent.go b/core/agent/agent.go index e34ca44..e93996e 100644 --- a/core/agent/agent.go +++ b/core/agent/agent.go @@ -605,7 +605,13 @@ func (a *Agent) consumeJob(job *types.Job, role string) { var err error conv, err = a.handlePlanning(job.GetContext(), job, chosenAction, actionParams, reasoning, pickTemplate, conv) if err != nil { - job.Result.Finish(fmt.Errorf("error running action: %w", err)) + xlog.Error("error handling planning", "error", err) + //job.Result.Conversation = conv + //job.Result.SetResponse(msg.Content) + a.reply(job, role, append(conv, openai.ChatCompletionMessage{ + Role: "assistant", + Content: fmt.Sprintf("Error handling planning: %v", err), + }), actionParams, chosenAction, reasoning) return }