Skip to content

fix(yuanbao): persist message_id on @bot user transcript writes#27866

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-7ca2e462
May 18, 2026
Merged

fix(yuanbao): persist message_id on @bot user transcript writes#27866
teknium1 merged 1 commit into
mainfrom
hermes/hermes-7ca2e462

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

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 QuoteContextMiddleware already 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 quoted message_id and pulling ybres anchors out of the message content.

That fallback works for observed (silent group) messages because yuanbao.py:2091 attaches message_id to the transcript entry. It silently fails for @bot agent-processed messages because gateway/run.py writes them as {role:user, content, timestamp} with no message_id — so quoting an earlier @bot turn with media can't be resolved.

Changes

  • gateway/run.py: attach event.message_id to the user transcript entry at all three write sites — agent_failed_early branch, the no-new-messages edge case, and the normal agent path (first user-role entry in new_messages).

Validation

Before After
Quote observed message + media resolves resolves
Quote @bot message + media fails resolves
Test suite (gateway) 5506 passed
Test suite (yuanbao pipeline) 94 passed

Credit

Closes #27425. Original report and investigation by @loongfay — co-authored on the commit.

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>
@teknium1 teknium1 merged commit 0fa46c6 into main May 18, 2026
16 of 17 checks passed
@teknium1 teknium1 deleted the hermes/hermes-7ca2e462 branch May 18, 2026 08:19
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-7ca2e462 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 8771 on HEAD, 8771 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 4614 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery platform/wecom WeCom / WeChat Work adapter P2 Medium — degraded but workaround exists labels May 18, 2026
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/wecom WeCom / WeChat Work adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants