Skip to content

feat(dingtalk): quoted-reply extraction and text handling improvements#14334

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

feat(dingtalk): quoted-reply extraction and text handling improvements#14334
meng93 wants to merge 1 commit into
NousResearch:mainfrom
PeterGuy326:feat/dingtalk-quoted-reply

Conversation

@meng93

@meng93 meng93 commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Surface DingTalk quoted-reply context ([引用] <body>) to the agent so it can see the conversational thread the user is referencing, and add SDK blind-spot fallbacks for message types the dingtalk-stream SDK does not parse into typed attributes.

Stacked on #14333 — merge that first.

Motivation

When a user long-presses → quotes → replies in the DingTalk client, the inbound payload carries isReplyMsg=True + repliedMsg={...} alongside the user's new text. The dingtalk-stream SDK does not expose this through a typed field; without explicit extraction the agent loses the quoted context, causing confusion on follow-up questions.

Additionally, for audio, video, file, and markdown message types the SDK's ChatbotMessage leaves typed attributes empty — the content is only available in the raw extensions dict.

Changes

File What
gateway/platforms/dingtalk.py Add _extract_quoted_msg_text() — recursive parser (max_depth=3) supporting text, richText, picture, video, audio (recognition), file (fileName), markdown, interactiveCard (forward-compatible)
gateway/platforms/dingtalk.py Enhance _extract_text() — surface quoted context as [引用] <body> lines; handle both dict and TextContent.extensions SDK payload shapes
gateway/platforms/dingtalk.py Add SDK blind-spot fallbacks in _extract_text() for audio/video/file/markdown via extensions['content']
tests/gateway/test_dingtalk.py 12 new unit tests covering all quoted-reply scenarios

Test Plan

  • 12 new pytest cases covering: dict payloads, TextContent extensions, picture/file/card placeholders, nested quotes, JSON-stringified content, and forward-compat interactiveCard scenarios.
  • All existing tests pass unchanged.

Risk Assessment

Low. The _extract_text() change is backward-compatible — when no quote payload is present the function returns the same result as before. The new _extract_quoted_msg_text() is only called from _extract_text().

@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

Quoted-reply extraction overlaps with #12769. Part of stacked series: #14333#14334#14335#14336.

- Add _extract_quoted_msg_text() — recursive parser for DingTalk's
  isReplyMsg/repliedMsg payload, supporting text, richText, picture,
  video, audio (with recognition), file (with fileName), markdown,
  and interactiveCard (forward-compatible: text/markdown/title keys).
  Bounded to max_depth=3 matching openclaw-connector behaviour.
- Enhance _extract_text() to surface quoted context as '[引用] <body>'
  lines appended to the user's new text.  Handles both dict-style and
  TextContent.extensions SDK payload shapes.
- Add SDK blind-spot fallbacks in _extract_text() for message types
  the dingtalk-stream SDK does not parse into typed attributes
  (audio → recognition, video → placeholder, file → fileName,
  markdown → text body).
- Add 12 unit tests covering dict payloads, TextContent extensions,
  picture/file/card placeholders, nested quotes, JSON-stringified
  content, and forward-compat interactiveCard scenarios.
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