llamaindex-memorysync
Long-term memory for LlamaIndex, backed by MemorySync — a Memory subclass that sends every user turn to MemorySync the moment it happens, native memory-block recall, a genuine retriever for RAG, and agent memory tools.
MemorySyncMemory— LlamaIndex'sMemorywith durable server-side long-term memory foragent.run(..., memory=...).MemorySyncMemoryBlock— the recall block alone (it also sends the user messages the buffer flushes into it), for composing into your ownMemory.MemorySyncRetriever— memories as a genuineBaseRetrieverfor query engines and retriever tools.- Five agent tools + sync helpers — add/search/list/update/delete tools that never raise;
get_memory_context,search_memories,save_turn.
pip install llamaindex-memorysync
Set MEMORYSYNC_API_KEY in the environment (create a key at app.memorysync.io), or pass api_key explicitly. Requires llama-index-core >=0.13 <0.15, Python 3.10+.
The upgraded Memory
from llama_index.core.agent.workflow import FunctionAgent
from llamaindex_memorysync import MemorySyncMemory
memory = MemorySyncMemory.from_defaults(
user_id="customer-7", # per-end-user scoping — required
session_id="thread-42", # groups the stored facts by thread
)
agent = FunctionAgent(tools=[...], llm=llm)
# First conversation
await agent.run("I'm vegetarian and I fly aisle.", memory=memory)
# Any later run — same user, any thread, any deploy
response = await agent.run("Book my trip.", memory=memory)
# The model already saw: vegetarian, aisle seat — injected from memory.
The waterfall trap, fixed. LlamaIndex memory blocks only receive messages when the short-term buffer overflows its token budget (~21k tokens on the defaults) — so a block-only integration silently sends NOTHING for most real conversations. MemorySyncMemory sends every user message the moment it is aput; MemorySync extracts the durable facts in it and stores only those, and filler ("ok", "thanks") stores nothing. The flush path still works, and shared speaker seeds mean a turn sent on both paths is recognised server-side and extracted once.
Everything Memory does still works — token_limit, insert_method, your own additional blocks — because this IS a Memory, not a wrapper. from_defaults works, async-native end to end, and serialization never leaks the API key. Only the user's messages are sent to MemorySync; assistant replies are not stored as memories, and they stay in the short-term buffer along with system prompts and tool traffic. Memory failures never break the turn: the buffer write happens first, the MemorySync write degrades through on_error.
Or compose the block
from llama_index.core.memory import Memory
from llamaindex_memorysync import MemorySyncMemoryBlock
memory = Memory.from_defaults(
session_id="thread-42",
memory_blocks=[MemorySyncMemoryBlock(user_id="customer-7")],
)
Recall renders into the framework's own <memory> template with query/profile/full modes. Under token pressure, atruncate drops the lowest-value lines — the framework default deletes the whole block.
Memories as a retriever
from llama_index.core.query_engine import RetrieverQueryEngine
from llama_index.core.tools import RetrieverTool
from llamaindex_memorysync import MemorySyncRetriever
retriever = MemorySyncRetriever(user_id="customer-7", similarity_top_k=5)
nodes = retriever.retrieve("dietary preferences")
engine = RetrieverQueryEngine.from_args(retriever=retriever, llm=llm)
tool = RetrieverTool.from_defaults(retriever=retriever, name="memory_search",
description="Search everything known about this user.")
Raises on API failure rather than returning an empty list — "no memories" and "the memory service errored" must never look identical to a RAG pipeline.
Agent tools
from llamaindex_memorysync import create_memorysync_tools
agent = FunctionAgent(
tools=create_memorysync_tools(user_id="customer-7"),
llm=llm,
)
# Untrusted agents: search + list only.
create_memorysync_tools(user_id="customer-7", read_only=True)
Same five operations, same response strings as the MemorySync LangChain, AI SDK, CrewAI, Mastra and OpenAI Agents tool sets.
Helpers
from llamaindex_memorysync import get_memory_context, save_turn, search_memories
context = get_memory_context("what should I cook?", user_id="customer-7")
hits = search_memories("dietary preferences", user_id="customer-7")
save_turn(user_id="customer-7", user="I'm vegetarian", assistant="Noted!")
All surfaces share the same speaker seeds, so a turn sent through two of them is recognised server-side and extracted once. save_turn sends only the user message — assistant is accepted and not sent, because assistant replies are not stored as memories — and raises on failure.
Version support
| Package | Requires | Runtime |
|---|---|---|
llamaindex-memorysync 1.1.0 |
llama-index-core >=0.13 <0.15 |
Python 3.10+ |
CI exercises the real memory machinery — waterfall flush, block template, RetrieverQueryEngine — against the latest core release within the supported range on every push.
Documentation
Metadata
Release files for llamaindex-memorysync 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| llamaindex_memorysync-1.1.0.tar.gz | 16.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| llamaindex_memorysync-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 37.1 kB
Release files / llamaindex_memorysync-1.1.0.tar.gz
| Download URL | llamaindex_memorysync-1.1.0.tar.gz |
|---|---|
| Size | 16.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
af682568fc642b3450f114be8ac11d191949c6c7871e18f5bdfd1942fde8cdcd
|
|
BLAKE2b-256 checksum How to use checksums |
a0ace1f608d023373885e42d2c1a96b552d2429854d536eab6ffa8fc73e246bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.5
|
Release files / llamaindex_memorysync-1.1.0-py3-none-any.whl
| Download URL | llamaindex_memorysync-1.1.0-py3-none-any.whl |
|---|---|
| Size | 21.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dc4c401da98c82f6de061e618a0d9b77562360da39b33f57bd44676c569b1627
|
|
BLAKE2b-256 checksum How to use checksums |
8d8c52544b2f8f59556ff80d55715cbdeb12c862b30c58646aaf1ec63e36cc2b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.5
|
Security for llamaindex-memorysync 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.