Skip to Content

Core Concepts

Recall memory

Ask a memory space a question with Lynk and get back the most relevant, current memories.

lynk.recall takes a question in plain words and returns the memories that answer it, best first. You don't need to match the stored text or know which memories exist.

Recall memories

This example asks one question and prints what comes back:

from docklee import Lynk

lynk = Lynk()
records = lynk.recall_sync("How does Maya like to be contacted?", top_k=5)
for record in records:
    print(record.confidence, record.content)

The API returns a list, best match first:

[
  {
    "id": "9b1e7c42-5d3a-4f08-b6e2-1a7c0d93e5f4",
    "content": "Maya now prefers phone calls.",
    "memory_type": "entity",
    "confidence_score": 0.91
  },
  {
    "id": "e47a03d9-2c18-4b6f-8e5a-7f1d9c2b0a36",
    "content": "Maya moved from Austin to Denver last month.",
    "memory_type": "entity",
    "confidence_score": 0.64
  }
]

The older email preference isn't in the list. It was replaced by the newer one, so recall returns only the current value.

recall options

OptionPythonTypeScriptDefaultDescription
Queryqueryfirst argumentnoneThe question, in plain words.
Memory spacememory_space_idmemorySpaceIdDOCKLEE_MEMORY_SPACE_IDThe space to read for this call.
Result counttop_ktopK5How many memories to return, from 1 to 50.
End userend_userendUserDOCKLEE_END_USERReturns only that person's memories. Required in a multi-user space.

The memory record

PythonTypeScriptDescription
memory_idmemoryIdThe memory's ID.
contentcontentThe remembered text.
memory_typememoryTypeThe storage class of the memory. See Memory types.
confidenceconfidenceHow strongly this memory answers the query, from 0 to 1.

Sync and async

In Python, recall is async and recall_sync blocks. Use the one that matches your code:

records = await lynk.recall("What plan is the customer on?")
records = lynk.recall_sync("What plan is the customer on?")

Use memories in a prompt

Join the recalled memories into a short block above the user's message:

records = lynk.recall_sync(user_message, end_user=user_id)
known = "\n".join(f"- {record.content}" for record in records)
prompt = f"What you know about this user:\n{known}\n\nUser: {user_message}"

Recall before your model replies, and capture after. Each turn then starts with what your app already knows and adds what it just learned.

Next steps

You can read memories back. Learn how Docklee picks which ones to return.

On this page