You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Stops gateway typing indicators immediately after the user-visible response is delivered, before post-delivery hooks and debounce cleanup continue running.
On Discord, the platform adapter keeps a persistent typing task that refreshes the typing endpoint every 12 seconds. The agent path already calls stop_typing() when the model result is ready, but the base adapter's generic _keep_typing() task can still recreate the platform typing loop while the final response is being sent and while post-delivery hooks run. That leaves the user seeing a completed reply while Hermes still appears to be typing.
This change cancels the generic typing task and calls the platform stop_typing() hook immediately after delivery. The existing final cleanup remains in place as a safety net for empty-response, error, cancellation, and late cleanup paths.
Existing related PRs reviewed before opening this:
N/A - found from local Windows Discord gateway repro.
Type of Change
Bug fix (non-breaking change that fixes an issue)
New feature (non-breaking change that adds functionality)
Security fix
Documentation update
Tests (adding or improving test coverage)
Refactor (no behavior change)
New skill (bundled or hub)
Changes Made
gateway/platforms/base.py: stop the generic typing task and the platform typing loop immediately after user-visible delivery, before on_processing_complete hooks and debounce cleanup.
tests/gateway/test_base_topic_sessions.py: add a regression test proving typing is stopped before the processing-complete hook observes the completed turn.
How to Test
Run scripts/run_tests.sh -j 4 tests/gateway/test_base_topic_sessions.py.
Run a Discord gateway session.
Send a message that takes long enough to show the Discord typing indicator, then confirm the indicator does not keep refreshing after the reply is visible.
The change correctly moves stop_typing / _stop_typing_task to execute before the _run_processing_hook call, so Discord and other platforms stop showing "typing…" as soon as the response is delivered. The hasattr guard handles adapters without a stop_typing method gracefully.
Test test_process_message_background_stops_typing_before_complete_hook verifies the ordering constraint: typing-cancelled and stop-typing both appear before complete in the event sequence. Clean test design with explicit ordering assertions.
Thanks for this, and for the careful write-up linking the related PRs.
The post-delivery typing-stop fix has landed on main via #37556 (merged as 6a30cfca8), so I'm closing this as superseded.
For the record on the difference: this PR placed the early _stop_typing_task() inside the try block, ahead of the on_processing_complete hook. Because _stop_typing_task swallows CancelledError, a cancellation landing in that post-delivery window gets eaten and the turn is reported SUCCESS instead of CANCELLED (verified with a control-flow repro: pre-PR CANCELLED, post-PR mislabeled SUCCESS). On Telegram that leaves the in-progress reaction stuck, since it's only cleared on CANCELLED. #37556 avoids this by placing the stop at the top of finally, after the outcome is already decided, and additionally moves the stop ahead of the post-delivery callback plus bounds that callback with a timeout — which also closes the root-cause issue #24971.
Appreciate the contribution — the diagnosis here was sound, it was just the placement that mattered.
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
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?
Stops gateway typing indicators immediately after the user-visible response is delivered, before post-delivery hooks and debounce cleanup continue running.
On Discord, the platform adapter keeps a persistent typing task that refreshes the typing endpoint every 12 seconds. The agent path already calls
stop_typing()when the model result is ready, but the base adapter's generic_keep_typing()task can still recreate the platform typing loop while the final response is being sent and while post-delivery hooks run. That leaves the user seeing a completed reply while Hermes still appears to be typing.This change cancels the generic typing task and calls the platform
stop_typing()hook immediately after delivery. The existing final cleanup remains in place as a safety net for empty-response, error, cancellation, and late cleanup paths.Existing related PRs reviewed before opening this:
Related Issue
N/A - found from local Windows Discord gateway repro.
Type of Change
Changes Made
gateway/platforms/base.py: stop the generic typing task and the platform typing loop immediately after user-visible delivery, beforeon_processing_completehooks and debounce cleanup.tests/gateway/test_base_topic_sessions.py: add a regression test proving typing is stopped before the processing-complete hook observes the completed turn.How to Test
scripts/run_tests.sh -j 4 tests/gateway/test_base_topic_sessions.py.Focused local validation:
venv/Scripts/python.exe -m py_compile gateway/platforms/base.py tests/gateway/test_base_topic_sessions.pyscripts/run_tests.sh -j 4 tests/gateway/test_base_topic_sessions.py- 11 passedChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) - N/Acli-config.yaml.exampleif I added/changed config keys - N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows - N/AFor New Skills
N/A
Screenshots / Logs
Local Windows gateway log showed the user-visible Discord response sent before follow-on cron/background activity continued:
response ready: platform=discord ... time=319.6s[Discord] Sending response ...The patch moves typing cleanup to immediately after that delivery boundary so post-delivery work cannot keep the Discord typing loop alive.