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:
Codex
2026-10-16 17:56:33 +09:00
parent 0d7e345d3d
commit d1068f1627
2 changed files with 37 additions and 1 deletions

View File

@@ -19,6 +19,7 @@ vi.mock('./service-routing.js', async () => {
import {
filterLoopingPairedBotMessages,
getProcessableMessages,
matchesExpectedPairedFollowUpIntent,
resolveFollowUpDispatch,
resolveExecutionTarget,
@@ -46,6 +47,32 @@ const baseLease: EffectiveChannelLease = {
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', () => {
const FAIL = '요청을 완료하지 못했습니다. 다시 시도해 주세요.';
const msg = (content: string, isBot: boolean) =>

View File

@@ -482,7 +482,16 @@ export function getProcessableMessages(
messages,
hasReviewerLease(chatJid),
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(