From e021934e68bbd2583965365a4dbd8564b22080cd Mon Sep 17 00:00:00 2001 From: viettranx Date: Sun, 12 Apr 2026 15:13:53 +0700 Subject: [PATCH] fix(vault): wire provider hot-reload to config.patch event The previous commit only listened to TopicSystemConfigChanged (periodic DB refresh), but config.patch from UI fires TopicConfigChanged. Add subscriber in gateway_lifecycle so vault enrichment picks up provider/ model changes immediately when user saves config. --- cmd/gateway_lifecycle.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cmd/gateway_lifecycle.go b/cmd/gateway_lifecycle.go index 27f990d8..8d1a4b40 100644 --- a/cmd/gateway_lifecycle.go +++ b/cmd/gateway_lifecycle.go @@ -106,6 +106,22 @@ func (d *gatewayDeps) runLifecycle( slog.Info("tts config reloaded", "provider", newMgr.PrimaryProvider(), "auto", string(newMgr.AutoMode())) }) + // Hot-swap vault enrichment provider/model on config changes via pub/sub. + if d.updateVaultProvider != nil { + d.msgBus.Subscribe("vault-enrich-config-reload", func(evt bus.Event) { + if evt.Name != bus.TopicConfigChanged { + return + } + updatedCfg, ok := evt.Payload.(*config.Config) + if !ok { + return + } + if p, m := resolveBackgroundProvider(updatedCfg, d.providerRegistry); p != nil { + d.updateVaultProvider(p, m) + } + }) + } + // Log orphaned providers on agent deletion. Auto-delete is unsafe because // providers can be referenced by heartbeats (FK), OAuth tokens, media chains. d.msgBus.Subscribe("agent-deleted-provider-log", func(evt bus.Event) {