The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(discord): keep the exec-approval reason bounded after dropping the embed mirror
teknium1c1eb1592e8fa
diff --git a/plugins/platforms/discord/adapter.py b/plugins/platforms/discord/adapter.pyindex 4f26f79a23d..a22a4c7e190 100644--- a/plugins/platforms/discord/adapter.py+++ b/plugins/platforms/discord/adapter.py@@ -5404,6 +5404,9 @@ class DiscordAdapter(DiscordMediaMixin, BasePlatformAdapter):_EA_CODE_CLOSE = "\n```\n"_EA_REASON_LABEL = f"**{EA_REASON_LABEL_TEXT}:** "_EA_SMART_DENY_LINE = "\n\n**Smart DENY:** owner override applies to this one operation only."+ # The reason shares the 2000-char content cap with the command; unbounded it would starve+ # the command preview to zero and push the content past the cap.+ _EA_REASON_BUDGET = 300def _exec_approval_cmd_budget(self, description: str, smart_denied: bool) -> int:# Mentions ride in front of the content and count against the 2000-char message cap too.diff --git a/tests/gateway/test_discord_exec_approval_content.py b/tests/gateway/test_discord_exec_approval_content.pyindex 65918b5a2de..a4e1b97d3c8 100644--- a/tests/gateway/test_discord_exec_approval_content.py+++ b/tests/gateway/test_discord_exec_approval_content.py@@ -48,11 +48,24 @@ async def test_exec_approval_prompt_uses_visible_content_with_command_and_reasonassert "script execution via -c flag" in prompt_textassert "it will NOT run" in prompt_text- # Content is the canonical, accessible approval payload. The embed retains- # its visual state but must not repeat either user-facing value.+ # Content is the canonical, accessible approval payload (embeds may not render, #33681);+ # the embed is a header-only card so the command and reason appear exactly once.embed = sent["embed"]- assert command not in (embed.description or "")- assert "script execution via -c flag" not in (embed.description or "")- assert all(command not in (field.value or "") for field in embed.fields)- assert all("script execution via -c flag" not in (field.value or "") for field in embed.fields)+ embed_text = (embed.description or "") + "".join(field.value or "" for field in embed.fields)+ assert command not in embed_text+ assert "script execution via -c flag" not in embed_text+++async def test_exec_approval_content_stays_within_discord_cap_for_long_reason():+ """The reason shares the 2000-char content cap with the command preview."""+ adapter = DiscordAdapter(PlatformConfig(enabled=True, token="***"))+ sent = _capture_channel(adapter)++ result = await adapter.send_exec_approval(+ chat_id="555", command="x" * 5000, session_key="discord:555", description="r" * 5000)++ assert result.success is True+ assert len(sent["content"]) <= adapter.MAX_MESSAGE_LENGTH+ assert "xxx" in sent["content"] # the command preview is not starved to zero