- SDK
- Memory
SDK
Memory
Enable persistent memory so your assistant remembers facts across conversations. Manage memories programmatically.
Overview
Memory lets your assistant remember facts and preferences across conversations. Memories are stored at the assistant level — to recall memories across different threads, you must use the same assistant_id.
memory is a per-turn parameter: pass it on every call where you want memory active.
Memory Modes
| Parameter | Value | Saves? | Retrieves? | Accuracy |
|---|---|---|---|---|
memory | "Auto" | Yes | Yes | Standard |
memory | "Readonly" | No | Yes | Standard |
memory | "off" | No | No | — |
memory_pro | "Auto" | Yes | Yes | Higher |
memory_pro | "Readonly" | No | Yes | Higher |
memory and memory_pro cannot be used together.
Memory Lite — Non-Streaming
Pass assistant_id to keep memories on the same assistant across threads:
Python
JavaScript
TypeScript
import asyncio
from backboard import BackboardClient
async def main():
client = BackboardClient(api_key="YOUR_API_KEY")
r1 = await client.send_message(
"My name is Sarah. I work at Google as a software engineer.",
assistant_id="your-assistant-id",
memory="Auto",
)
print(f"AI: {r1.content}")
# New thread, same assistant — memory carries over
r2 = await client.send_message(
"What do you remember about me?",
assistant_id="your-assistant-id",
memory="Auto",
)
print(f"AI: {r2.content}")
if __name__ == "__main__":
asyncio.run(main())
If you omit assistant_id, each call creates a new assistant with its own empty memory. To share memories, always pass the same assistant_id.
Memory Lite — Streaming
Python
JavaScript
TypeScript
async for chunk in await client.send_message(
"My name is Sarah. I work at Google.",
assistant_id="your-assistant-id",
memory="Auto",
stream=True,
):
if chunk.get("type") == "content_streaming":
print(chunk.get("content", ""), end="", flush=True)
print()
Memory Pro
Memory Pro provides higher-accuracy retrieval at a higher cost. Use memory_pro instead of memory:
Python
JavaScript
TypeScript
response = await client.send_message(
"What were my project deadlines?",
assistant_id="your-assistant-id",
memory_pro="Auto",
)
Readonly Mode
Retrieve saved memories without creating new ones:
response = await client.send_message(
"Tell me what you know about my preferences",
assistant_id="your-assistant-id",
memory="Readonly",
)
Manual Memory Management
List Memories
Supports pagination: page (1-indexed), page_size (1–100, default 25). Omit page to fetch all.
Python
JavaScript
TypeScript
memories = await client.get_memories(
assistant_id,
page=1,
page_size=25
)
for m in memories.memories:
print(f"[{m.id}] {m.content}")
print(f"Total: {memories.total_count}")
Add a Memory
Python
JavaScript
TypeScript
result = await client.add_memory(
assistant_id,
content="User prefers dark mode in all applications",
metadata={"source": "manual", "confidence": "high"}
)
Search Memories
Semantic search across an assistant’s memories. Returns results ranked by relevance score.
Python
JavaScript
TypeScript
results = await client.search_memories(
assistant_id,
query="user interface preferences",
limit=5
)
for m in results["memories"]:
print(f"[{m.get('score', 0):.2f}] {m['content']}")
Get, Update & Delete
Python
JavaScript
TypeScript
memory = await client.get_memory(assistant_id, memory_id)
print(memory.content)
updated = await client.update_memory(
assistant_id,
memory_id,
content="Updated preference: user prefers system theme"
)
await client.delete_memory(assistant_id, memory_id)
Reset All Memories
Delete every memory for an assistant in one call. This removes them from both the database and the vector store — irreversible.
Python
JavaScript
cURL
result = await client.reset_memories(assistant_id)
print(result["message"])
Operation Status
Memory operations can be asynchronous. The message response includes memory_operation_id when memory is active:
Python
JavaScript
TypeScript
op = await client.get_memory_operation_status(operation_id)
print(op.status) # "COMPLETED", "IN_PROGRESS", or "ERROR"