Skip to content

fix: keep typing indicator alive during long inference#25886

Closed
stakeswky wants to merge 1 commit intoopenclaw:mainfrom
stakeswky:fix/25882
Closed

fix: keep typing indicator alive during long inference#25886
stakeswky wants to merge 1 commit intoopenclaw:mainfrom
stakeswky:fix/25882

Conversation

@stakeswky
Copy link

@stakeswky stakeswky commented Feb 24, 2026

Closes #25882

Problem

Typing indicators can expire during long LLM inference. Some channels (for example Matrix) rely on a server-side typing TTL, so a single typing event at reply start disappears before the model finishes.

Root Cause

createTypingCallbacks only sent typing on reply start and did not refresh it while inference was still running. Once the platform TTL elapsed, the indicator dropped even though processing continued.

Fix

  • Add a keepalive loop in createTypingCallbacks (default 3s) that re-sends typing until cleanup
  • Unify onIdle / onCleanup cleanup to stop the keepalive timer and optionally send stop
  • Deduplicate stop calls across idle + cleanup and avoid overlapping keepalive start() calls
  • Keep the change in the shared channel typing helper so channel integrations inherit the fix without per-plugin changes

Testing

  • pnpm exec vitest run --config vitest.unit.config.ts src/channels/channel-helpers.test.ts --maxWorkers=1
  • Added fake-timer coverage for keepalive refresh and cleanup timer clearing
  • pnpm test:fast -- src/channels/channel-helpers.test.ts was also attempted, but this script runs the full unit suite in this repo and hit unrelated existing failures (e.g. src/telegram/bot.media.downloads-media-file-path-no-file-download.test.ts, src/plugins/discovery.test.ts)

Greptile Summary

Adds a keepalive mechanism to typing indicators so they remain visible during long LLM inference operations. Previously, typing indicators expired when platform TTLs elapsed, especially on channels like Matrix. The fix introduces a 3-second refresh loop that re-sends typing events until cleanup, along with deduplication logic to prevent multiple stop calls.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation is clean, well-tested, and solves a real UX issue. The keepalive logic correctly prevents overlapping calls with the keepaliveStartInFlight flag, properly clears timers on cleanup, and deduplicates stop calls with the stopSent flag. Test coverage is comprehensive, including fake timer tests for the keepalive mechanism and deduplication edge cases.
  • No files require special attention

Last reviewed commit: 03db125

steipete added a commit that referenced this pull request Feb 25, 2026
…stakeswky)

Co-authored-by: stakeswky <stakeswky@users.noreply.github.com>
@steipete
Copy link
Contributor

Implemented and landed on main as e0201c277.

What I changed (reimplemented after code review):

  • Added keepalive refresh support to createTypingCallbacks (src/channels/typing.ts) so typing can be re-sent during long inference windows.
  • Added regression tests in src/channels/channel-helpers.test.ts for keepalive refresh behavior and idle/cleanup stop deduplication.
  • Wired onIdle/onCleanup through core and extension dispatcher callsites using createTypingCallbacks (Telegram, Signal, Slack, Discord, Matrix, Mattermost, MS Teams) so keepalive timers are always cleared.

Validation:

  • pnpm lint
  • pnpm build
  • pnpm test

Thanks for the report and PR, @stakeswky.

@steipete steipete closed this Feb 25, 2026
joshavant pushed a commit that referenced this pull request Feb 25, 2026
…stakeswky)

Co-authored-by: stakeswky <stakeswky@users.noreply.github.com>
margulans pushed a commit to margulans/Neiron-AI-assistant that referenced this pull request Feb 25, 2026
… thanks @stakeswky)

Co-authored-by: stakeswky <stakeswky@users.noreply.github.com>
Jackson3195 pushed a commit to Jackson3195/openclaw-with-a-personal-touch that referenced this pull request Feb 25, 2026
… thanks @stakeswky)

Co-authored-by: stakeswky <stakeswky@users.noreply.github.com>
brianleach pushed a commit to brianleach/openclaw that referenced this pull request Feb 26, 2026
… thanks @stakeswky)

Co-authored-by: stakeswky <stakeswky@users.noreply.github.com>
execute008 pushed a commit to execute008/openclaw that referenced this pull request Feb 27, 2026
… thanks @stakeswky)

Co-authored-by: stakeswky <stakeswky@users.noreply.github.com>
r4jiv007 pushed a commit to r4jiv007/openclaw that referenced this pull request Feb 28, 2026
… thanks @stakeswky)

Co-authored-by: stakeswky <stakeswky@users.noreply.github.com>
hughdidit pushed a commit to hughdidit/DAISy-Agency that referenced this pull request Mar 1, 2026
… thanks @stakeswky)

Co-authored-by: stakeswky <stakeswky@users.noreply.github.com>
(cherry picked from commit e0201c2)

# Conflicts:
#	src/channels/channel-helpers.test.ts
#	src/discord/monitor/message-handler.process.ts
#	src/telegram/bot-message-dispatch.ts
hughdidit pushed a commit to hughdidit/DAISy-Agency that referenced this pull request Mar 3, 2026
… thanks @stakeswky)

Co-authored-by: stakeswky <stakeswky@users.noreply.github.com>
(cherry picked from commit e0201c2)

# Conflicts:
#	src/channels/channel-helpers.test.ts
#	src/discord/monitor/message-handler.process.ts
#	src/telegram/bot-message-dispatch.ts
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
… thanks @stakeswky)

Co-authored-by: stakeswky <stakeswky@users.noreply.github.com>
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
… thanks @stakeswky)

Co-authored-by: stakeswky <stakeswky@users.noreply.github.com>
thebenjaminlee pushed a commit to escape-velocity-ventures/openclaw that referenced this pull request Mar 7, 2026
… thanks @stakeswky)

Co-authored-by: stakeswky <stakeswky@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Typing indicator expires during long LLM inference – no keepalive in createTypingCallbacks

2 participants