feat(dingtalk): quoted-reply extraction and text handling improvements#14334
Open
meng93 wants to merge 1 commit into
Open
feat(dingtalk): quoted-reply extraction and text handling improvements#14334meng93 wants to merge 1 commit into
meng93 wants to merge 1 commit into
Conversation
Collaborator
6601ceb to
6c0b561
Compare
- 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.
6c0b561 to
7b15c19
Compare
Open
5 tasks
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 thedingtalk-streamSDK does not parse into typed attributes.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. Thedingtalk-streamSDK 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, andmarkdownmessage types the SDK'sChatbotMessageleaves typed attributes empty — the content is only available in the rawextensionsdict.Changes
gateway/platforms/dingtalk.py_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_extract_text()— surface quoted context as[引用] <body>lines; handle both dict andTextContent.extensionsSDK payload shapesgateway/platforms/dingtalk.py_extract_text()for audio/video/file/markdown viaextensions['content']tests/gateway/test_dingtalk.pyTest Plan
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().