refactor(matrix): remove delayed reaction redaction scheduling - #22090
Closed
Phoenix1819 wants to merge 1 commit into
Closed
refactor(matrix): remove delayed reaction redaction scheduling#22090Phoenix1819 wants to merge 1 commit into
Phoenix1819 wants to merge 1 commit into
Conversation
Reactions are now redacted immediately instead of after a 5-second async delay. The old logic scheduled a background task that slept before calling _redact_reaction(), which added complexity: - A Set[asyncio.Task] to track pending redactions - Cancellation logic in disconnect() - A non-configurable 5-second delay constant - Risk of task leaks if disconnect raced with the scheduler The delay was originally added to avoid "missing event" errors in some Matrix clients, but in practice the issue is homeserver-specific and better handled by the server-side event ordering. Immediate redaction is simpler, more predictable, and avoids stale reactions lingering when the bot is under load. Changes: - Removed _schedule_reaction_redaction() method - Removed _reaction_redaction_delay_seconds and _reaction_redaction_tasks - Removed task-cancellation cleanup in disconnect() - on_processing_complete() now calls _redact_reaction() directly - _redact_bot_approval_reactions() now calls redact_message() directly All call sites handle failure gracefully with logger.debug.
Phoenix1819
pushed a commit
to Phoenix1819/hermes-agent
that referenced
this pull request
May 10, 2026
…d tasks Reaction redactions previously slept for 5 seconds before executing. This blocked the processing loop unnecessarily. Now they fire immediately as background tasks, with proper cleanup on disconnect. Closes NousResearch#22090
Author
|
Withdrawing — the 5-second delay was a workaround for a real race condition. Removing it without data that the underlying issue is resolved is a behavioral change, not a clear improvement. |
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.
Summary
This PR removes the delayed async reaction redaction logic from the Matrix gateway and replaces it with immediate redaction.
Problem
The Matrix adapter scheduled a background
asyncio.Taskfor every reaction redaction, sleeping for 5 seconds first. This was intended to give homeservers time to deliver the final message event before the reaction disappeared, avoiding "missing event" errors in some clients.In practice, the delay caused several issues:
Solution
Redact reactions immediately via direct
await:on_processing_complete()→_redact_reaction()directly_redact_bot_approval_reactions()→redact_message()directlyBoth call sites log at
debuglevel on failure, so errors are visible but non-fatal.Removed
_schedule_reaction_redaction()method_reaction_redaction_delay_secondsconstant_reaction_redaction_tasks: Set[asyncio.Task]disconnect()Backwards Compatibility
Testing