From 8510fc313ec0144249dea977ed1a3026ed673192 Mon Sep 17 00:00:00 2001 From: hkfires <10558748+hkfires@users.noreply.github.com> Date: Thu, 29 Jan 2026 09:28:49 +0800 Subject: [PATCH] fix(api): update amp module only on config changes --- internal/api/server.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/internal/api/server.go b/internal/api/server.go index c7505dc2e..e0c92b3e1 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -12,6 +12,7 @@ import ( "net/http" "os" "path/filepath" + "reflect" "strings" "sync" "sync/atomic" @@ -990,14 +991,17 @@ func (s *Server) UpdateClients(cfg *config.Config) { s.mgmt.SetAuthManager(s.handlers.AuthManager) } - // Notify Amp module of config changes (for model mapping hot-reload) - if s.ampModule != nil { - log.Debugf("triggering amp module config update") - if err := s.ampModule.OnConfigUpdated(cfg); err != nil { - log.Errorf("failed to update Amp module config: %v", err) + // Notify Amp module only when Amp config has changed. + ampConfigChanged := oldCfg == nil || !reflect.DeepEqual(oldCfg.AmpCode, cfg.AmpCode) + if ampConfigChanged { + if s.ampModule != nil { + log.Debugf("triggering amp module config update") + if err := s.ampModule.OnConfigUpdated(cfg); err != nil { + log.Errorf("failed to update Amp module config: %v", err) + } + } else { + log.Warnf("amp module is nil, skipping config update") } - } else { - log.Warnf("amp module is nil, skipping config update") } // Count client sources from configuration and auth store.