fix(yuanbao): persist message_id on @bot user transcript writes#27866
Merged
Conversation
Yuanbao's QuoteContextMiddleware has a transcript-lookup fallback for when quote.desc is empty: it scans the session transcript for the quoted message_id and pulls ybres anchors out of its content. That fallback works for observed (silent) group messages because the platform writer attaches message_id (yuanbao.py:2091). It silently fails for @bot agent-processed messages because gateway/run.py wrote them as {role:user, content, timestamp} with no message_id, so quoting an earlier @bot turn that contained an image/file couldn't be resolved. Fix: attach event.message_id to the user transcript entry at all three write sites in gateway/run.py — the agent_failed_early branch, the no-new-messages edge case, and the normal agent path (first user-role entry in new_messages). Surfaces gap reported in #27425 (loongfay) using the existing fallback already on main; no new caches needed. Co-authored-by: loongfay <loongfay@users.noreply.github.com>
Contributor
🔎 Lint report:
|
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
Plug the gap surfaced by #27425 — quoted @bot messages with media now resolve via the existing transcript-lookup fallback. Closes the same bug in ~21 LOC instead of #27425's 110 LOC of new caches + 280 LOC of tests.
Root cause
Yuanbao's
QuoteContextMiddlewarealready has a transcript-lookup fallback for empty-desc quotes (added May 10 in fc2754d / refactored in 0086cda). It works by scanning the session transcript for the quotedmessage_idand pulling ybres anchors out of the message content.That fallback works for observed (silent group) messages because
yuanbao.py:2091attachesmessage_idto the transcript entry. It silently fails for @bot agent-processed messages becausegateway/run.pywrites them as{role:user, content, timestamp}with nomessage_id— so quoting an earlier @bot turn with media can't be resolved.Changes
gateway/run.py: attachevent.message_idto the user transcript entry at all three write sites —agent_failed_earlybranch, the no-new-messages edge case, and the normal agent path (first user-role entry innew_messages).Validation
Credit
Closes #27425. Original report and investigation by @loongfay — co-authored on the commit.