Skip to content

feat(discord): configure voice inactivity timeout - #60539

Closed
bmobytes wants to merge 2 commits into
NousResearch:mainfrom
bmobytes:feat/discord-voice-inactivity-timeout
Closed

bmobytes wants to merge 2 commits into
NousResearch:mainfrom
bmobytes:feat/discord-voice-inactivity-timeout

Conversation

@bmobytes

@bmobytes bmobytes commented Jul 7, 2026

Copy link
Copy Markdown

Summary

  • Add discord.voice_inactivity_timeout_seconds for Discord voice-channel auto-leave, preserving the historical 300s default and supporting 0 to disable auto-leave.
  • Suspend/cancel the inactivity timer while Discord voice playback or voice-input processing is active, then re-arm it afterward.
  • Document the new setting in the configuration reference and Discord guide.

Test Plan

  • uv run --with pytest --with pytest-asyncio --with pyyaml python -m pytest tests/gateway/test_config.py::TestLoadGatewayConfig::test_bridges_discord_voice_inactivity_timeout_from_config_yaml tests/gateway/test_voice_command.py::TestVoiceTimeoutCleansRunnerState -q -o 'addopts=' --tb=short (12 passed)
  • uv run --with pytest --with pytest-asyncio --with pyyaml python -m pytest tests/gateway/test_voice_command.py -q -o 'addopts=' --tb=short (171 passed, 21 skipped)
  • uv run --with pytest --with pytest-asyncio --with pyyaml python -m pytest tests/gateway/test_config.py -q -o 'addopts=' --tb=short (86 passed)
  • uv run --with pytest --with pytest-asyncio --with pyyaml python -m pytest tests/gateway/test_discord_voice_mixer.py -q -o 'addopts=' --tb=short (1 skipped; pytest exit 5 because the file contains only skipped tests in this environment)
  • python -m compileall -q plugins/platforms/discord/adapter.py gateway/config.py

Platforms Tested

  • Linux (targeted unit tests only; no live Discord gateway/service restart)

@alt-glitch alt-glitch added type/feature New feature or request platform/discord Discord bot adapter comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have duplicate This issue or pull request already exists labels Jul 7, 2026
@alt-glitch

Copy link
Copy Markdown
Contributor

This was generated by AI during triage.

Duplicate of #50533 — both add a configurable Discord voice inactivity timeout (with 0 to disable) in plugins/platforms/discord/adapter.py, implementing #17790. #50533 is the earlier open PR (2026-06-22) and additionally adds a duration-aware playback watchdog floor, so it is the canonical implementation. Related: #17790 (the feature request).

@bmobytes

bmobytes commented Jul 7, 2026

Copy link
Copy Markdown
Author

Closing as duplicate. Existing upstream PRs already cover this area; I am handling the local solution by pinning selected PRs on top of our hermes-stack instead.

@bmobytes bmobytes closed this Jul 7, 2026
@bmobytes bmobytes reopened this Jul 7, 2026

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing the configurable Discord voice timeout. The premise remains valid on current main: VOICE_TIMEOUT is still hardcoded at plugins/platforms/discord/adapter.py:816, and _voice_timeout_handler() sleeps on it at :3026.

Problems

  • plugins/platforms/discord/adapter.py:2961 cancels the existing inactivity task before mixer decode / legacy playback setup. Current main allows exceptions from those later operations (decode_to_pcm at :2946, FFmpegPCMAudio at :2988), but this change only re-arms on successful playback paths. An exception therefore leaves a connected guild with no inactivity task.

Suggested changes

  • Put the cancellation and playback body under try/finally; in the finally, re-arm only if the guild remains connected and the configured timeout is enabled.
  • Add a regression test for a decoder or FFmpeg setup exception after cancellation.

Automated hermes-sweeper review.

vc = self._voice_clients.get(guild_id)
if not vc or not vc.is_connected():
return False
self._cancel_voice_timeout(guild_id)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please re-arm the timer in a finally around the remaining playback attempt. decode_to_pcm, FFmpegPCMAudio, or vc.play can raise after this cancellation; the current success-only resets then leave a connected guild with no inactivity timer.

@teknium1 teknium1 added sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 15, 2026
@teknium1

Copy link
Copy Markdown
Collaborator

The configurable voice timeouts landed in #73517 via @namredips's #50533 (this was already labeled duplicate). Thanks for the contribution!

(Landed via #73517, merge b8c38a451a.) Closing.

@teknium1 teknium1 closed this Jul 29, 2026
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 duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have platform/discord Discord bot adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants