chore: update user facing timestamp for a memory (#4066)

This commit is contained in:
Mragank Shekhar
2026-02-18 03:27:46 +05:30
committed by GitHub
parent a6810819ca
commit a140829395
6 changed files with 69 additions and 23 deletions
+16
View File
@@ -7,6 +7,14 @@ mode: "wide"
<Tabs>
<Tab title="Python">
<Update label="2026-02-17" description="v1.0.4">
**New Features & Updates:**
- **Memory Update:**
- Added `timestamp` parameter to `update()` — accepts Unix epoch (int/float) or ISO 8601 string
</Update>
<Update label="2026-01-29" description="v1.0.3">
**New Features & Updates:**
@@ -716,6 +724,14 @@ mode: "wide"
<Tab title="TypeScript">
<Update label="2026-02-17" description="v2.2.3">
**New Features & Updates:**
- **Memory Update:**
- Added `timestamp` parameter to `update()` — accepts Unix epoch or ISO 8601 string
</Update>
<Update label="2026-01-29" description="v2.2.2">
**New Features & Updates:**
@@ -21,6 +21,7 @@ Mem0’s update operation lets you fix or enrich an existing memory without dele
- **memory_id** – Unique identifier returned by `add` or `search` results.
- **text** / **data** – New content that replaces the stored memory value.
- **metadata** – Optional key-value pairs you update alongside the text.
- **timestamp** – Unix epoch (int/float) or ISO 8601 string to override the memory's timestamp.
- **batch_update** – Platform API that edits multiple memories in a single request.
- **immutable** – Flagged memories that must be deleted and re-added instead of updated.
@@ -50,7 +51,8 @@ memory_id = "your_memory_id"
client.update(
memory_id=memory_id,
text="Updated memory content about the user",
metadata={"category": "profile-update"}
metadata={"category": "profile-update"},
timestamp="2025-01-15T12:00:00Z"
)
```
@@ -62,7 +64,8 @@ const memory_id = "your_memory_id";
await client.update(memory_id, {
text: "Updated memory content about the user",
metadata: { category: "profile-update" }
metadata: { category: "profile-update" },
timestamp: "2025-01-15T12:00:00Z"
});
```
</CodeGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "mem0ai",
"version": "2.2.2",
"version": "2.2.3",
"description": "The Memory Layer For Your AI Apps",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
+21 -7
View File
@@ -253,18 +253,32 @@ export default class MemoryClient {
async update(
memoryId: string,
{ text, metadata }: { text?: string; metadata?: Record<string, any> },
{
text,
metadata,
timestamp,
}: {
text?: string;
metadata?: Record<string, any>;
timestamp?: number | string;
},
): Promise<Array<Memory>> {
if (text === undefined && metadata === undefined) {
throw new Error("Either text or metadata must be provided for update.");
if (
text === undefined &&
metadata === undefined &&
timestamp === undefined
) {
throw new Error(
"At least one of text, metadata, or timestamp must be provided for update.",
);
}
if (this.telemetryId === "") await this.ping();
this._validateOrgProject();
const payload = {
text: text,
metadata: metadata,
};
const payload: Record<string, any> = {};
if (text !== undefined) payload.text = text;
if (metadata !== undefined) payload.metadata = metadata;
if (timestamp !== undefined) payload.timestamp = timestamp;
const payloadKeys = Object.keys(payload);
this._captureEvent("update", [payloadKeys]);
+25 -12
View File
@@ -2,7 +2,7 @@ import hashlib
import logging
import os
import warnings
from typing import Any, Dict, List, Optional
from typing import Any, Dict, List, Optional, Union
import httpx
import requests
@@ -300,29 +300,34 @@ class MemoryClient:
memory_id: str,
text: Optional[str] = None,
metadata: Optional[Dict[str, Any]] = None,
timestamp: Optional[Union[int, float, str]] = None,
) -> Dict[str, Any]:
"""
Update a memory by ID.
Args:
memory_id (str): Memory ID.
text (str, optional): New content to update the memory with.
metadata (dict, optional): Metadata to update in the memory.
timestamp (int, float, or str, optional): Unix epoch timestamp or ISO 8601 string.
Returns:
Dict[str, Any]: The response from the server.
Example:
>>> client.update(memory_id="mem_123", text="Likes to play tennis on weekends")
>>> client.update(memory_id="mem_123", timestamp="2025-01-15T12:00:00Z")
"""
if text is None and metadata is None:
raise ValueError("Either text or metadata must be provided for update.")
if text is None and metadata is None and timestamp is None:
raise ValueError("At least one of text, metadata, or timestamp must be provided for update.")
payload = {}
if text is not None:
payload["text"] = text
if metadata is not None:
payload["metadata"] = metadata
if timestamp is not None:
payload["timestamp"] = timestamp
capture_client_event("client.update", self, {"memory_id": memory_id, "sync_type": "sync"})
params = self._prepare_params()
@@ -1196,30 +1201,38 @@ class AsyncMemoryClient:
@api_error_handler
async def update(
self, memory_id: str, text: Optional[str] = None, metadata: Optional[Dict[str, Any]] = None
self,
memory_id: str,
text: Optional[str] = None,
metadata: Optional[Dict[str, Any]] = None,
timestamp: Optional[Union[int, float, str]] = None,
) -> Dict[str, Any]:
"""
Update a memory by ID asynchronously.
Args:
memory_id (str): Memory ID.
text (str, optional): New content to update the memory with.
metadata (dict, optional): Metadata to update in the memory.
timestamp (int, float, or str, optional): Unix epoch timestamp or ISO 8601 string.
Returns:
Dict[str, Any]: The response from the server.
Example:
>>> await client.update(memory_id="mem_123", text="Likes to play tennis on weekends")
>>> await client.update(memory_id="mem_123", timestamp="2025-01-15T12:00:00Z")
"""
if text is None and metadata is None:
raise ValueError("Either text or metadata must be provided for update.")
if text is None and metadata is None and timestamp is None:
raise ValueError("At least one of text, metadata, or timestamp must be provided for update.")
payload = {}
if text is not None:
payload["text"] = text
if metadata is not None:
payload["metadata"] = metadata
if timestamp is not None:
payload["timestamp"] = timestamp
capture_client_event("client.update", self, {"memory_id": memory_id, "sync_type": "async"})
params = self._prepare_params()
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "mem0ai"
version = "1.0.3"
version = "1.0.4"
description = "Long-term memory for AI Agents"
authors = [
{ name = "Mem0", email = "founders@mem0.ai" }