Getting Started
Your First Memory
A useful memory is a durable fact, preference, constraint, or outcome that can improve a later interaction. Start small and preserve enough source context to understand it.
Choose information worth remembering
| Good candidate | Avoid |
|---|---|
| A confirmed response-style preference | A temporary instruction for one request |
| A user-approved project constraint | Passwords, tokens, or private credentials |
| A completed task outcome useful later | An entire transcript with no selection policy |
| A source-backed fact with useful metadata | Unverified model output presented as fact |
Write the record
import osfrom memorysync import MemorySyncClientclient = MemorySyncClient(api_key=os.environ["MEMORYSYNC_API_KEY"],base_url="https://api.memorysync.io",project_id=os.environ["MEMORYSYNC_PROJECT_ID"],end_user_id="user-123",)memory = client.add("The user prefers concise answers and dark mode.",source="chat",metadata={'conversation_id':'conv-42'},)
Start with these fields
| Field | Use |
|---|---|
text | The durable information future requests may need. |
source | A short application-defined origin such as chat or profile. |
metadata | Non-secret identifiers that help your app trace or filter the record. |
| Scope headers | The project and end user that own this memory context. |
Retrieve with the same scope
import osfrom memorysync import MemorySyncClientclient = MemorySyncClient(api_key=os.environ["MEMORYSYNC_API_KEY"],base_url="https://api.memorysync.io",project_id=os.environ["MEMORYSYNC_PROJECT_ID"],end_user_id="user-123",)result = client.query("How should I format the answer?", k=5)for memory in result.memories:print(memory.text)
Ask for the meaning you need, not an exact copy of the stored sentence. Semantic retrieval is designed for related wording.
Review before production
- Confirm the write policy excludes secrets and unnecessary personal data.
- Confirm the same user cannot read another user’s memory through your application.
- Preserve source metadata needed for support and deletion workflows.
- Test update, export, and forget behavior for your product’s lifecycle needs.
Was this page helpful?