Skip to content

fix(discord): stop phantom typing indicator after agent turn completes#3003

Merged
teknium1 merged 1 commit intomainfrom
hermes/hermes-7d7ac769
Mar 25, 2026
Merged

fix(discord): stop phantom typing indicator after agent turn completes#3003
teknium1 merged 1 commit intomainfrom
hermes/hermes-7d7ac769

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

Summary

Discord's typing indicator lingers indefinitely after the agent finishes because of a race between two typing systems:

  1. _keep_typing (base.py) pings Discord every 2s
  2. _typing_tasks (Discord adapter) tracks persistent typing loops

The race: stop_typing() clears the task dict, but _keep_typing wakes from its 2s sleep and calls send_typing() again — recreating the loop. When _keep_typing is then cancelled, the newly created task is orphaned with no cleanup path.

Fix

Two layers:

  1. Root cause (_keep_typing finally block): when _keep_typing exits for any reason, it calls stop_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.

  2. Safety net (_process_message_background finally block): after cancelling the typing task wrapper, also call stop_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

  • 1429 gateway tests pass
  • Both fixes are idempotent (stop_typing when already stopped is a no-op)
  • hasattr guard ensures no impact on platforms without stop_typing
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).
@teknium1 teknium1 merged commit 65dace1 into main Mar 25, 2026
1 of 2 checks passed
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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant