llama-index-memory-unison
Long-term agent memory for LlamaIndex — powered by the Unison brain.
Drop in wherever you'd use ChatMemoryBuffer. Agents get persistent,
knowledge-graph-powered recall across sessions with zero infrastructure changes.
Install • Quick start • Replacing ChatMemoryBuffer • How it works • For agents
Reading this as an AI agent? See
AGENTS.md— install, auth, andUnisonMemory.from_client(session_id=...)usage in one place.
Install
pip install llama-index-memory-unison
Quick start
import os
from llama_index.memory.unison import UnisonMemory
from llama_index.core.agent import ReActAgent
from llama_index.llms.openai import OpenAI
# Build Unison memory for this user/session
memory = UnisonMemory.from_client(
session_id="user-123", # stable per-user or per-thread ID
api_key="usk_live_...", # or set UNISON_TOKEN env var
# api_url="https://brain.unisonlabs.ai", # default
# search_k=5, # hits per recall
)
# Pass it to any LlamaIndex agent or chat engine
llm = OpenAI(model="gpt-4o", api_key=os.environ["OPENAI_API_KEY"])
agent = ReActAgent.from_tools([], llm=llm, memory=memory, verbose=True)
# Subsequent calls automatically recall relevant long-term context
response = agent.chat("What did we discuss last week about Alice?")
print(response)
Replacing ChatMemoryBuffer
# Before
from llama_index.core.memory import ChatMemoryBuffer
memory = ChatMemoryBuffer.from_defaults(token_limit=3000)
# After — drop-in replacement with long-term recall
from llama_index.memory.unison import UnisonMemory
memory = UnisonMemory.from_client(session_id="user-123", api_key="usk_live_...")
Using environment variables
export UNISON_TOKEN="usk_live_..."
export UNISON_API_URL="https://brain.unisonlabs.ai" # optional, this is the default
from llama_index.memory.unison import UnisonMemory
# Reads UNISON_TOKEN and UNISON_API_URL automatically
memory = UnisonMemory.from_defaults(session_id="user-123")
Environment variables
| Variable | Description | Default |
|---|---|---|
UNISON_TOKEN |
Unison API token (usk_live_...) |
Required |
UNISON_API_URL |
Unison brain base URL | https://brain.unisonlabs.ai |
How it works
| LlamaIndex call | What UnisonMemory does |
|---|---|
put(message) |
Appends to a local in-session buffer and POSTs the turn to POST /v1/brain/ingest. Ingestion is async on the Unison side — entity resolution and fact extraction happen server-side. |
get(input=query) |
Fetches GET /v1/brain/context?q=<query> and, if the brain has relevant hits (weakEvidence=false), prepends a SYSTEM message containing the recalled contextMd block ahead of the local buffer. |
get_all() |
Returns the raw local buffer only (no recall). |
set(messages) |
Replaces the local buffer. Server memory is not modified. |
reset() |
Clears the local buffer. Server memory is not deleted. |
Network errors are caught and logged; they never crash the agent.
Releasing
Set a PyPI token, then run one command:
export TWINE_USERNAME=__token__
export TWINE_PASSWORD=pypi-...
python3 scripts/release.py
Or configure ~/.pypirc instead of the env vars.
The script builds llama-index-memory-unison, publishes to PyPI (idempotent — skips if the version is already on PyPI), then tags and pushes v<version>.
Links
- Unison brain: https://unisonlabs.ai
- Docs: https://docs.unisonlabs.ai
- Unison brain repo: https://github.com/unison-labs-ai/unison-brain
- LlamaIndex memory docs: https://docs.llamaindex.ai/en/stable/module_guides/storing/chat_stores/
Contributing & security
Contributions welcome — see CONTRIBUTING.md. Found a vulnerability? See SECURITY.md — please report privately, not via a public issue.
Part of the Unison Labs constellation
One brain, every agent. Every repo below reads from and writes to the same Unison brain — no per-tool memory silos.
| Repo | What it does |
|---|---|
| unison-brain | CLI · SDK · MCP server — the core |
| claude-unison | Memory for Claude Code |
| cursor-unison | Memory for Cursor |
| codex-unison | Memory for OpenAI Codex CLI |
| opencode-unison | Memory for OpenCode |
| openclaw-unison | Memory for OpenClaw |
| pipecat-unison | Memory for Pipecat voice agents |
| langchain-unison | LangChain memory, history & retriever |
| llama-index-memory-unison | LlamaIndex memory provider ← you are here |
| unison-ai-sdk | Vercel AI SDK memory middleware |
| unison-mastra | Mastra agent memory provider |
| python-sdk | Python SDK for the brain |
| install-mcp | One-command MCP installer |
| unison-fs | Mount the brain as a filesystem |
| backchannel | Async messaging between agents |
| Unison-evals | Open memory benchmark suite |
License
MIT — see LICENSE.
Metadata
Release files for llama-index-memory-unison 0.1.1
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 | Actions |
|---|---|---|---|---|
| llama_index_memory_unison-0.1.1.tar.gz | 9.3 kB | Without provenance | Details for llama_index_memory_unison-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llama_index_memory_unison-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for llama_index_memory_unison-0.1.1-py3-none-any.whl |
Total release size: 19.0 kB
Release files / llama_index_memory_unison-0.1.1.tar.gz
| Download URL | llama_index_memory_unison-0.1.1.tar.gz |
|---|---|
| Size | 9.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5bfe6a9e6242b87ef1092ebc90376ce7f12b2050496af4d256bdc1bd36796b25
|
|
BLAKE2b-256 checksum How to use checksums |
8435f980ac957be8400444879c93cd7aa92aca800371897a2ee8c4aa1b4b9cb7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / llama_index_memory_unison-0.1.1-py3-none-any.whl
| Download URL | llama_index_memory_unison-0.1.1-py3-none-any.whl |
|---|---|
| Size | 9.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8b9943406148e6dd792fdf4c6ae6ad4f03fffaf9da03f1d38e177f9eefcc343a
|
|
BLAKE2b-256 checksum How to use checksums |
11a04f57af7460d52b8ed746eb40b1c450a1c4c2582159520357680736245484
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Security for llama-index-memory-unison 0.1.1
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.