Skip to content

Commit 45247f2

Browse files
committed
fix(proposal-a): P1/P2 refine feedback loop
P1 (Codex): Don't write last_confirmed_use_at on explicit error. When user explicitly corrects a recall, we shouldn't mark it as "confirmed use" - otherwise staleInjected logic breaks. P2 (Codex): 1. Run TTL cleanup on read path too (not just set path). This handles idle sessions that never trigger set() again. 2. Refine confirm/error keywords to reduce false positives. Removed "ok" and "no" which are too generic.
1 parent d33fe19 commit 45247f2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3003,6 +3003,8 @@ const memoryLanceDBProPlugin = {
30033003
// Use same key format as auto-recall hook (sessionKey:agentId) so we read the right entry.
30043004
const agentIdForKey = resolveHookAgentId(ctx?.agentId, (event as any).sessionKey);
30053005
const sessionKey = `${ctx?.sessionKey || ctx?.sessionId || "default"}:${agentIdForKey ?? ""}`;
3006+
// P2 fix: also cleanup on read path to handle idle sessions that never trigger set()
3007+
cleanupPendingRecall();
30063008
const pending = pendingRecall.get(sessionKey);
30073009
if (!pending) return;
30083010

@@ -3041,8 +3043,8 @@ const memoryLanceDBProPlugin = {
30413043
const boostOnConfirm = fb.boostOnConfirm ?? 0.15;
30423044
const penaltyOnError = fb.penaltyOnError ?? 0.10;
30433045
const minRecallCountForPenalty = fb.minRecallCountForPenalty ?? 2;
3044-
const confirmKeywords = fb.confirmKeywords ?? ["正確", "yes", "right", "沒錯", "確認", "correct", "ok"];
3045-
const errorKeywords = fb.errorKeywords ?? ["不是", "", "不對", "wrong", "no", "not right", "錯誤", "更正"];
3046+
const confirmKeywords = fb.confirmKeywords ?? ["correct", "right", "yes", "confirmed", "exactly", "對", "沒錯", "正確", "確認", "好的"];
3047+
const errorKeywords = fb.errorKeywords ?? ["wrong", "incorrect", "not right", "that's wrong", "error", "mistake", "fix it", "change that", "改成", "改為", "不是這樣", "不對", "錯了"];
30463048

30473049
// event.prompt is a plain string in the current hook contract (confirmed by codebase usage).
30483050
// We extract the user's last message from event.messages array instead.
@@ -3125,7 +3127,7 @@ const memoryLanceDBProPlugin = {
31253127
newImportance = Math.max(0.1, newImportance - penaltyOnError);
31263128
}
31273129
await store.update(recallId, { importance: newImportance }, undefined);
3128-
await store.patchMetadata(recallId, { bad_recall_count: badCount + 1, last_confirmed_use_at: Date.now() }, undefined);
3130+
await store.patchMetadata(recallId, { bad_recall_count: badCount + 1 }, undefined);
31293131
} else if (badCount >= 1) {
31303132
// P1 fix: check >= 1 to match injection path's staleInjected increment.
31313133
// After injection increments (staleInjected), badCount will be 1, so we apply

0 commit comments

Comments
 (0)