Skip to content

fix(discord): voice inactivity timeout fires under /voice off, spamming the channel - #43328

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-a1866009
Jun 10, 2026
Merged

teknium1 merged 2 commits into
mainfrom
hermes/hermes-a1866009

Conversation

@teknium1

Copy link
Copy Markdown
Collaborator

Summary

Discord bot no longer auto-disconnects and spams "Left voice channel (inactivity timeout)." every 300s while in /voice off mode.

Root cause: the inactivity timer (VOICE_TIMEOUT) only resets on the bot's own audio playback. /voice off is deliberate text-only mode that keeps the bot in the channel (leaving is /voice leave), so nothing ever resets the timer and it fires every 300s — disconnecting and spamming the text channel on a loop.

Salvage of #43165 by @xxxigm (reported by PanBartosz), cherry-picked onto current main with authorship preserved.

Changes

  • plugins/platforms/discord/adapter.py: _voice_timeout_handler skips the auto-disconnect when the linked channel's voice-reply mode is off. Also resets the timer when a user speaks in _voice_listen_loop (sibling fix: an active listener was getting disconnected mid-conversation since only bot playback counted as activity).
  • gateway/run.py: wires the gateway's live _voice_mode state into the adapter via a _voice_mode_getter callback on voice-channel join.
  • tests/gateway/test_voice_command.py: 2 new tests — timeout skips disconnect under /voice off, still disconnects under an active mode.

Validation

Scenario Before After
/voice off, idle 5+ min disconnect + "inactivity timeout" spam, loops stays connected, silent
/voice all/voice_only, idle 5+ min disconnect disconnect (unchanged)
getter unset (defensive default) n/a disconnect (legacy behavior preserved)

tests/gateway/test_voice_command.py: 183/183 passing. E2E-verified the real _voice_timeout_handler skips disconnect under voice-off mode.

Closes #43165.

Infographic

voice-off-no-longer-leaves

xxxigm added 2 commits June 9, 2026 22:32
The voice inactivity timer (VOICE_TIMEOUT) only counted the bot's OWN audio
playback as activity. Under /voice off (text-only replies, but still in the
channel — leaving is /voice leave) nothing ever reset it, so every 300s the bot
disconnected and spammed "Left voice channel (inactivity timeout)."

The adapter now learns the live voice-reply mode via a getter wired from run.py
and skips the auto-disconnect while mode is off. It also resets the timer when a
user actually speaks to the bot, so an active listener (incl. voice-on
text-only sessions that never play audio) isn't dropped mid-conversation.
Assert the inactivity handler skips disconnect (and the channel spam) when the
voice-mode getter reports "off", and still disconnects on genuine inactivity
when the mode is active.
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-a1866009 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 10650 on HEAD, 10649 on base (🆕 +1)

🆕 New issues (1):

Rule Count
invalid-assignment 1
First entries
gateway/run.py:9373: [invalid-assignment] invalid-assignment: Object of type `(chat_id) -> str` is not assignable to attribute `_voice_mode_getter` on type `BasePlatformAdapter & <Protocol with members 'join_voice_channel'> & <Protocol with members '_voice_mode_getter'>`

✅ Fixed issues: none

Unchanged: 5579 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/plugins Plugin system and bundled plugins platform/discord Discord bot adapter labels Jun 10, 2026
@teknium1
teknium1 merged commit aea0b73 into main Jun 10, 2026
23 checks passed
@teknium1
teknium1 deleted the hermes/hermes-a1866009 branch June 10, 2026 06:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P2 Medium — degraded but workaround exists platform/discord Discord bot adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants