The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(email): deliver oversized cron output as one whole email
teknium133c70180543a
diff --git a/plugins/platforms/email/adapter.py b/plugins/platforms/email/adapter.pyindex aabcfb318ed..419a12ebd25 100644--- a/plugins/platforms/email/adapter.py+++ b/plugins/platforms/email/adapter.py@@ -415,6 +415,8 @@ def _attach_file(msg: MIMEMultipart, path: Path, filename: str) -> None:class EmailAdapter(BasePlatformAdapter):"""Email gateway adapter using IMAP (receive) and SMTP (send)."""+ # One email carries the whole body, so cron delivery hands over the full payload untruncated.+ splits_long_messages = True# Per-account seen-UID snapshot surviving adapter recreation: the reconnect watcher builds a FRESH# adapter per retry; without this connect(is_reconnect=True) would re-mark the mailbox seen and skipdiff --git a/tests/gateway/test_email.py b/tests/gateway/test_email.pyindex 443bc27000b..3f193104fce 100644--- a/tests/gateway/test_email.py+++ b/tests/gateway/test_email.py@@ -1300,5 +1300,28 @@ class TestSenderAuthentication(unittest.TestCase):self.assertFalse(ok, reason)+def test_oversized_cron_output_is_delivered_as_one_whole_email():+ """No 4000-char truncation footer pointing at a file on the gateway host: the router hands+ the whole cron payload to the email adapter, which sends it as a single message."""+ import asyncio+ from gateway.config import GatewayConfig, PlatformConfig+ from gateway.delivery import DeliveryRouter++ with patch.dict(os.environ, {"EMAIL_ADDRESS": "[email protected]", "EMAIL_PASSWORD": "secret",+ "EMAIL_IMAP_HOST": "imap.test.com", "EMAIL_SMTP_HOST": "smtp.test.com"}):+ from plugins.platforms.email.adapter import EmailAdapter+ adapter = EmailAdapter(PlatformConfig(enabled=True))+ sent = []+ smtp = MagicMock()+ smtp.send_message.side_effect = lambda msg: sent.append(msg.get_payload()[0].get_payload(decode=True).decode())+ adapter._connect_smtp = lambda: smtp+ content = "\n\n".join(f"line {i} " + "x" * 200 for i in range(60))+ payload = DeliveryRouter(GatewayConfig())._cap_oversized_output(adapter, content, "job")+ result = asyncio.run(adapter.send("[email protected]", payload))++ assert result.success+ assert sent == [content]++if __name__ == "__main__":unittest.main()