diff --git a/core/state/pool.go b/core/state/pool.go index 4797d7e..5312983 100644 --- a/core/state/pool.go +++ b/core/state/pool.go @@ -158,14 +158,12 @@ func (a *AgentPool) CreateAgent(name string, agentConfig *AgentConfig) error { return err } - defer func(ac AgentConfig, pool *AgentPool) { - go func(ac AgentConfig, pool *AgentPool) { - // Create the agent avatar - if err := a.createAgentAvatar(ac); err != nil { - xlog.Error("Failed to create agent avatar", "error", err) - } - }(ac, pool) - }(*agentConfig, a) + go func(ac AgentConfig, pool *AgentPool) { + // Create the agent avatar + if err := a.createAgentAvatar(ac); err != nil { + xlog.Error("Failed to create agent avatar", "error", err) + } + }(a.pool[name], a) return a.startAgentWithConfig(name, agentConfig) }