From 56cd0e05ca0699ca4e46213f68a8599b95d76f11 Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Wed, 23 Apr 2025 00:12:44 +0200 Subject: [PATCH] chore: better defaults for parallel jobs (#76) * chore: better defaults for parallel jobs Signed-off-by: mudler * chore(tests): add timeout --------- Signed-off-by: mudler --- core/agent/agent.go | 8 ++++++-- core/agent/options.go | 1 + core/agent/state_test.go | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/core/agent/agent.go b/core/agent/agent.go index 44b91eb..1e27617 100644 --- a/core/agent/agent.go +++ b/core/agent/agent.go @@ -990,7 +990,6 @@ func (a *Agent) periodicallyRun(timer *time.Timer) { } func (a *Agent) Run() error { - a.startNewConversationsConsumer() xlog.Debug("Agent is now running", "agent", a.Character.Name) // The agent run does two things: @@ -1013,7 +1012,12 @@ func (a *Agent) Run() error { var muErr sync.Mutex var wg sync.WaitGroup - for i := 0; i <= a.options.parallelJobs; i++ { + parallelJobs := a.options.parallelJobs + if a.options.parallelJobs == 0 { + parallelJobs = 1 + } + + for i := 0; i < parallelJobs; i++ { xlog.Debug("Starting agent worker", "worker", i) wg.Add(1) go func() { diff --git a/core/agent/options.go b/core/agent/options.go index d27896a..942d062 100644 --- a/core/agent/options.go +++ b/core/agent/options.go @@ -64,6 +64,7 @@ func (o *options) SeparatedMultimodalModel() bool { func defaultOptions() *options { return &options{ + parallelJobs: 1, periodicRuns: 15 * time.Minute, LLMAPI: llmOptions{ APIURL: "http://localhost:8080", diff --git a/core/agent/state_test.go b/core/agent/state_test.go index 59a1b98..bb371ac 100644 --- a/core/agent/state_test.go +++ b/core/agent/state_test.go @@ -25,6 +25,7 @@ var _ = Describe("Agent test", func() { agent, err = New( WithLLMAPIURL(apiURL), WithModel(testModel), + WithTimeout("10m"), WithRandomIdentity(), ) Expect(err).ToNot(HaveOccurred())