@mingxy/cerebro 1.12.1 → 1.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/hooks.ts +11 -3
package/package.json
CHANGED
package/src/hooks.ts
CHANGED
|
@@ -633,6 +633,13 @@ export function compactingHook(client: CerebroClient, containerTags: string[], t
|
|
|
633
633
|
output.context.push(block);
|
|
634
634
|
output.context.push(FETCH_POLICY);
|
|
635
635
|
}
|
|
636
|
+
// 将compacting搜索结果的ID写入injectedMemoryIds,避免后续autoRecall重复注入
|
|
637
|
+
if (input.sessionID && results.length > 0) {
|
|
638
|
+
const compactingIds = results.map((r) => r.memory.id);
|
|
639
|
+
const existing = injectedMemoryIds.get(input.sessionID) ?? new Set<string>();
|
|
640
|
+
injectedMemoryIds.set(input.sessionID, new Set([...existing, ...compactingIds]));
|
|
641
|
+
logDebug("compactingHook updated injectedMemoryIds", { sessionId: input.sessionID, addedCount: compactingIds.length, totalExisting: existing.size });
|
|
642
|
+
}
|
|
636
643
|
} catch {
|
|
637
644
|
}
|
|
638
645
|
|
|
@@ -652,7 +659,6 @@ export function compactingHook(client: CerebroClient, containerTags: string[], t
|
|
|
652
659
|
if (input.sessionID) {
|
|
653
660
|
sessionMessages.delete(input.sessionID);
|
|
654
661
|
profileInjectedSessions.delete(input.sessionID);
|
|
655
|
-
injectedMemoryIds.delete(input.sessionID);
|
|
656
662
|
firstMessages.delete(input.sessionID);
|
|
657
663
|
}
|
|
658
664
|
return;
|
|
@@ -679,7 +685,6 @@ export function compactingHook(client: CerebroClient, containerTags: string[], t
|
|
|
679
685
|
if (isAutoStoreEnabled && !isAutoStoreEnabled(input.sessionID)) {
|
|
680
686
|
sessionMessages.delete(input.sessionID);
|
|
681
687
|
profileInjectedSessions.delete(input.sessionID);
|
|
682
|
-
injectedMemoryIds.delete(input.sessionID);
|
|
683
688
|
firstMessages.delete(input.sessionID);
|
|
684
689
|
} else {
|
|
685
690
|
const messages = sessionMessages.get(input.sessionID)!;
|
|
@@ -708,8 +713,11 @@ export function compactingHook(client: CerebroClient, containerTags: string[], t
|
|
|
708
713
|
// Cleanup tracked messages regardless of ingest result
|
|
709
714
|
sessionMessages.delete(input.sessionID);
|
|
710
715
|
profileInjectedSessions.delete(input.sessionID);
|
|
711
|
-
injectedMemoryIds.delete(input.sessionID);
|
|
712
716
|
firstMessages.delete(input.sessionID);
|
|
717
|
+
// Evict stale injectedMemoryIds if over size cap (200 sessions)
|
|
718
|
+
if (injectedMemoryIds.size > 200) {
|
|
719
|
+
injectedMemoryIds.clear();
|
|
720
|
+
}
|
|
713
721
|
}
|
|
714
722
|
|
|
715
723
|
// Phase 2: compact inserts "[restore checkpointed" user message — poll for that marker
|