feat(h5): inject direct-chat history on agent escalation and defer ambiguous routing.
Phase B appends snapshot context when leaving h5direct sessions so Goose no longer starts blind. Phase C lets the 0.72 fallback return null on gated chat text so the existing LLM router can run, flags default off. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import {
|
||||
isChatSessionDeferEnabledForUser,
|
||||
isDirectEscalationContextEnabledForUser,
|
||||
resolveChatSessionDeferPolicy,
|
||||
resolveDirectEscalationContextPolicy,
|
||||
shouldDeferChatSessionRoutingToLlm,
|
||||
} from './chat-task-intent-config.mjs';
|
||||
|
||||
test('resolveDirectEscalationContextPolicy defaults to disabled', () => {
|
||||
const policy = resolveDirectEscalationContextPolicy({});
|
||||
assert.equal(policy.enabled, false);
|
||||
assert.equal(policy.canaryUserIds.size, 0);
|
||||
});
|
||||
|
||||
test('isDirectEscalationContextEnabledForUser respects canary list', () => {
|
||||
const policy = {
|
||||
enabled: true,
|
||||
canaryUserIds: new Set(['user-a']),
|
||||
};
|
||||
assert.equal(isDirectEscalationContextEnabledForUser('user-a', policy), true);
|
||||
assert.equal(isDirectEscalationContextEnabledForUser('user-b', policy), false);
|
||||
});
|
||||
|
||||
test('shouldDeferChatSessionRoutingToLlm skips explicit direct chat text', () => {
|
||||
assert.equal(shouldDeferChatSessionRoutingToLlm({
|
||||
enabled: true,
|
||||
text: '你好',
|
||||
isExplicitDirectChatOnlyText: (value) => value === '你好',
|
||||
}), false);
|
||||
assert.equal(shouldDeferChatSessionRoutingToLlm({
|
||||
enabled: true,
|
||||
text: '帮我研究一下车载冰箱的参数和选购建议',
|
||||
minTextLength: 12,
|
||||
isExplicitDirectChatOnlyText: () => false,
|
||||
}), true);
|
||||
assert.equal(shouldDeferChatSessionRoutingToLlm({
|
||||
enabled: false,
|
||||
text: '帮我研究一下车载冰箱的参数和选购建议',
|
||||
isExplicitDirectChatOnlyText: () => false,
|
||||
}), false);
|
||||
});
|
||||
|
||||
test('resolveChatSessionDeferPolicy parses min text length', () => {
|
||||
const policy = resolveChatSessionDeferPolicy({
|
||||
MEMIND_CHAT_ROUTER_CHAT_SESSION_DEFER_ENABLED: '1',
|
||||
MEMIND_CHAT_ROUTER_CHAT_SESSION_DEFER_MIN_TEXT_LENGTH: '20',
|
||||
MEMIND_CHAT_ROUTER_CHAT_SESSION_DEFER_CANARY_USER_IDS: 'john',
|
||||
});
|
||||
assert.equal(policy.enabled, true);
|
||||
assert.equal(policy.minTextLength, 20);
|
||||
assert.deepEqual([...policy.canaryUserIds], ['john']);
|
||||
assert.equal(isChatSessionDeferEnabledForUser('john', policy), true);
|
||||
assert.equal(isChatSessionDeferEnabledForUser('other', policy), false);
|
||||
});
|
||||
Reference in New Issue
Block a user