Skip to content

feat(dingtalk): extract quoted-reply context for agent awareness#17368

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

feat(dingtalk): extract quoted-reply context for agent awareness#17368
spike2204 wants to merge 1 commit into
NousResearch:mainfrom
spike2204:feat/dingtalk-quoted-reply

Conversation

@spike2204

Copy link
Copy Markdown

Summary

When a user long-presses → quotes → replies in DingTalk, the inbound payload carries isReplyMsg=True + repliedMsg={...}. The dingtalk-stream SDK does not expose this through a typed field; without explicit extraction the agent loses the quoted context.

Changes

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

Ported from dingtalk-openclaw-connector core/message-handler.ts:163-240.

Related

Part of the DingTalk adapter enhancement series — see #12769 for the umbrella PR.

When a user long-presses → quotes → replies in DingTalk, the inbound
payload carries isReplyMsg=True + repliedMsg={...}.  The dingtalk-stream
SDK does not expose this through a typed field; without explicit
extraction the agent loses the quoted context.

- Add _extract_quoted_msg_text() — recursive parser (max_depth=3)
  supporting text, richText, picture, video, audio (recognition),
  file (fileName), markdown, and interactiveCard (forward-compatible)
- Enhance _extract_text() to surface quoted context as '[引用] <body>'
  lines; handle both dict and TextContent.extensions SDK payload shapes
- Add SDK blind-spot fallbacks for audio/video/file/markdown via
  extensions['content'] (types the SDK doesn't parse into typed attrs)
- Add 12 unit tests covering all scenarios

Matches dingtalk-openclaw-connector core/message-handler.ts:163-240. to #
@alt-glitch alt-glitch added type/feature New feature or request P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/dingtalk DingTalk adapter labels Apr 29, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #14334 — same DingTalk quoted-reply extraction feature. Part of umbrella #12769.

@spike2204

Copy link
Copy Markdown
Author

Hi @alt-glitch, thanks for flagging the overlap! 🙏

Correct — this is a refined, self-contained extraction of the quoted-reply feature from the original stacked #14334. To clarify the relationship:

@PeterGuy326 and @spike2204 are colleagues on the DingTalk (钉钉) Open Platform team at Alibaba. We maintain the DingTalk stream SDK, AI Card APIs, and the messaging infrastructure that Hermes integrates with. This PR series represents production-validated improvements from our internal Hermes deployment.

The original #14334 was stacked on top of #14333 (included all reliability fixes + the quoted-reply feature in one PR). This new PR (#17368) isolates only the quoted-reply extraction logic, rebased cleanly against main, making it independently reviewable and mergeable.

Technical note on this feature: DingTalk's quoted-reply payload is carried in text.isReplyMsg + text.repliedMsg — fields the dingtalk-stream SDK intentionally does not parse into typed attributes (it's a client-side convention, not a protocol field). Without explicit extraction here, the agent completely loses the conversational context when users quote-reply, which is a very common interaction pattern in DingTalk group chats.

The 12 unit tests cover all message types including the forward-compatible interactiveCard path — we anticipate DingTalk IM team will populate content.text server-side for card quotes in a future release.

Happy to address any feedback! 🚀

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