Conversation
…ispatchMiddleware
…ote desc lacks ybres When a user quotes a file message (type=3) and @bot, the quote's desc field only contains the filename without a ybres:// resource reference. The existing QuoteContextMiddleware only extracted media refs from desc using the ybres regex, which always returned empty for file quotes. Fix: add a transcript lookup fallback in QuoteContextMiddleware.handle() — when quote_media_refs is empty but reply_to_message_id is set, search the session transcript for the quoted message_id and extract ybres anchors from its content. Also fix message_type classification: when quote media resolves non-image files, override message_type to DOCUMENT so gateway/run.py's document injection logic properly prepends the file path and content for the agent.
…dleware, tighten conditions
beforeload
left a comment
There was a problem hiding this comment.
I've encountered this issue as well. when a user quotes a file or image message and @mentions the bot in a group chat, the bot can't access the media content because the quote metadata doesn't carry the resourceId.
I've tested this PR hands-on and it works well. Would love to see it merged. Thanks!
|
Hi @alt-glitch Just wanted to follow up on this PR — is there anything else I can help with to move it forward? This fix is scoped only to the Yuanbao platform and shouldn’t affect other platforms. I’ve tested it locally (including file/image quote scenarios), and everything is working as expected. Happy to make any adjustments or add more tests if needed. Thanks! |
|
This is our team's developer. This fix will optimize the dialogue experience of Yuanbao. |
|
Salvaged onto current main via #26216 and merged. Your 5 commits were cherry-picked with your authorship preserved (rebase merge), now visible on main as d57a4b3..0086cda. Thanks for the fix! One conflict at |
What does this PR do?
Fix Yuanbao bot's inability to read quoted file and image messages in group chats. When a user quotes a file/image message and @mentions the bot, the bot previously could not access the media content — it would report "file not found" because the quote metadata ( cloud_custom_data ) doesn't carry the resourceId needed for downloading.
This PR introduces a transcript fallback lookup mechanism: when the quote's desc field doesn't contain ybres references (which is always the case for file quotes, type=3 ), the system looks up the quoted message by message_id in the session transcript to retrieve the resourceId that was stored when the message was first observed.
Related Issue
Fixes #
Type of Change
Changes Made
File: gateway/platforms/yuanbao.py
⦁If quote_media_refs is empty (file quotes only have filename in desc), performs a reversed transcript lookup by message_id to extract ybres anchors from the observed message content.
⦁Resolves and downloads quote media refs exclusively (skips unrelated history backfill).
⦁Overrides message_type to DOCUMENT when resolved media includes document MIME types ( application/* , text/* ) so gateway/run.py 's file injection logic properly provides the content to the agent.
How to Test
File quote (quote_type=3):
Image quote (quote_type=2):
Regression — non-quote messages:
Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AFor New Skills
hermes --toolsets skills -q "Use the X skill to do Y"Screenshots / Logs