fix: don't drop human messages that paste a bot status prefix
A user copy-pasted a bot progress message into joke-app; the invisible U+2063 status prefix came along and getProcessableMessages dropped the human message as a task-status control message, so it was never answered. Only treat the prefix as control when the message is bot-authored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,7 @@ vi.mock('./service-routing.js', async () => {
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
filterLoopingPairedBotMessages,
|
filterLoopingPairedBotMessages,
|
||||||
|
getProcessableMessages,
|
||||||
matchesExpectedPairedFollowUpIntent,
|
matchesExpectedPairedFollowUpIntent,
|
||||||
resolveFollowUpDispatch,
|
resolveFollowUpDispatch,
|
||||||
resolveExecutionTarget,
|
resolveExecutionTarget,
|
||||||
@@ -46,6 +47,32 @@ const baseLease: EffectiveChannelLease = {
|
|||||||
explicit: true,
|
explicit: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
describe('getProcessableMessages task-status prefix', () => {
|
||||||
|
const PREFIX = '\u2063\u2063\u2063';
|
||||||
|
const msg = (id: string, content: string, isBot: boolean) =>
|
||||||
|
({
|
||||||
|
id,
|
||||||
|
chat_jid: 'chat-1',
|
||||||
|
sender: isBot ? 'bot' : 'user',
|
||||||
|
sender_name: isBot ? 'bot' : 'user',
|
||||||
|
content,
|
||||||
|
timestamp: '2026-10-16T08:54:15.670Z',
|
||||||
|
is_bot_message: isBot,
|
||||||
|
}) as never;
|
||||||
|
|
||||||
|
it('drops bot status messages but keeps a human message that pasted the prefix', () => {
|
||||||
|
const out = getProcessableMessages('chat-1', [
|
||||||
|
msg('bot-status', `${PREFIX}STEP_DONE 진행 중`, true),
|
||||||
|
msg(
|
||||||
|
'human-paste',
|
||||||
|
`${PREFIX}Background agent didn't finish\n다시확인바람`,
|
||||||
|
false,
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
expect(out.map((m: { id: string }) => m.id)).toEqual(['human-paste']);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('filterLoopingPairedBotMessages', () => {
|
describe('filterLoopingPairedBotMessages', () => {
|
||||||
const FAIL = '요청을 완료하지 못했습니다. 다시 시도해 주세요.';
|
const FAIL = '요청을 완료하지 못했습니다. 다시 시도해 주세요.';
|
||||||
const msg = (content: string, isBot: boolean) =>
|
const msg = (content: string, isBot: boolean) =>
|
||||||
|
|||||||
@@ -482,7 +482,16 @@ export function getProcessableMessages(
|
|||||||
messages,
|
messages,
|
||||||
hasReviewerLease(chatJid),
|
hasReviewerLease(chatJid),
|
||||||
channel?.isOwnMessage?.bind(channel),
|
channel?.isOwnMessage?.bind(channel),
|
||||||
).filter((message) => !isTaskStatusControlMessage(message.content));
|
).filter(
|
||||||
|
// Only bot-authored status messages carry the control prefix on purpose.
|
||||||
|
// A human who copy-pastes a bot status message also pastes the invisible
|
||||||
|
// prefix, and that message must still reach the agent.
|
||||||
|
(message) =>
|
||||||
|
!(
|
||||||
|
(message.is_bot_message || message.is_from_me) &&
|
||||||
|
isTaskStatusControlMessage(message.content)
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function filterLoopingPairedBotMessages(
|
export function filterLoopingPairedBotMessages(
|
||||||
|
|||||||
Reference in New Issue
Block a user