feat(router): improve direct_chat fast-path and add 103 token env sync
Memind CI / Test, build, and release guards (push) Failing after 12m44s

Route explicit text-only Q&A away from Agent before page-generation rules,
and add a script to enable Router + tighter memory budgets on 103 without
changing the global deepseek-v4-pro model.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-08-25 15:13:22 +08:00
parent 9dfafb99ca
commit 9332bacabd
7 changed files with 758 additions and 13 deletions
+36 -1
View File
@@ -103,6 +103,25 @@ export const DIRECT_CHAT_FAQ_RULES = [
/^.{0,16}(?:有什么建议|给点建议|怎么看)[?]?$/u,
],
},
{
id: 'text_only_declined_page',
reason: '明确要求纯文字、不生成页面/链接',
patterns: [
/(?:不要|别|无需|不需要|禁止).{0,12}(?:生成|做|制作|创建|发布).{0,8}(?:页面|网页|HTML|html|H5|h5|链接)/u,
/(?:纯文字|只要文字|文字回答|不要页面|不用页面|别做页面)/u,
],
},
{
id: 'brief_intro',
reason: '短篇幅介绍/说明(纯文字)',
patterns: [
/(?:用|以).{0,6}(?:一|两|二|三|四|五|几|\d+).{0,4}(?:句话|句).{0,32}(?:介绍|说明|描述|讲讲|推荐)/u,
/^(?:简单|简要|大概|概括)(?:介绍|说明|描述|讲讲).{0,48}[?]?$/u,
/^简要介绍.{0,48}(?:区别|差异|不同|对比|比较)[?]?$/u,
/^(?:推荐|介绍)(?:一个|一下).{0,32}(?:理由|原因)[,]?一句话/u,
/(?:推荐|介绍).{0,32}一句话.{0,16}(?:说明|讲讲).{0,12}(?:理由|原因)/u,
],
},
];
const MAX_FAQ_TEXT_LENGTH = 200;
@@ -111,10 +130,26 @@ const MAX_FAQ_TEXT_LENGTH = 200;
* @param {string} text
* @returns {{ id: string, reason: string } | null}
*/
const EXPLICIT_TEXT_ONLY_PAGE_DECLINE = /(?:不要|别|无需|不需要|禁止).{0,12}(?:生成|做|制作|创建|发布).{0,8}(?:页面|网页|HTML|html|H5|h5|链接)/u;
export function isExplicitTextOnlyRequest(text) {
const normalized = String(text ?? '').trim();
if (!normalized) return false;
return EXPLICIT_TEXT_ONLY_PAGE_DECLINE.test(normalized)
|| /(?:纯文字|只要文字|文字回答|不要页面|不用页面|别做页面)/u.test(normalized);
}
export function matchDirectChatFaqRule(text) {
const normalized = String(text ?? '').trim();
if (!normalized || normalized.length > MAX_FAQ_TEXT_LENGTH) return null;
if (FAQ_EXCLUSION_PATTERNS.some((pattern) => pattern.test(normalized))) return null;
const declinedPage = EXPLICIT_TEXT_ONLY_PAGE_DECLINE.test(normalized)
|| /(?:纯文字|只要文字|文字回答|不要页面|不用页面|别做页面)/u.test(normalized);
if (
!declinedPage
&& FAQ_EXCLUSION_PATTERNS.some((pattern) => pattern.test(normalized))
) {
return null;
}
for (const rule of DIRECT_CHAT_FAQ_RULES) {
if (rule.patterns.some((pattern) => pattern.test(normalized))) {
return { id: rule.id, reason: rule.reason };