Recall Quickstart for Python
Native PyO3 binding. Async-first; use the sync wrapper if you're not in an async context. Requires Python 3.10+.
Install
bash
pip install recall
# or with uv:
# uv add recall
# or with poetry:
# poetry add recallInitialize
python
from recall import Recall
recall = Recall(
store={"type": "sqlite", "path": "./recall.db"},
# For production:
# store={"type": "postgres", "url": os.environ["DATABASE_URL"]},
)Write a memory
python
await recall.write(
scope={"user_id": "u_alice"},
source={
"turn": {
"user": "I prefer dark mode in my IDE — light themes hurt my eyes.",
"assistant": "Noted — I'll default to dark mode for editor recommendations.",
},
},
)
# The 7-stage pipeline runs:
# pre-filter → extract → classify → resolve → dedupe → conflict → persist
# Result: 1 preference stored ("user prefers dark mode in IDE", confidence 0.93)Retrieve
python
results = await recall.search(
scope={"user_id": "u_alice"},
query="what theme should I use?",
limit=10,
)
print(results[0])
# Memory(
# id='mem_01H...',
# type='preference',
# content='user prefers dark mode in IDE',
# confidence=0.93,
# score=0.91,
# freshness=1.0,
# )Render into a prompt
python
ctx = await recall.context(
scope={"user_id": "u_alice"},
query=user_message,
budget=1500, # tokens
)
# ctx.render("structured") produces:
# memories.preferences:
# - [mem_01H...] user prefers dark mode in IDE (conf 0.93)
# memories.facts: []
response = await openai.chat.completions.create(
model="gpt-4.1",
messages=[
{
"role": "system",
"content": f"You have these memories about the user:\n{ctx.render('structured')}",
},
{"role": "user", "content": user_message},
],
)Sync wrapper if you're not async
Most production agent code is async. If yours isn't yet, use the sync wrapper:
python
from recall.sync import Recall
recall = Recall(store={"type": "sqlite", "path": "./recall.db"})
recall.write(scope={"user_id": "u_alice"}, source={...})
results = recall.search(scope={"user_id": "u_alice"}, query="...")Type stubs included
The package ships .pyi stubs. Pyright and mypy both pick them up.
python
from recall import Memory, MemoryType, RecallError
def describe(m: Memory) -> str:
if m.type == MemoryType.PREFERENCE:
return f"User prefers {m.content}"
if m.type == MemoryType.FACT:
return f"Fact: {m.content}"
# ...Done.
You have a working memory layer in Python. Continue with the docs for production patterns, or browse the Learn track for architecture deep-dives.