diff --git a/sdk/cliproxy/service.go b/sdk/cliproxy/service.go index 720ec13b2..6f2d99673 100644 --- a/sdk/cliproxy/service.go +++ b/sdk/cliproxy/service.go @@ -852,6 +852,24 @@ func (s *Service) hasNativeOpenAICompatExecutorConfig(a *coreauth.Auth, provider return false } +func (s *Service) unregisterOpenAICompatExecutor(providerKey string) { + if s == nil || s.coreManager == nil { + return + } + providerKey = strings.ToLower(strings.TrimSpace(providerKey)) + if providerKey == "" { + return + } + existing, okExecutor := s.coreManager.Executor(providerKey) + if !okExecutor || existing == nil { + return + } + if _, okOpenAICompat := existing.(*executor.OpenAICompatExecutor); !okOpenAICompat { + return + } + s.coreManager.UnregisterExecutor(providerKey) +} + func (s *Service) ensureExecutorsForAuth(a *coreauth.Auth) { s.ensureExecutorsForAuthWithMode(a, false) } @@ -984,6 +1002,7 @@ func (s *Service) registerExecutorForAuth(a *coreauth.Auth, forceReplace bool) { if s.pluginHost != nil && s.pluginHost.HasExecutorCandidateProvider(providerKey) && !s.hasNativeOpenAICompatExecutorConfig(a, providerKey) { + s.unregisterOpenAICompatExecutor(providerKey) return } s.coreManager.RegisterExecutor(executor.NewOpenAICompatExecutor(providerKey, s.cfg)) @@ -1223,6 +1242,8 @@ func (s *Service) applyConfigUpdateWithAuthSynthesis(newCfg *config.Config, synt s.coreManager.SetConfig(newCfg) s.coreManager.SetOAuthModelAlias(newCfg.OAuthModelAlias) } + ctx := coreauth.WithSkipPersist(context.Background()) + s.syncPluginRuntimeConfig(ctx) var auths []*coreauth.Auth if s.coreManager != nil { auths = s.coreManager.List() @@ -1232,7 +1253,6 @@ func (s *Service) applyConfigUpdateWithAuthSynthesis(newCfg *config.Config, synt forceReplaceAuths: true, auths: auths, }) - ctx := coreauth.WithSkipPersist(context.Background()) if synthesizeConfigAuths { s.registerConfigAPIKeyAuths(ctx, newCfg) } @@ -1241,7 +1261,7 @@ func (s *Service) applyConfigUpdateWithAuthSynthesis(newCfg *config.Config, synt log.Warnf("failed to restore cooldown state after config update: %v", errRestoreCooldown) } } - s.syncPluginRuntime(ctx) + s.syncPluginModelRuntime(ctx) } func (s *Service) reloadConfigFromWatcher() bool {