Repository navigation
feat(whatsapp): outbound media attachments via Twilio MediaUrl (#1315) - #1318
Conversation
WhatsApp agents can now send files to users. send_response delivers ChannelResponse.files as Twilio MediaUrl attachments (one message per file, text first), reaching parity with the Slack adapter. - New create_share_from_bytes() persists in-memory bytes through the FILES-001 pipeline (MIME-blocklist/quota/disk/DB) and mints a public ?sig= URL; both it and create_share now share the extracted _persist_and_register helper. - Per-agent file_sharing_enabled gate; 1h share TTL (cleanup reaper purges). - Caps (image/audio/video ~5MB, documents ~16MB) on the detected MIME; graceful text-link fallback when public_chat_url is unset/non-HTTPS, the MIME is unsupported, or the file is oversized — never silently dropped. - Per-file isolation: a rejected/failed file never aborts the text or siblings. - 42 unit tests; requirements.md + whatsapp-integration.md updated. Fixes #1315 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
/review — #1318 (WhatsApp outbound media)Reviewed the diff against ✅ Verified good
🟡 Informational[I1] "never silent drop" is slightly overstated for pre-persist rejections (Confidence: 7/10) [I2] Sync persist in the async send path (Confidence: 6/10) Summary
Nice work. LGTM modulo the I1 wording/UX nit. Automated |
Summary
WhatsAppAdapter.send_responsedeliversChannelResponse.filesas TwilioMediaUrlattachments (one message per file, text sent first), reaching parity with the Slack adapter — previously these files were silently dropped.MediaUrlserver-side, so each file is persisted to FILES-001 storage and handed to Twilio as its public?sig=URL. Newcreate_share_from_bytes()is the bytes-input twin ofcreate_share; both now share the extracted_persist_and_registerhelper (MIME-blocklist → quota → disk-check → persist → DB → URL).file_sharing_enabledtoggle; short 1h share TTL (the existing cleanup-service reaper purges expired shares).Changes
src/backend/adapters/whatsapp_adapter.py—_prepare_outbound_media(persist + classify, per-file isolated),send_responserestructure (markdown-convert text first, append download links verbatim, then one media message per file),_send_messagegainsmedia_url, MIME-cap helper + constants.src/backend/services/agent_shared_files_service.py— extract_persist_and_register+_validate_expires_in; addcreate_share_from_bytes.create_sharebehavior unchanged.tests/unit/test_whatsapp_outbound_media.py— 42 tests.docs/memory/requirements.md,docs/memory/feature-flows/whatsapp-integration.md— outbound-media flow documented.Design notes
Content-Type: mime_type, which Twilio reads to render media), not the code-fencelanguagehint.application/octet-stream/unknown → text-link fallback.public_chat_url/ unsupported MIME / oversized → the file's download link is appended to the text body + WARN log.HTTPException, or any error) is logged and skipped — it never aborts the text reply or sibling files.twilio_webhookdedups inbound byMessageSidbefore dispatch, sosend_response(and each mint) runs exactly once.ChannelResponse.filesartifacts only; promoting in-text FILES-001 URLs toMediaUrlis deferred (feat(whatsapp): outbound media attachments — deliver ChannelResponse.files to WhatsApp users via Twilio MediaUrl #1315 option b). Telegram has the same outbound-drop bug but uses directsendDocument(no URL needed) — tracked as a follow-up.Test Plan
pytest tests/unit/test_whatsapp_outbound_media.py(42 passed)file_sharing_enabled+ public HTTPSpublic_chat_urlreturns a csv/json code-fence → user receives the file inlineFixes #1315
🤖 Generated with Claude Code