diff --git a/internal/api/server.go b/internal/api/server.go index c7505dc2..e0c92b3e 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. diff --git a/internal/config/config.go b/internal/config/config.go index 839b7b05..5fd48408 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -923,6 +923,7 @@ func SaveConfigPreserveComments(configFile string, cfg *Config) error { removeLegacyGenerativeLanguageKeys(original.Content[0]) pruneMappingToGeneratedKeys(original.Content[0], generated.Content[0], "oauth-excluded-models") + pruneMappingToGeneratedKeys(original.Content[0], generated.Content[0], "oauth-model-alias") // Merge generated into original in-place, preserving comments/order of existing nodes. mergeMappingPreserve(original.Content[0], generated.Content[0])