Back to Mem0

Temporal Reasoning

docs/platform/features/temporal-reasoning.mdx

2.0.162.4 KB
Original Source

Temporal Reasoning gives a ranking boost to memories whose event dates match the time in a search. Event dates are when something described in a memory happened or will happen. It runs automatically on Mem0 Platform v3.

It is not available in the OSS SDK.

Dates from new memories usually affect search within a few seconds.

Time-aware searches

Queries can include expressions such as yesterday, last week, tomorrow, currently, and as of March 2025. Mem0 compares them with dates and date ranges found in stored memories.

Example

Suppose a user has these memories:

  • "Yesterday I met Maya at the Orion conference in Paris."
  • "Last week I met Maya at the Orion conference in Tokyo."
  • "Last year I met Maya at the Orion conference in Lisbon."

Searching for Which city did I meet Maya in at the Orion conference last week? gives the Tokyo memory a temporal boost and ranks it first.

<CodeGroup> ```python Python results = client.search( "Which city did I meet Maya in at the Orion conference last week?", filters={"user_id": "maya-demo"}, ) ```
javascript
const results = await client.search(
  "Which city did I meet Maya in at the Orion conference last week?",
  { filters: { user_id: "maya-demo" } }
);
</CodeGroup>

Search returns the usual memory results, reordered using the temporal boost.

Search from a specific time

Use reference_date to simulate searching at a specific date and time. Mem0 treats it as the current time for that search.

<CodeGroup> ```python Python results = client.search( "What happened last week?", filters={"user_id": "user-123"}, reference_date="2025-03-21T00:00:00Z", ) ```
javascript
const results = await client.search("What happened last week?", {
  filters: { user_id: "user-123" },
  referenceDate: "2025-03-21T00:00:00Z",
});
</CodeGroup>

Parameters

ActionPythonTypeScriptPurpose
Add memoriestimestamptimestampPreserve the original time of an imported conversation.
Search memoriesreference_datereferenceDateSimulate searching at a specific date and time.

For all search inputs and returned fields, see the Search Memories API reference.

<CardGroup cols={1}> <Card title="Memory Timestamps" icon="calendar" href="/platform/features/timestamp"> Preserve the original time of imported memories. </Card> </CardGroup> <Snippet file="get-help.mdx" />