From 5c84c8840b9e4efeaa648f20b70a2f25bc7aed80 Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Sun, 1 Mar 2026 11:24:28 -0500 Subject: [PATCH] fix: use emoji allowlist instead of length check in pick_reaction Prevents text words like "skull" from passing the filter and causing Discord HTTPException noise. Co-Authored-By: Claude Opus 4.6 --- utils/llm_client.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/utils/llm_client.py b/utils/llm_client.py index 8f77dba..4d9a1a0 100644 --- a/utils/llm_client.py +++ b/utils/llm_client.py @@ -743,6 +743,12 @@ class LLMClient: self._log_llm("classify_intent", elapsed, False, message_text[:200], error=str(e)) return "chat" + _REACTION_EMOJIS = { + "\U0001f480", "\U0001f602", "\U0001f440", "\U0001f525", + "\U0001f4af", "\U0001f62d", "\U0001f921", "\u2764\ufe0f", + "\U0001fae1", "\U0001f913", "\U0001f974", "\U0001f3af", + } + async def pick_reaction(self, message_text: str, channel_name: str) -> str | None: """Pick a contextual emoji reaction for a Discord message. @@ -785,7 +791,7 @@ class LLMClient: raw = (response.choices[0].message.content or "").strip() token = raw.split()[0] if raw.split() else "" - if not token or token.lower() == "none" or len(token) > 7: + if not token or token.lower() == "none" or token not in self._REACTION_EMOJIS: self._log_llm("pick_reaction", elapsed, True, message_text[:200], "NONE") return None