Files
Ilker ManapandClaude Opus 5.5 dc243f8840 The nodes' agent settings kept with the cluster's, agent.yaml down to what an agent needs to start
agents.default and agents.nodes.<id> in the cluster's settings hold
everything agent.yaml can say but the agent's id, control planes, address and
certificate, which stay in the file and are refused there. The control plane
sends each node its settings on register and, a second apart, when they
change; an agent whose settings changed checks they load beside its file,
keeps them and starts again on them, engines serving throughout. An edited
agent.yaml that loads restarts the agent too. History, audit, ctl config, the
console and the portal's settings page cover them as the rest of the
settings.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-08 18:06:36 +02:00

51 lines
1.4 KiB
Go

package agentsvc
import (
"time"
llmgwv1 "gitea.mynodes.xyz/ilker/llmgw/api/gen/llmgw/v1"
)
// SetAgentSettings gives the service each node's agent settings from the
// cluster's (BACKLOG E3), as YAML, read at each use so a change is what is
// sent next.
func (s *Service) SetAgentSettings(f func(node string) string) {
s.mu.Lock()
s.agentSettings = f
s.mu.Unlock()
}
func (s *Service) agentSettingsMsg(node string) *llmgwv1.ControlMessage {
s.mu.RLock()
f := s.agentSettings
s.mu.RUnlock()
if f == nil {
return nil
}
return &llmgwv1.ControlMessage{Msg: &llmgwv1.ControlMessage_AgentSettings{
AgentSettings: &llmgwv1.AgentSettings{Yaml: f(node)}}}
}
// agentSettingsGap is the pause between telling one node and the next: an
// agent whose settings changed starts again, and a whole cluster's agents
// doing so in the same second would all re-register at once.
var agentSettingsGap = time.Second
// BroadcastAgentSettings tells every connected agent what the cluster's
// settings now say it runs on, a moment apart. A node not connected is told
// when it registers.
func (s *Service) BroadcastAgentSettings() {
for _, node := range s.ConnectedNodes() {
msg := s.agentSettingsMsg(node)
if msg == nil {
return
}
if err := s.send(node, msg); err != nil {
s.log.Warn("could not tell a node its agent settings; it is told when it next registers",
"node", node, "err", err)
continue
}
time.Sleep(agentSettingsGap)
}
}