fix(yuanbao): clear _processing_msg_ids/_processing_msg_texts after each message
_dispatch_inbound_event() writes session_key → msg_id/raw_text into _processing_msg_ids and _processing_msg_texts so RecallGuardMiddleware can find and interrupt the currently-processing message. These entries were never removed after a message finished processing, causing both dicts to grow unboundedly — one persistent entry per unique session key for the lifetime of the bot. Fix: clear both entries in the _process_message_background() finally block, after super() returns. The guard compares the stored msg_id against event.message_id before popping: a concurrent pending message may have already overwritten the entry in _dispatch_inbound_event while we were running, in which case the drain task owns it and we must not clear it. When msg_id is absent (nothing was written at dispatch time) the pop is a safe no-op. Note: _msg_content_cache already bounds itself to 200 entries at the same write site; _processing_msg_ids and _processing_msg_texts had no such bound.
This commit is contained in:
@@ -5116,6 +5116,15 @@ class YuanbaoAdapter(BasePlatformAdapter):
|
||||
await super()._process_message_background(event, session_key)
|
||||
finally:
|
||||
self._outbound.cancel_slow_notifier(chat_id)
|
||||
# Clear the RecallGuard tracking entries for this message only if
|
||||
# our msg_id is still current. A concurrent pending message may
|
||||
# have already overwritten the entry in _dispatch_inbound_event
|
||||
# while we were running; in that case the drain task owns it and
|
||||
# we must not clear it.
|
||||
msg_id = event.message_id
|
||||
if not msg_id or self._processing_msg_ids.get(session_key) == msg_id:
|
||||
self._processing_msg_ids.pop(session_key, None)
|
||||
self._processing_msg_texts.pop(session_key, None)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Group query (delegate to GroupQueryService)
|
||||
|
||||
Reference in New Issue
Block a user