fix(gateway): deduplicate Weixin messages by content fingerprint - #16190
Closed
PratikRai0101 wants to merge 1 commit into
Closed
fix(gateway): deduplicate Weixin messages by content fingerprint#16190PratikRai0101 wants to merge 1 commit into
PratikRai0101 wants to merge 1 commit into
Conversation
3 tasks
Contributor
|
Salvaged via #19742 onto current main. Test-file conflict resolved by preserving both the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR resolves an issue where the Weixin (ilinkai) adapter would occasionally deliver the same logical message twice within a short window (~3 seconds). Because the upstream API assigns unique
message_idvalues to these duplicate deliveries, they bypassed the existing ID-based deduplicator, causing the agent to respond twice to the same user query.The fix implements a secondary deduplication layer in the Weixin adapter that fingerprints messages based on a hash of the
sender_idand thetextcontent. This ensures that identical text from the same sender within the deduplicator's 5-minute TTL window is only processed once.Related Issue
Fixes #16182
Type of Change
Changes Made
gateway/platforms/weixin.py: Updated_process_messageto calculate an MD5 content fingerprint (content:{sender_id}:{text_hash}) for messages containing text. If this fingerprint is already present in the deduplicator, the message is dropped early.tests/gateway/test_weixin.py: Added a newTestWeixinContentDedupclass with regression tests to verify:How to Test
[Weixin] Content-dedup: skipping duplicate message from ...appears if the upstream API sends a redundant poll response.Checklist
Code
pytest tests/ -qand all relevant tests passDocumentation & Housekeeping
cli-config.yaml.example— N/ACONTRIBUTING.mdorAGENTS.md— N/AScreenshots / Logs
Test Execution Output: