Merge branch 'feat/v3-pipeline' of https://github.com/mem0ai/mem0 into feat/v3-pipeline

This commit is contained in:
Soumil Rathi
2026-04-13 13:19:34 -07:00
3 changed files with 5 additions and 16 deletions
+2 -1
View File
@@ -298,7 +298,8 @@ export default class MemoryClient {
body: JSON.stringify(payload), body: JSON.stringify(payload),
}, },
); );
return response; // Unwrap v1.1 format: { results: [...] } → [...]
return Array.isArray(response) ? response : (response?.results ?? response);
} }
async delete(memoryId: string): Promise<{ message: string }> { async delete(memoryId: string): Promise<{ message: string }> {
@@ -92,11 +92,7 @@ export async function waitForSearchResults(
maxRetries = 4, maxRetries = 4,
): Promise<Memory[]> { ): Promise<Memory[]> {
for (let attempt = 1; attempt <= maxRetries; attempt++) { for (let attempt = 1; attempt <= maxRetries; attempt++) {
const response = await withRetry(() => client.search(query, options)); const results = await withRetry(() => client.search(query, options));
// v3 returns { results: [...] }, unwrap for backward compat
const results = Array.isArray(response)
? response
: (response?.results ?? []);
if (results.length > 0) { if (results.length > 0) {
return results; return results;
} }
@@ -108,30 +108,22 @@ describeIntegration("MemoryClient Integration — Search & History", () => {
// ─── Edge cases ───────────────────────────────────────── // ─── Edge cases ─────────────────────────────────────────
describe("edge cases", () => { describe("edge cases", () => {
test("search for non-existent user returns empty results", async () => { test("search for non-existent user returns empty results", async () => {
const response = await client.search("anything", { const results = await client.search("anything", {
filters: { userId: `nonexistent-user-${randomUUID()}` }, filters: { userId: `nonexistent-user-${randomUUID()}` },
}); });
// v3 returns { results: [...] }
const results = Array.isArray(response)
? response
: (response?.results ?? []);
expect(Array.isArray(results)).toBe(true); expect(Array.isArray(results)).toBe(true);
expect(results.length).toBe(0); expect(results.length).toBe(0);
}); });
test("search with top_k param does not throw", async () => { test("search with top_k param does not throw", async () => {
const response = await client.search( const results = await client.search(
"Tell me about integration test user", "Tell me about integration test user",
{ {
filters: { userId: TEST_USER_ID }, filters: { userId: TEST_USER_ID },
topK: 1, topK: 1,
}, },
); );
// v3 returns { results: [...] }
const results = Array.isArray(response)
? response
: (response?.results ?? []);
expect(Array.isArray(results)).toBe(true); expect(Array.isArray(results)).toBe(true);
}); });