fix(channels): add periodic sweep for pending message compaction

Auto-compaction stopped working after server restarts because provider
resolution failure was silent and there was no retry mechanism. Add a
10-minute periodic sweep in the flusher loop that checks DB for groups
exceeding the compaction threshold, and warn when compaction provider
cannot be resolved at startup.
This commit is contained in:
viettranx committed 2026-03-23 15:45:35 +07:00
1 parent ed840dd6d7
commit 9aaec59527
4 files changed
+50 -2

No files matched your search

+10
View File
@@ -282,6 +282,16 @@ func (l *InstanceLoader) loadInstance(ctx context.Context, inst store.ChannelIns
pc.SetPendingCompaction(cc)
slog.Debug("pending compaction configured", "channel", inst.Name, "provider", p.Name(), "model", model,
"threshold", cc.Threshold, "keep_recent", cc.KeepRecent, "max_tokens", cc.MaxTokens)
} else {
attemptedProvider := ""
if l.pendingCompactCfg != nil {
attemptedProvider = l.pendingCompactCfg.Provider
}
if attemptedProvider == "" && ag != nil {
attemptedProvider = ag.Provider
}
slog.Warn("pending compaction not configured: provider/model unavailable",
"channel", inst.Name, "agent_id", inst.AgentID, "attempted_provider", attemptedProvider)
}
}
l.manager.RegisterChannel(inst.Name, ch)