-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Open
Labels
Priority: HighHigh priority issueHigh priority issueType: BugSomething isn't workingSomething isn't working
Description
Bug Report
Problem
When a user sends a message, they receive two different replies instead of one. This happens consistently for all messages.
Root Cause
The processGroupMessages function in src/index.ts calls channel.sendMessage() for each result returned by the SDK in the streaming callback. When the SDK returns multiple results, all of them are sent to the user, causing duplicate replies.
Evidence from Logs
[agent-runner] Result #1: subtype=success text=你好!我很好,谢谢你的问候!有什么我可以帮助你的吗?
[agent-runner] Piping IPC message into active query (109 chars)
[agent-runner] Result #2: subtype=success text=哈哈,抱歉让你久等了!我随时在这里,很高兴能和你聊天。有什么想聊的或者需要我帮忙的吗?😊
Fix Applied
Modified the processGroupMessages function to only send the last output to the user:
// Track the last output
let lastOutput: string | null = null;
const output = await runAgent(group, prompt, chatJid, async (result) => {
if (result.result) {
const raw = typeof result.result === 'string'
? result.result
: JSON.stringify(result.result);
const text = raw.replace(/<internal>[\s\S]*?<\/internal>/g, '').trim();
if (text) {
lastOutput = text; // ← Update last output
outputSentToUser = true;
}
resetIdleTimer();
}
});
// Send only the last output to avoid duplicates
if (lastOutput) {
await channel.sendMessage(chatJid, lastOutput);
}Test Results
✅ After applying the fix, verified with 6 consecutive test messages - each message now receives only one reply.
Impact
- All channels affected: Not specific to Feishu, affects all channels (WhatsApp, Telegram, etc.)
- User experience: Confusing and annoying to receive two different replies
- No side effects observed: Only sends the last result, which is the most complete response
Suggested Action
Consider merging this fix into the main branch to prevent all users from experiencing this duplicate message issue.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Priority: HighHigh priority issueHigh priority issueType: BugSomething isn't workingSomething isn't working