From 9a81fa5e844c92c2430a927c100b3c4742280232 Mon Sep 17 00:00:00 2001 From: shinchan-zhai Date: Mon, 23 Mar 2026 09:54:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20news=20seen=20map=20eviction=20strategy?= =?UTF-8?q?=20=E2=80=94=20keep=20half=20instead=20of=20clearing=20all?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously when the seen map exceeded 1000 entries, ALL entries were deleted, losing dedup state and causing re-notifications. Now evicts ~half the entries, preserving recent URLs for dedup continuity. --- agent/brain.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/agent/brain.go b/agent/brain.go index 373da3c7..fd5fd70c 100644 --- a/agent/brain.go +++ b/agent/brain.go @@ -105,7 +105,15 @@ func (b *Brain) scanNews(seen map[string]bool) { emoji, d.Title, d.Source, sentiment)) } - if len(seen) > 1000 { for k := range seen { delete(seen, k) } } + // Evict ~half when seen map gets large (keep recent half to avoid re-notifying) + if len(seen) > 1000 { + i, half := 0, len(seen)/2 + for k := range seen { + if i >= half { break } + delete(seen, k) + i++ + } + } } func (b *Brain) StartMarketBriefs(hours []int) {