diff --git a/gateway/platforms/discord.py b/gateway/platforms/discord.py index da56a61af0..bf48fc7d13 100644 --- a/gateway/platforms/discord.py +++ b/gateway/platforms/discord.py @@ -2122,14 +2122,11 @@ class DiscordAdapter(BasePlatformAdapter): prompts = self.config.extra.get("channel_prompts") or {} if not isinstance(prompts, dict): return None - prompts = {str(k): v for k, v in prompts.items()} for key in (channel_id, parent_id): if not key: continue prompt = prompts.get(key) - if prompt is None: - prompt = prompts.get(str(key)) if prompt is None: continue prompt = str(prompt).strip() diff --git a/gateway/run.py b/gateway/run.py index 1c74b03ca3..a95ca159b6 100644 --- a/gateway/run.py +++ b/gateway/run.py @@ -2891,7 +2891,7 @@ class GatewayRunner: message_type=_MT.TEXT, source=event.source, message_id=event.message_id, - channel_prompt=getattr(event, "channel_prompt", None), + channel_prompt=event.channel_prompt, ) adapter._pending_messages[_quick_key] = queued_event return "Queued for the next turn." @@ -3869,7 +3869,7 @@ class GatewayRunner: session_id=session_entry.session_id, session_key=session_key, event_message_id=event.message_id, - channel_prompt=getattr(event, "channel_prompt", None), + channel_prompt=event.channel_prompt, ) # Stop persistent typing indicator now that the agent is done @@ -5091,7 +5091,7 @@ class GatewayRunner: message_type=MessageType.TEXT, source=source, raw_message=event.raw_message, - channel_prompt=getattr(event, "channel_prompt", None), + channel_prompt=event.channel_prompt, ) # Let the normal message handler process it @@ -9384,7 +9384,7 @@ class GatewayRunner: session_key=session_key, _interrupt_depth=_interrupt_depth + 1, event_message_id=next_message_id, - channel_prompt=getattr(pending_event, "channel_prompt", None), + channel_prompt=pending_event.channel_prompt, ) finally: # Stop progress sender, interrupt monitor, and notification task diff --git a/tests/gateway/test_discord_channel_prompts.py b/tests/gateway/test_discord_channel_prompts.py index 633fa17bc3..d29180cbd2 100644 --- a/tests/gateway/test_discord_channel_prompts.py +++ b/tests/gateway/test_discord_channel_prompts.py @@ -91,10 +91,19 @@ class TestResolveChannelPrompts: adapter.config.extra = {"channel_prompts": {"100": "Research mode"}} assert adapter._resolve_channel_prompt("100") == "Research mode" - def test_match_by_numeric_channel_id_key(self): + def test_numeric_yaml_keys_normalized_at_config_load(self): + """Numeric YAML keys are normalized to strings by config bridging. + + The resolver itself expects string keys (config.py handles normalization), + so raw numeric keys will not match — this is intentional. + """ adapter = _make_adapter() - adapter.config.extra = {"channel_prompts": {100: "Research mode"}} + # Simulates post-bridging state: keys are already strings + adapter.config.extra = {"channel_prompts": {"100": "Research mode"}} assert adapter._resolve_channel_prompt("100") == "Research mode" + # Pre-bridging numeric key would not match (bridging is responsible) + adapter.config.extra = {"channel_prompts": {100: "Research mode"}} + assert adapter._resolve_channel_prompt("100") is None def test_match_by_parent_id(self): adapter = _make_adapter()