Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3984,6 +3984,18 @@ const memoryLanceDBProPlugin = {
embedPassage: (text) => embedder.embedPassage(text),
vectorSearch: (vector, limit, minScore, scopeFilter) => store.vectorSearch(vector, limit, minScore, scopeFilter),
store: (entry) => store.store(entry),
onPersisted: mdMirror
? async (entry, kind) => {
// The event row is a run-marker (kv stamp, no semantic content); the
// daily journal already records the run via its "Reflection generated"
// line, so mirroring the stamp only adds a content-less entry.
if (kind === "event")
return;
const source = kind === "item-invariant" ? "reflection-slice:invariant"
: "reflection-slice:derived";
await mdMirror({ text: entry.text, category: entry.category, scope: entry.scope, timestamp: entry.timestamp }, { source, agentId: sourceAgentId });
}
: undefined,
});
if (sessionKey && stored.slices.derived.length > 0 && !isSessionBoundaryReflectionAction(action)) {
reflectionDerivedBySession.set(sessionKey, {
Expand Down Expand Up @@ -4066,10 +4078,15 @@ const memoryLanceDBProPlugin = {
const now = new Date(params.timestampMs ?? Date.now());
const dateStr = now.toISOString().split("T")[0];
const timeStr = now.toISOString().split("T")[1].split(".")[0];
// Session key/id stay out of `text`: it is the FTS index surface, and
// the `simple` tokenizer splits a key like
// `agent:main:cron:<uuid>:run:<uuid>` on its punctuation — so every session
// summary ends up indexed under `agent`, `main`, `cron`, `run`. A query
// mentioning any of those then BM25-matches every session summary in the
// store regardless of content. Both ids are already recorded structurally
// in metadata below, so provenance is unaffected.
const memoryText = [
`Session: ${dateStr} ${timeStr} UTC`,
`Session Key: ${params.sessionKey}`,
`Session ID: ${params.sessionId}`,
`Source: ${params.source}`,
"",
"Conversation Summary:",
Expand Down
10 changes: 9 additions & 1 deletion dist/src/reflection-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export async function storeReflectionToLanceDB(params) {
continue;
}
}
await params.store({
const storedEntry = await params.store({
text: payload.text,
vector,
category: "reflection",
Expand All @@ -122,6 +122,14 @@ export async function storeReflectionToLanceDB(params) {
metadata: JSON.stringify(payload.metadata),
});
storedKinds.push(payload.kind);
if (params.onPersisted && payload.kind !== "combined-legacy") {
try {
await params.onPersisted(storedEntry, payload.kind);
}
catch {
// mirror/notification failures must never abort reflection persistence
}
}
}
return { stored: storedKinds.length > 0, eventId, slices, storedKinds };
}
Expand Down
15 changes: 15 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5075,6 +5075,21 @@ const memoryLanceDBProPlugin = {
vectorSearch: (vector, limit, minScore, scopeFilter) =>
store.vectorSearch(vector, limit, minScore, scopeFilter),
store: (entry) => store.store(entry),
onPersisted: mdMirror
? async (entry, kind) => {
// The event row is a run-marker (kv stamp, no semantic content); the
// daily journal already records the run via its "Reflection generated"
// line, so mirroring the stamp only adds a content-less entry.
if (kind === "event") return;
const source =
kind === "item-invariant" ? "reflection-slice:invariant"
: "reflection-slice:derived";
await mdMirror(
{ text: entry.text, category: entry.category, scope: entry.scope, timestamp: entry.timestamp },
{ source, agentId: sourceAgentId },
);
}
: undefined,
});
if (sessionKey && stored.slices.derived.length > 0 && !isSessionBoundaryReflectionAction(action)) {
reflectionDerivedBySession.set(sessionKey, {
Expand Down
Loading
Loading