fix(router): route casual chat to DeepSeek and reserve Cursor for page tasks
Default unmatched conversation to direct_chat, stop blanket Agent session continuation and generic Agent→Cursor promotion; fix WeChat page retry userPublishDir scope and simplify ChatPanel controls. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+36
-39
@@ -399,11 +399,9 @@ export function coerceRealtimeWebSkill(classification, text, { grantedSkills = [
|
||||
}
|
||||
|
||||
function resolveRouterFallbackRoute(env, overrides = {}) {
|
||||
const raw = overrides.fallbackRoute
|
||||
return overrides.fallbackRoute
|
||||
?? normalizeRoute(env?.MEMIND_CHAT_ROUTER_FALLBACK_ROUTE)
|
||||
?? CHAT_INTENT_ROUTE.AGENT;
|
||||
// Timeout/parse failures must fail open to agent so realtime/tool tasks are not dropped.
|
||||
return raw === CHAT_INTENT_ROUTE.DIRECT_CHAT ? CHAT_INTENT_ROUTE.AGENT : raw;
|
||||
?? CHAT_INTENT_ROUTE.DIRECT_CHAT;
|
||||
}
|
||||
|
||||
const DEFAULT_ROUTER_TIMEOUT_MS = 1200;
|
||||
@@ -1071,12 +1069,7 @@ export function classifyWithRules({
|
||||
reason: '消息包含非文本内容',
|
||||
}, { source: 'rule' }), decisionContext);
|
||||
}
|
||||
if (
|
||||
includeIntentPatterns &&
|
||||
normalized &&
|
||||
isMemoryRecallQuestion(normalized) &&
|
||||
!hasPriorAgentConversation(sessionId, sessionMessageCount)
|
||||
) {
|
||||
if (includeIntentPatterns && normalized && isMemoryRecallQuestion(normalized)) {
|
||||
return finalizeRouterClassification(normalizeClassification({
|
||||
route: CHAT_INTENT_ROUTE.DIRECT_CHAT,
|
||||
confidence: 0.98,
|
||||
@@ -1091,16 +1084,6 @@ export function classifyWithRules({
|
||||
reason: faqMatch?.reason ?? '用户明确要求纯文字、不生成页面',
|
||||
}, { source: 'rule' }), decisionContext);
|
||||
}
|
||||
if (hasPriorAgentConversation(sessionId, sessionMessageCount)) {
|
||||
const reason = isAgentSessionContinueText(normalized)
|
||||
? 'Agent 会话确认/续聊'
|
||||
: '延续已有 Agent 会话';
|
||||
return finalizeRouterClassification(normalizeClassification({
|
||||
route: CHAT_INTENT_ROUTE.AGENT,
|
||||
confidence: 1,
|
||||
reason,
|
||||
}, { source: 'rule' }), decisionContext);
|
||||
}
|
||||
if (includeIntentPatterns && normalized) {
|
||||
const faqMatch = matchDirectChatFaqRule(normalized);
|
||||
if (faqMatch) {
|
||||
@@ -1111,6 +1094,35 @@ export function classifyWithRules({
|
||||
}, { source: 'rule' }), decisionContext);
|
||||
}
|
||||
}
|
||||
if (
|
||||
includeIntentPatterns &&
|
||||
normalized &&
|
||||
OBVIOUS_DIRECT_PATTERNS.some((pattern) => pattern.test(normalized))
|
||||
) {
|
||||
return finalizeRouterClassification(normalizeClassification({
|
||||
route: CHAT_INTENT_ROUTE.DIRECT_CHAT,
|
||||
confidence: 0.95,
|
||||
reason: '简单寒暄或连通性测试',
|
||||
}, { source: 'rule' }), decisionContext);
|
||||
}
|
||||
if (
|
||||
includeIntentPatterns &&
|
||||
normalized &&
|
||||
OBVIOUS_DIRECT_CHAT_PATTERNS.some((pattern) => pattern.test(normalized))
|
||||
) {
|
||||
return finalizeRouterClassification(normalizeClassification({
|
||||
route: CHAT_INTENT_ROUTE.DIRECT_CHAT,
|
||||
confidence: 0.95,
|
||||
reason: '纯文字创作或闲聊,无需执行任务',
|
||||
}, { source: 'rule' }), decisionContext);
|
||||
}
|
||||
if (hasPriorAgentConversation(sessionId, sessionMessageCount) && isAgentSessionContinueText(normalized)) {
|
||||
return finalizeRouterClassification(normalizeClassification({
|
||||
route: CHAT_INTENT_ROUTE.AGENT,
|
||||
confidence: 1,
|
||||
reason: 'Agent 会话确认/续聊',
|
||||
}, { source: 'rule' }), decisionContext);
|
||||
}
|
||||
if (includeIntentPatterns && normalized && isPageDataDevIntent(normalized)) {
|
||||
return finalizeRouterClassification(normalizeClassification({
|
||||
route: CHAT_INTENT_ROUTE.AGENT,
|
||||
@@ -1160,26 +1172,11 @@ export function classifyWithRules({
|
||||
if (includeIntentPatterns && normalized && isRealtimeInfoQuestion(normalized)) {
|
||||
return finalizeRouterClassification(buildRealtimeInfoClassification(), decisionContext);
|
||||
}
|
||||
if (
|
||||
includeIntentPatterns &&
|
||||
normalized &&
|
||||
OBVIOUS_DIRECT_PATTERNS.some((pattern) => pattern.test(normalized))
|
||||
) {
|
||||
if (includeIntentPatterns && normalized) {
|
||||
return finalizeRouterClassification(normalizeClassification({
|
||||
route: CHAT_INTENT_ROUTE.DIRECT_CHAT,
|
||||
confidence: 0.95,
|
||||
reason: '简单寒暄或连通性测试',
|
||||
}, { source: 'rule' }), decisionContext);
|
||||
}
|
||||
if (
|
||||
includeIntentPatterns &&
|
||||
normalized &&
|
||||
OBVIOUS_DIRECT_CHAT_PATTERNS.some((pattern) => pattern.test(normalized))
|
||||
) {
|
||||
return finalizeRouterClassification(normalizeClassification({
|
||||
route: CHAT_INTENT_ROUTE.DIRECT_CHAT,
|
||||
confidence: 0.95,
|
||||
reason: '纯文字创作或闲聊,无需执行任务',
|
||||
confidence: 0.72,
|
||||
reason: '普通对话默认走轻量聊天',
|
||||
}, { source: 'rule' }), decisionContext);
|
||||
}
|
||||
return null;
|
||||
@@ -1220,7 +1217,7 @@ export function createChatIntentRouter(options = {}) {
|
||||
});
|
||||
}
|
||||
|
||||
function buildFallbackClassification(reason = '规则未命中,走 skill 默认 Agent 通道') {
|
||||
function buildFallbackClassification(reason = '规则未命中,默认轻量聊天') {
|
||||
return normalizeClassification({
|
||||
route: policy.fallbackRoute,
|
||||
confidence: 0.5,
|
||||
|
||||
Reference in New Issue
Block a user