Skip to content

fix: preserve quote context (ref_msg) for voice messages#49

Open
gaoyangz77 wants to merge 1 commit intoTencent:mainfrom
gaoyangz77:fix/voice-quote-ref-msg
Open

fix: preserve quote context (ref_msg) for voice messages#49
gaoyangz77 wants to merge 1 commit intoTencent:mainfrom
gaoyangz77:fix/voice-quote-ref-msg

Conversation

@gaoyangz77
Copy link
Copy Markdown

@gaoyangz77 gaoyangz77 commented Apr 10, 2026

Summary

  • Extract shared ref_msg handling from the TEXT branch of bodyFromItemList into a reusable applyRefMsg helper
  • Apply the same helper to the VOICE branch so voice messages with STT text preserve quoted context

Previously, when a user sent a voice message quoting a previous message, the agent only received the STT transcription with no indication of the quoted message. Now the output matches the TEXT behavior: [引用: <quoted content>]\n<voice text>.

Closes #48

Changes

src/messaging/inbound.ts

Before:

// TEXT: handles ref_msg ✅
if (item.type === TEXT && item.text_item?.text != null) {
  const text = String(item.text_item.text);
  const ref = item.ref_msg;
  // ... ref_msg logic ...
}
// VOICE: ignores ref_msg ❌
if (item.type === VOICE && item.voice_item?.text) {
  return item.voice_item.text;
}

After:

function applyRefMsg(text: string, ref: MessageItem["ref_msg"]): string {
  // shared ref_msg logic
}

// TEXT: ✅
if (item.type === TEXT && ...) {
  return applyRefMsg(String(item.text_item.text), item.ref_msg);
}
// VOICE: ✅
if (item.type === VOICE && ...) {
  return applyRefMsg(item.voice_item.text, item.ref_msg);
}

Test plan

  • Send a text message, then quote it with a voice message — agent should see [引用: ...] prefix
  • Send a voice message without quoting — agent should see only the STT text (no regression)
  • Quote a media message (image/video) with a voice message — agent should see only the STT text (media quotes are intentionally excluded)

Voice messages with STT text that quote/reply to a previous message
now include the quoted context, matching the existing TEXT behavior.

Previously bodyFromItemList only checked ref_msg for TEXT items,
returning voice_item.text directly and dropping the quote. Extract
shared ref_msg handling into applyRefMsg helper used by both paths.

Closes Tencent#48
@gaoyangz77
Copy link
Copy Markdown
Author

Friendly ping / 轻轻 bump 一下~

这个 PR 修复了语音消息引用时上下文不正确的问题,能让引用内容更准确,减少聊天场景里的理解偏差;同时也 closes #48

This PR fixes the incorrect context used in voice message quoting, which should make quoted voice replies more accurate and reduce confusion in chat flows; it also closes #48.

CI is already passing, so it should be ready for review when convenient. Thanks!

@gaoyangz77
Copy link
Copy Markdown
Author

Gentle ping / 再轻轻 bump 一下~

This PR is still ready for review when convenient. CI has been passing, and the change is scoped to fixing quote context (ref_msg) for voice messages so quoted voice replies use the correct context.

有空的时候麻烦帮看一下,感谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Voice messages with quote (ref_msg) lose quoted context

1 participant