Skip to content

The agent that grows with you

fix(gateway): voice turns drop the bound /voice join message id

teknium133599cf4c0b4
diff --git a/gateway/run_voice.py b/gateway/run_voice.py
index db11a1ee114..5d6fd672dbe 100644
--- a/gateway/run_voice.py
+++ b/gateway/run_voice.py
@@ -255,6 +255,9 @@ class GatewayVoiceMixin:
if user_name is None and source.user_id == str(user_id):
user_name = source.user_name
source.user_id, source.user_name = str(user_id), user_name or str(user_id)
+ # The bound source is the `/voice join` message's; its id is not this turn's trigger
+ # (run.py exports it as HERMES_SESSION_MESSAGE_ID for reply anchoring).
+ source.message_id = None
else:
source = SessionSource(
platform=Platform.DISCORD, chat_id=str(text_ch_id), user_id=str(user_id),
diff --git a/tests/gateway/test_discord_turn_prompt_parity.py b/tests/gateway/test_discord_turn_prompt_parity.py
index 342ea16ba3b..f58a4fe3bac 100644
--- a/tests/gateway/test_discord_turn_prompt_parity.py
+++ b/tests/gateway/test_discord_turn_prompt_parity.py
@@ -129,7 +129,9 @@ async def test_voice_channel_turn_matches_a_typed_turn(monkeypatch: pytest.Monke
SimpleNamespace(channel=channel, channel_id=channel.id, guild=parent.guild, guild_id=1, user=_USER),
"/voice join")
adapter._voice_text_channels = {1: channel.id}
- adapter._voice_sources = {1: join.source.to_dict()}
+ # A typed `/voice join` binds that message's source, id included; a voice turn must not inherit it
+ # as its own trigger.
+ adapter._voice_sources = {1: {**join.source.to_dict(), "message_id": "1554000000000000000"}}
adapter._client.get_channel = {channel.id: channel}.get
if case == "renamed-after-join":
channel.name, channel.topic = "renamed", "New topic"
@@ -148,6 +150,7 @@ async def test_voice_channel_turn_matches_a_typed_turn(monkeypatch: pytest.Monke
spoken = adapter.handle_message.await_args.args[0]
assert spoken is not typed
_assert_same_prompt_inputs(typed, spoken)
+ assert spoken.source.message_id is None
# The join-time name belongs to the joiner only; another uncached speaker never borrows it.
other = runner._voice_input_source(adapter, 1, 43, channel.id).user_name
assert other == ("43" if case == "speaker-uncached" else "Alice")