From d1068f1627efc85588e654c2a4595aa02e9c8b25 Mon Sep 17 00:00:00 2001 From: Codex Date: Fri, 16 Oct 2026 17:56:33 +0900 Subject: [PATCH] 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 --- src/message-runtime-rules.test.ts | 27 +++++++++++++++++++++++++++ src/message-runtime-rules.ts | 11 ++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/message-runtime-rules.test.ts b/src/message-runtime-rules.test.ts index d6bd8ab..d2df7e3 100644 --- a/src/message-runtime-rules.test.ts +++ b/src/message-runtime-rules.test.ts @@ -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) => diff --git a/src/message-runtime-rules.ts b/src/message-runtime-rules.ts index e25855c..98947b8 100644 --- a/src/message-runtime-rules.ts +++ b/src/message-runtime-rules.ts @@ -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(