fix(wechat): guard ambiguous memory recall and scheduled task execution
Skip memory injection for short filler messages, demote page-workflow memory pollution, keep scheduled automation off page.generate, and fail scheduled tasks that only return clarification instead of deliverables. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
||||
isWechatPageEditText,
|
||||
isWechatPageRetryText,
|
||||
} from './page-continuation.mjs';
|
||||
import { shouldUseScheduledTaskAutomation } from '../../scheduled-task-intent.mjs';
|
||||
|
||||
export const PAGE_GENERATE_PATTERN =
|
||||
/(?:生成|创建|做|写|帮我.*(?:生成|创建|做|写)).*(?:html|页面|网页|page|文件)/iu;
|
||||
@@ -29,6 +30,7 @@ export const CONNECTIVITY_TEST_PATTERN = /^(测试\s*\d*|test\s*\d*)[!!。.\s]
|
||||
export function isPageGenerateText(text) {
|
||||
const normalized = String(text ?? '').trim();
|
||||
if (!normalized) return false;
|
||||
if (shouldUseScheduledTaskAutomation(normalized)) return false;
|
||||
if (PAGE_GENERATE_NEGATION_PATTERN.test(normalized)) return false;
|
||||
return (
|
||||
PAGE_GENERATE_PATTERN.test(normalized)
|
||||
|
||||
@@ -33,6 +33,15 @@ test('classifyWechatIntent detects page.generate', () => {
|
||||
assert.equal(isPageGenerateIntent({ msgType: 'text', agentText: intent.topic }), true);
|
||||
});
|
||||
|
||||
test('classifyWechatIntent keeps scheduled automation on chat.general', () => {
|
||||
const intent = classifyWechatIntent({
|
||||
msgType: 'text',
|
||||
agentText: '我想创建一个定时执行任务,今晚 21:45 分执行做新闻页面',
|
||||
});
|
||||
assert.equal(intent.kind, 'chat.general');
|
||||
assert.equal(isPageGenerateIntent({ msgType: 'text', agentText: intent.text }), false);
|
||||
});
|
||||
|
||||
test('classifyWechatIntent detects session.reset', () => {
|
||||
assert.equal(classifyWechatIntent({ msgType: 'text', agentText: '换话题' }).kind, 'session.reset');
|
||||
assert.equal(classifyWechatIntent({ msgType: 'text', agentText: '换新会话' }).kind, 'session.reset');
|
||||
|
||||
Reference in New Issue
Block a user