fix(honcho plugin): gateway-restart dedup prevents duplicate messages#17153
Closed
kaishi00 wants to merge 1 commit into
Closed
fix(honcho plugin): gateway-restart dedup prevents duplicate messages#17153kaishi00 wants to merge 1 commit into
kaishi00 wants to merge 1 commit into
Conversation
Prevents duplicate messages when the Hermes gateway restarts and replays the current turn to sync_turn(). After restart, the in-memory session cache is empty and get_or_create() reloads existing Honcho messages as synced, but the gateway may still feed the same turn data, creating unsynced copies of messages that Honcho already has. Fix: before calling add_messages(), query last 100 existing Honcho messages, build MD5 content hashes (peer_id + content), skip any new message whose hash matches. Best-effort: if context() query fails, sends all messages without dedup (no data loss risk). Also swaps peer_name priority: config.peerName wins over runtime user_id for single-user setups where configured identity should always be used.
Collaborator
Contributor
|
Closing as superseded. The peer-name priority swap (config.peer_name > runtime user_id) is already available on current main as an opt-in via The gateway-restart dedup is an interesting idea but has a few issues worth sorting out before landing:
Happy to revisit the dedup approach separately if you have evidence the duplicate-message issue is still happening on current main with |
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.
Problem
When the Hermes gateway restarts mid-conversation, the Honcho plugin replays the current turn's messages to Honcho — creating duplicate entries for messages that were already synced before the restart.
Root cause:
HonchoSessionManageruses an in-memory_cache(dict) that is lost on restart. After restart:get_or_create()loads existing Honcho messages → marks them_synced: Truesync_turn()again_flush_session()sends them all to Honcho → duplicatesFix
Added content-hash dedup to
_flush_session()inplugins/memory/honcho/session.py:honcho_session.add_messages(), query the last 100 existing Honcho messagespeer_id + contentfor each"Honcho dedup: skipped N duplicate(s) (gateway restart protection)"context()query fails, send all messages (no data loss risk)Bonus: Peer name priority swap
Also fixed
get_or_create()soconfig.peerNametakes priority over runtimeuser_id. For single-user setups (private Discord DMs), the configured peer identity should always win over derived Discord numeric IDs.Changes
plugins/memory/honcho/session.py_flush_session()+ peer priority swap inget_or_create()Testing