From 6e59060a01d30a957fe953f3531035e10175016c Mon Sep 17 00:00:00 2001 From: Deluan Date: Sat, 19 Apr 2025 13:01:41 -0400 Subject: [PATCH] fix: prevent double initialization of agents Modify the createAgents function to call each agent constructor only once.\n\nPreviously, the constructor (init(ds)) was called first to check if the\nagent could be initialized, and then called again when appending the agent\nto the result slice. This caused unnecessary work and duplicate log messages.\n\nThe fix stores the result of the first call in the 'agent' variable and\nreuses this instance when appending, ensuring each constructor runs only once. --- core/agents/agents.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/agents/agents.go b/core/agents/agents.go index 50a1e04ad..9814c9f18 100644 --- a/core/agents/agents.go +++ b/core/agents/agents.go @@ -45,7 +45,7 @@ func createAgents(ds model.DataStore) *Agents { continue } enabled = append(enabled, name) - res = append(res, init(ds)) + res = append(res, agent) } log.Debug("List of agents enabled", "names", enabled)