feat: add episodic history recall
Memind CI / Test, build, and release guards (pull_request) Successful in 4m37s
Memind CI / Test, build, and release guards (pull_request) Successful in 4m37s
This commit is contained in:
@@ -97,6 +97,7 @@ async function syncConversationMemory({
|
||||
export function createSessionSnapshotService(pool, options = {}) {
|
||||
const conversationMemoryService = options.conversationMemoryService ?? null;
|
||||
const memoryV2 = options.memoryV2 ?? null;
|
||||
const episodicMemoryService = options.episodicMemoryService ?? null;
|
||||
const logger = options.logger ?? console;
|
||||
|
||||
function isEnabled() {
|
||||
@@ -189,6 +190,22 @@ export function createSessionSnapshotService(pool, options = {}) {
|
||||
);
|
||||
});
|
||||
}
|
||||
if (episodicMemoryService?.upsertSnapshot) {
|
||||
void episodicMemoryService.upsertSnapshot({
|
||||
sessionId,
|
||||
userId,
|
||||
session: {
|
||||
...session,
|
||||
display_title: sessionMeta.display_title,
|
||||
},
|
||||
messages,
|
||||
}).catch((err) => {
|
||||
logger?.warn?.(
|
||||
'[snapshot] episodic memory index failed:',
|
||||
err instanceof Error ? err.message : err,
|
||||
);
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
// Non-fatal: log and continue; caller falls back to Goose.
|
||||
console.warn('[snapshot] save failed:', err instanceof Error ? err.message : err);
|
||||
@@ -260,6 +277,14 @@ export function createSessionSnapshotService(pool, options = {}) {
|
||||
async function remove(sessionId) {
|
||||
if (!pool) return;
|
||||
try {
|
||||
if (episodicMemoryService?.remove) {
|
||||
await episodicMemoryService.remove(sessionId).catch((err) => {
|
||||
logger?.warn?.(
|
||||
'[snapshot] episodic memory delete failed:',
|
||||
err instanceof Error ? err.message : err,
|
||||
);
|
||||
});
|
||||
}
|
||||
await pool.query(
|
||||
`DELETE FROM h5_session_snapshots WHERE agent_session_id = ?`,
|
||||
[sessionId],
|
||||
|
||||
Reference in New Issue
Block a user