From 81c86456af960bb4dec480343bfe1ebf2cd81459 Mon Sep 17 00:00:00 2001 From: EloquentBrush <147827411+EloquentBrush@users.noreply.github.com> Date: Sun, 10 May 2026 22:46:43 +0300 Subject: [PATCH] fix(yuanbao): evict stale entries from _member_cache on TTL expiry _build_msg_body_with_mentions() checks the TTL of each _member_cache entry and returns an empty member list when the entry is stale, but never removes the entry from the dict. Over time every group_code the bot has ever queried accumulates a permanent entry, retaining the full member list (potentially thousands of records per group) until disconnect(). Fix: delete the stale entry at the point it is detected as expired. The next call to get_group_member_list_raw() for the same group will repopulate the cache with fresh data as before. Symmetric with the existing TTL pattern in MessageDeduplicator, which evicts on access. --- gateway/platforms/yuanbao.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gateway/platforms/yuanbao.py b/gateway/platforms/yuanbao.py index 118224fa08..bec2976b1e 100644 --- a/gateway/platforms/yuanbao.py +++ b/gateway/platforms/yuanbao.py @@ -4588,7 +4588,11 @@ class MessageSender: cached = self._adapter._member_cache.get(group_code) if cached: ts, member_list = cached - members = member_list if (time.time() - ts < self._adapter.MEMBER_CACHE_TTL_S) else [] + if time.time() - ts < self._adapter.MEMBER_CACHE_TTL_S: + members = member_list + else: + del self._adapter._member_cache[group_code] + members = [] else: members = [] if not members: