fix(eve): address review — async-write status, reasoning filter, turn-bounded capture, best-effort dedup
Review by @kartik-mem0. Root cause across all four: Mem0's hosted add with
infer:true is async and returns a PENDING event before the memory is visible.
- store.ts/tools.ts: add() returns AddResult{status,eventId} via parseAddResult;
the v3 add path returns {status:"PENDING", event_id}, so remember reports
{status:"queued", eventId} for async writes and {status:"saved"} only when
resolved. FAILED/unknown status maps to completed, not queued.
- messages.ts: drop typed non-text parts (reasoning no longer leaks into memory);
bound the captured assistant reply to the current turn and collect all of its
text segments (text->tool->text) instead of a stale prior answer.
- capture.ts + README + eve.mdx: document operationId dedup as best-effort
(lookup+add is not atomic; pending/concurrent windows can double-write);
removed the "restart replays cannot write twice" claim.
Tests: 68 pass (+15). Added reasoning, tool-only/cross-turn, multi-segment,
pending/concurrent capture replay, and PENDING/FAILED add-result cases.
Typecheck + build clean.
This commit is contained in:
@@ -247,7 +247,7 @@ describe("mem0Provider", () => {
|
||||
expect(search).toEqual({
|
||||
memories: [{ id: "mem_1", memory: "likes tea" }],
|
||||
});
|
||||
expect(remember).toEqual({ saved: true });
|
||||
expect(remember).toEqual({ status: "saved" });
|
||||
expect(forget).toEqual({ deleted: true });
|
||||
expect(store.searched[0]).toMatchObject({
|
||||
userId: "scope_abc",
|
||||
@@ -264,6 +264,18 @@ describe("mem0Provider", () => {
|
||||
expect(store.deleted).toEqual(["mem_1"]);
|
||||
});
|
||||
|
||||
it("reports remember as queued when the write is still pending", async () => {
|
||||
const store = createFakeStore([], { pendingWrites: true });
|
||||
const provider = mem0Provider({ store, infer: true });
|
||||
const tools = await provider.tools!(toolsContext());
|
||||
const rememberTool = tools?.remember;
|
||||
if (!rememberTool) {
|
||||
throw new Error("expected remember tool");
|
||||
}
|
||||
const remember = await runTool(rememberTool, { text: "Allergic to peanuts" });
|
||||
expect(remember).toEqual({ status: "queued", eventId: "evt_1" });
|
||||
});
|
||||
|
||||
it("refuses to forget a memory from another scope", async () => {
|
||||
const store = createFakeStore([
|
||||
{ id: "mem_other", memory: "secret", userId: "scope_other" },
|
||||
|
||||
Reference in New Issue
Block a user