The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.
Python agentic-memoryagentic-memory-systemagentsaiai-agentschatgptgenaillmlong-term-memorymemorymemory-managementpythonragstate-management
feat(ts): expose latestOnly on hosted memory reads (#5153)
Chaithanya Kumarddee5f867150
diff --git a/mem0-ts/src/client/mem0.types.ts b/mem0-ts/src/client/mem0.types.tsindex afd5b663d..0c5c1c93f 100644--- a/mem0-ts/src/client/mem0.types.ts+++ b/mem0-ts/src/client/mem0.types.ts@@ -22,6 +22,7 @@ export interface SearchMemoryOptions {topK?: number;threshold?: number;rerank?: boolean;+ latestOnly?: boolean;fields?: string[];categories?: string[];}@@ -32,6 +33,7 @@ export interface GetAllMemoryOptions {pageSize?: number;startDate?: string;endDate?: string;+ latestOnly?: boolean;categories?: string[];}diff --git a/mem0-ts/src/client/tests/memoryClient.search.test.ts b/mem0-ts/src/client/tests/memoryClient.search.test.tsindex 649b53563..f2f1ef32e 100644--- a/mem0-ts/src/client/tests/memoryClient.search.test.ts+++ b/mem0-ts/src/client/tests/memoryClient.search.test.ts@@ -63,6 +63,24 @@ describe("MemoryClient - search()", () => {expect(getFetchBody(call!).filters).toEqual({ user_id: "u1" });});+ test("serializes latestOnly as latest_only", async () => {+ const extra = new Map<string, { status: number; body: unknown }>();+ extra.set("/v3/memories/search/", {+ status: 200,+ body: { results: [] },+ });+ const mock = setupMockFetch(extra);++ const client = new MemoryClient({ apiKey: TEST_API_KEY });+ await client.search("test", {+ filters: { user_id: "u1" },+ latestOnly: true,+ });++ const call = findFetchCall(mock, "/v3/memories/search/", "POST");+ expect(getFetchBody(call!).latest_only).toBe(true);+ });+test("passes complex OR filters through to the API body", async () => {const extra = new Map<string, { status: number; body: unknown }>();extra.set("/v3/memories/search/", {@@ -264,4 +282,22 @@ describe("MemoryClient - getAll() entity param rejection", () => {await client.getAll({ filters: { user_id: "u1" } });expect(findFetchCall(mock, "/v3/memories/", "POST")).toBeDefined();});++ test("serializes latestOnly as latest_only", async () => {+ const extra = new Map<string, { status: number; body: unknown }>();+ extra.set("/v3/memories/", {+ status: 200,+ body: { results: [] },+ });+ const mock = setupMockFetch(extra);++ const client = new MemoryClient({ apiKey: TEST_API_KEY });+ await client.getAll({+ filters: { user_id: "u1" },+ latestOnly: true,+ });++ const call = findFetchCall(mock, "/v3/memories/", "POST");+ expect(getFetchBody(call!).latest_only).toBe(true);+ });});