fix(discord): stop phantom typing indicator after agent turn completes#3003
Merged
fix(discord): stop phantom typing indicator after agent turn completes#3003
Conversation
Two fixes for a race where Discord's typing indicator lingers after the agent finishes: 1. _keep_typing (root cause): after outer stop_typing() clears the task dict, _keep_typing wakes from its 2s sleep and calls send_typing() again, recreating an orphaned loop. Add a finally block so _keep_typing always calls stop_typing() on exit, cleaning up any loop it recreated. 2. _process_message_background (safety net): add stop_typing() after cancelling the typing task, catching any platform-level persistent typing tasks that slipped through. Combines fixes from PR #2945 by catbusconductor (root cause in _keep_typing) and PR #2832 by subrih (safety net in _process_message_background).
This was referenced Mar 25, 2026
InB4DevOps
pushed a commit
to InB4DevOps/hermes-agent
that referenced
this pull request
Mar 25, 2026
NousResearch#3003) Two fixes for a race where Discord's typing indicator lingers after the agent finishes: 1. _keep_typing (root cause): after outer stop_typing() clears the task dict, _keep_typing wakes from its 2s sleep and calls send_typing() again, recreating an orphaned loop. Add a finally block so _keep_typing always calls stop_typing() on exit, cleaning up any loop it recreated. 2. _process_message_background (safety net): add stop_typing() after cancelling the typing task, catching any platform-level persistent typing tasks that slipped through. Combines fixes from PR NousResearch#2945 by catbusconductor (root cause in _keep_typing) and PR NousResearch#2832 by subrih (safety net in _process_message_background).
outsourc-e
pushed a commit
to outsourc-e/hermes-agent
that referenced
this pull request
Mar 26, 2026
NousResearch#3003) Two fixes for a race where Discord's typing indicator lingers after the agent finishes: 1. _keep_typing (root cause): after outer stop_typing() clears the task dict, _keep_typing wakes from its 2s sleep and calls send_typing() again, recreating an orphaned loop. Add a finally block so _keep_typing always calls stop_typing() on exit, cleaning up any loop it recreated. 2. _process_message_background (safety net): add stop_typing() after cancelling the typing task, catching any platform-level persistent typing tasks that slipped through. Combines fixes from PR NousResearch#2945 by catbusconductor (root cause in _keep_typing) and PR NousResearch#2832 by subrih (safety net in _process_message_background).
StreamOfRon
pushed a commit
to StreamOfRon/hermes-agent
that referenced
this pull request
Mar 29, 2026
NousResearch#3003) Two fixes for a race where Discord's typing indicator lingers after the agent finishes: 1. _keep_typing (root cause): after outer stop_typing() clears the task dict, _keep_typing wakes from its 2s sleep and calls send_typing() again, recreating an orphaned loop. Add a finally block so _keep_typing always calls stop_typing() on exit, cleaning up any loop it recreated. 2. _process_message_background (safety net): add stop_typing() after cancelling the typing task, catching any platform-level persistent typing tasks that slipped through. Combines fixes from PR NousResearch#2945 by catbusconductor (root cause in _keep_typing) and PR NousResearch#2832 by subrih (safety net in _process_message_background).
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
Discord's typing indicator lingers indefinitely after the agent finishes because of a race between two typing systems:
_keep_typing(base.py) pings Discord every 2s_typing_tasks(Discord adapter) tracks persistent typing loopsThe race:
stop_typing()clears the task dict, but_keep_typingwakes from its 2s sleep and callssend_typing()again — recreating the loop. When_keep_typingis then cancelled, the newly created task is orphaned with no cleanup path.Fix
Two layers:
Root cause (
_keep_typingfinally block): when_keep_typingexits for any reason, it callsstop_typing()to clean up any loop it recreated after the last outer cleanup. From PR fix(discord): stop phantom typing indicator after agent turn completes #2945 by @catbusconductor.Safety net (
_process_message_backgroundfinally block): after cancelling the typing task wrapper, also callstop_typing()to catch any platform-level persistent tasks. From PR fix(discord): cancel platform-level typing tasks in base.py finally block #2832 by @subrih.Test plan
stop_typingwhen already stopped is a no-op)hasattrguard ensures no impact on platforms withoutstop_typing