Copy default LLM pointers when resolving agents
ResolveAgent aliased the default config's Temperature and MaxTokens pointers into every agent that left them unset, so all resolved agents shared one backing value. A mutation through any of those pointers would corrupt the default and every other agent. It also dereferenced the default unconditionally even though it can be nil. Allocate a fresh pointer holding a copy of the default value, and guard against a nil default so each resolved agent owns independent state. Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
@@ -96,12 +96,8 @@ func (c *AgentsConfig) ResolveAgent(agent LLMAgentConfig) LLMAgentConfig {
|
||||
agent.ModelName = c.Default.ModelName
|
||||
}
|
||||
|
||||
if agent.Temperature == nil {
|
||||
agent.Temperature = c.Default.Temperature
|
||||
}
|
||||
|
||||
if agent.MaxTokens == nil {
|
||||
agent.MaxTokens = c.Default.MaxTokens
|
||||
if agent.MaxTokens == nil && c.Default.MaxTokens != nil {
|
||||
agent.MaxTokens = new(*c.Default.MaxTokens)
|
||||
}
|
||||
|
||||
return agent
|
||||
|
||||
Reference in New Issue
Block a user