fix(memory-v2): improve pgvector recall and WeChat memory injection
Add keyword fallback and dedupe for pgvector resolve, score personal vs episodic memories by relevance, record WeChat recall product events, and disable broken chatrecall on Postgres session storage. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -37,6 +37,10 @@ import {
|
||||
isWechatContentEditFollowup,
|
||||
} from './wechat/intent/page-continuation.mjs';
|
||||
import { resolvePageGenerateOutcome } from './wechat/handlers/page-generate.mjs';
|
||||
import {
|
||||
MEMORY_V2_PRODUCT_EVENT_TYPES,
|
||||
recordMemoryV2ProductEvent,
|
||||
} from './memory-v2-product-events.mjs';
|
||||
import {
|
||||
buildWechatImageRunMetadata,
|
||||
resolveWechatImageGenerationPolicy,
|
||||
@@ -1488,6 +1492,7 @@ export function createWechatMpService({
|
||||
llmProviderService = null,
|
||||
chatIntentRouter = null,
|
||||
wechatIntentRouter = null,
|
||||
mysqlPool = null,
|
||||
systemDisclosurePolicyService = null,
|
||||
onPageGenerated = null,
|
||||
applySessionLlmProvider = null,
|
||||
@@ -2358,6 +2363,28 @@ export function createWechatMpService({
|
||||
) {
|
||||
return userMessage;
|
||||
}
|
||||
const memoryCount = memoryContext.memories.length;
|
||||
if (mysqlPool?.query) {
|
||||
void recordMemoryV2ProductEvent(mysqlPool, {
|
||||
eventType: MEMORY_V2_PRODUCT_EVENT_TYPES.RESOLVED_INJECTED,
|
||||
userId,
|
||||
sessionId,
|
||||
data: {
|
||||
mode: memoryContext.mode ?? null,
|
||||
memoryCount,
|
||||
source: memoryContext.source ?? 'wechat_mp',
|
||||
},
|
||||
}).catch(() => {});
|
||||
void recordMemoryV2ProductEvent(mysqlPool, {
|
||||
eventType: MEMORY_V2_PRODUCT_EVENT_TYPES.RECALL_HIT,
|
||||
userId,
|
||||
sessionId,
|
||||
data: {
|
||||
memoryCount,
|
||||
mode: memoryContext.mode ?? null,
|
||||
},
|
||||
}).catch(() => {});
|
||||
}
|
||||
const orchestrationMessage = preserveAgentPrompt
|
||||
? {
|
||||
...userMessage,
|
||||
|
||||
Reference in New Issue
Block a user