Skip to content

feat(dingtalk): rich-media inbound pipeline — download, parse, persist#14335

Open
meng93 wants to merge 1 commit into
NousResearch:mainfrom
PeterGuy326:feat/dingtalk-media-pipeline
Open

feat(dingtalk): rich-media inbound pipeline — download, parse, persist#14335
meng93 wants to merge 1 commit into
NousResearch:mainfrom
PeterGuy326:feat/dingtalk-media-pipeline

Conversation

@meng93

@meng93 meng93 commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Add a full inbound rich-media pipeline for the DingTalk adapter: download images / files from DingTalk's CDN, parse document contents (docx / pdf / xlsx / txt), persist to a local inbox directory with automatic 24 h purge, and inject parsed text into the agent context so the LLM can reason over attachments.

Stacked on #14334 — merge that first.

Motivation

DingTalk users regularly share screenshots, PDFs, spreadsheets, and Word documents in chats. Without media handling, the agent only sees a placeholder [文件] or [图片] and cannot act on the content. This PR gives the agent the same document-understanding capability that the Telegram and Discord adapters already have.

Changes

File What
gateway/platforms/dingtalk.py File parsers: _parse_text_file, _parse_docx_file, _parse_pdf_file, _parse_excel_file with graceful fallbacks
gateway/platforms/dingtalk.py _inbound_media_dir() + _cleanup_inbound_media() — 24 h auto-purge
gateway/platforms/dingtalk.py _download_file_to_inbox() — authenticated download via DingTalk /v1.0/robot/messageFiles/download with 20 MB guard
gateway/platforms/dingtalk.py _download_images_to_local() — batch download photo/rich-text images for multi-modal input
gateway/platforms/dingtalk.py _extract_and_parse_file_attachments() — walk raw extensions payload, resolve URLs, download, parse
gateway/platforms/dingtalk.py _resolve_single_download_url() — thin wrapper for the download endpoint
gateway/platforms/dingtalk.py Integrate media pipeline into _on_message(); send() @mention support
pyproject.toml Add python-docx, pdfplumber, openpyxl to dingtalk optional deps

Test Plan

  • Existing tests/gateway/test_dingtalk.py suite passes.
  • Manual testing: sent .docx, .pdf, .xlsx, .png, mixed rich-text messages — all correctly parsed and surfaced to the agent.
  • Verified 24 h cleanup purges stale files.

Risk Assessment

Low-Medium. File parsing dependencies (python-docx, pdfplumber, openpyxl) are optional — the parsers degrade gracefully with a log warning when not installed. Downloaded files are capped at 20 MB and auto-purged after 24 h.

@alt-glitch alt-glitch added type/feature New feature or request P2 Medium — degraded but workaround exists platform/dingtalk DingTalk adapter comp/gateway Gateway runner, session dispatch, delivery labels Apr 23, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Overlaps with #9451 (rich media in&outbound) and #8988 (inbound picture download). Part of stacked series: #14333#14334#14335#14336.

- Add file content parsers (_parse_text_file, _parse_docx_file,
  _parse_pdf_file, _parse_excel_file) with graceful fallbacks when
  optional dependencies are missing.  Parsed text is injected into
  the agent context so the LLM can reason over document contents.
- Add inbound media directory helpers (_inbound_media_dir,
  _cleanup_inbound_media) with 24 h automatic purge so downloaded
  attachments do not accumulate on disk.
- Add _download_file_to_inbox() — authenticated download via
  DingTalk /v1.0/robot/messageFiles/download with resumable-range
  support and _DINGTALK_MEDIA_MAX_SIZE (20 MB) guard.
- Add _download_images_to_local() — batch download of photo/rich-text
  image download_codes to local paths for multi-modal agent input.
- Add _extract_and_parse_file_attachments() — walk the raw inbound
  extensions payload, resolve download URLs, download, parse, and
  return structured attachment metadata for the agent context.
- Integrate media pipeline into _on_message(); send() @mention support.
- Add python-docx, pdfplumber, openpyxl to dingtalk optional deps
  in pyproject.toml.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/dingtalk DingTalk adapter type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants