An Extension of fabricatio aiming to extend the context llm could handle.
Project description
fabricatio-memory
Memory management for Fabricatio agents — persistent, searchable long-term memory backed by a Tantivy full-text index in Rust.
Installation
pip install fabricatio[memory]
# or
uv pip install fabricatio[memory]
For a full installation including all optional packages:
pip install fabricatio[full]
# or
uv pip install fabricatio[full]
Overview
fabricatio-memory provides a persistent memory system for LLM agents. It combines a Rust-backed Tantivy search engine with Python-level agent capabilities to record, search, and recall information across sessions.
Memories are stored in named stores (independent Tantivy indexes). Each memory carries content, an importance score, tags, and is tracked for access frequency and recency — enabling relevance-boosted retrieval.
The Python layer wraps recording and recall through LLM integration: raw text is structured into a Note by the agent's LLM before storage, and recall queries return LLM-summarized results from the top matching memories.
Architecture
Python (capabilities) Rust (storage engine)
┌─────────────────────┐ ┌──────────────────────┐
│ Remember │──▶ │ MemoryStore │
│ .record(raw) │ │ .add_memory() │
│ .recall(query) │ │ .search_memories() │
│ SelectiveRemember │ │ .get_memory() │
│ .sremember(…) │ │ .update_memory() │
└─────────────────────┘ │ .stats() │
└──────────────────────┘
│
┌──────────────────────┐
│ MemoryService │
│ .get_store(name) │
│ .list_stores() │
└──────────────────────┘
Key APIs
Rust backend (fabricatio_memory.rust)
| Type | Description |
|---|---|
Memory |
A single memory entry: uuid, content, timestamp, importance (0–100), tags, access_count, last_accessed. |
MemoryService(root, buffer_size, cache_size) |
Manages named stores. Creates/opens Tantivy indexes under root. |
MemoryStore |
CRUD and search on one index. |
MemoryStats |
Aggregated metrics: total_memories, avg_importance, avg_access_count, avg_age_days. |
MemoryStore methods:
| Method | Description |
|---|---|
add_memory(content, importance, tags) |
Store a new memory; returns its UUID. |
get_memory(uuid) |
Retrieve by ID (updates access count). |
update_memory(uuid, content?, importance?, tags?) |
Update fields; returns True if found. |
delete_memory(uuid) |
Delete by ID. |
search_memories(query, top_k, boost_recent) |
Full-text search, optionally boosting recent entries. |
search_by_tags(tags, top_k) |
Filter by tags (OR semantics). |
get_memories_by_importance(min, top_k) |
Filter by minimum importance. |
get_recent_memories(days, top_k) |
Memories from the last N days. |
get_frequently_accessed(top_k) |
Most-accessed memories first. |
count_memories() |
Total stored documents. |
stats() |
Aggregated MemoryStats. |
write() |
Flush pending writes to disk. |
All mutation methods accept an optional write=False parameter; when False, changes are buffered for performance. Call write() to commit.
Python capabilities (fabricatio_memory.capabilities)
| Class | Description |
|---|---|
Remember |
Mixin providing record() and recall(). Uses the agent's LLM to structure raw text into a Note (content + importance + tags), then stores it. Recall searches the store and summarizes results via LLM. |
SelectiveRemember |
Extends Remember with sremember() — conditionally records only when a judgment (powered by fabricatio-judge) deems the information worth keeping. |
Models (fabricatio_memory.models)
| Class | Fields |
|---|---|
Note |
content: str, importance: int (0–100), tags: List[str]. Pydantic model; LLM output target for record(). |
Configuration (fabricatio_memory.config)
MemoryConfig controls template paths, store root directory (~/.fabricatio-memory by default), writer buffer size (50 MB default), and index cache size (10 stores).
Service singleton (fabricatio_memory.inited_memory_service)
get_memory_service() returns a lazily-initialized MemoryService using the global MemoryConfig.
Usage
Direct store operations
from fabricatio_memory.rust import MemoryService
service = MemoryService("/path/to/store_root")
store = service.get_store("my_agent")
# Store a memory
mem_id = store.add_memory("User prefers dark mode", importance=70, tags=["preferences", "ui"])
# Search
results = store.search_memories("dark mode", top_k=5, boost_recent=True)
for mem in results:
print(f"{mem.uuid}: {mem.content} (importance={mem.importance})")
# Stats
stats = store.stats()
print(stats.display())
# total: 42, avg importance: 55.3, avg access: 3.1, avg age: 12.4d
# Commit buffered writes
store.write()
Agent capability (LLM-integrated)
from fabricatio_memory.capabilities.remember import Remember
from fabricatio_memory.inited_memory_service import get_memory_service
class MyAgent(Remember, SomeBaseAgent):
...
agent = MyAgent(memory_store_name="agent_memories")
agent.mount_memory_store()
# Record — LLM extracts structured Note from raw text
note = await agent.record("The user said their name is Alice and they work at Acme Corp.")
# note.content = "User name is Alice, works at Acme Corp."
# note.importance = 60
# note.tags = ["user_info", "employment"]
# Recall — semantic search + LLM summarization
summary = await agent.recall("What do we know about Alice?")
# summary = "Alice works at Acme Corp. She prefers dark mode."
Selective memory
from fabricatio_memory.capabilities.selective_remember import SelectiveRemember
class MyAgent(SelectiveRemember, SomeBaseAgent):
...
# Only record if the agent judges it's worth remembering
note = await agent.sremember(
prerequisite="Only remember if this contains personal user information",
raw="The weather is sunny today."
)
# note is None — weather isn't personal info
Dependencies
fabricatio-core— core interfaces, configuration, template management- Optional:
fabricatio-judge— required bySelectiveRememberfor conditional recording
License
MIT — see LICENSE
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fabricatio_memory-0.3.6-cp314-cp314-win_amd64.whl.
File metadata
- Download URL: fabricatio_memory-0.3.6-cp314-cp314-win_amd64.whl
- Upload date:
- Size: 6.0 MB
- Tags: CPython 3.14, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24805721c93177bd002741f9011b9d3ecafd7e097ffb24367adb500faa7f0643
|
|
| MD5 |
cd249fd514c721c3f2558ff82fc9f821
|
|
| BLAKE2b-256 |
ad7266c37f493f089072b29aee78386440ceca654009320db9792f467f679b1e
|
File details
Details for the file fabricatio_memory-0.3.6-cp314-cp314-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: fabricatio_memory-0.3.6-cp314-cp314-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 6.5 MB
- Tags: CPython 3.14, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e34f71bff729254d777067e3a3fd97952c392683b0de3ee607d7a830cf4168c1
|
|
| MD5 |
d5e16b8be7dcf96660a0a16e18773eca
|
|
| BLAKE2b-256 |
165677689dfc4b03b952c8e8a29254160e2f7f0361549f646651f8a42f0cb9d5
|
File details
Details for the file fabricatio_memory-0.3.6-cp314-cp314-manylinux_2_34_aarch64.whl.
File metadata
- Download URL: fabricatio_memory-0.3.6-cp314-cp314-manylinux_2_34_aarch64.whl
- Upload date:
- Size: 5.9 MB
- Tags: CPython 3.14, manylinux: glibc 2.34+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fee83eadf9bdd5674fe54d31cd6e28649fa9ffaa56fad5adb2f1f4541c39c057
|
|
| MD5 |
f9ebdb811ee062dcb8183c93da9941c6
|
|
| BLAKE2b-256 |
904b15b529dfd0bfd14c9852b1397be571e8b2662ba4bd7e2290884c79a9256a
|
File details
Details for the file fabricatio_memory-0.3.6-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: fabricatio_memory-0.3.6-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 6.0 MB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3961b9a9652ff71febcb8221c73178995bad121d7b79ba0387478496f89b047
|
|
| MD5 |
2c8eb7ffcf728933f287c4244624443f
|
|
| BLAKE2b-256 |
4eaf009de9454a5e11eae80bd9469c0ee9c2333f5a4b77745401b1999a485780
|
File details
Details for the file fabricatio_memory-0.3.6-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: fabricatio_memory-0.3.6-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 6.0 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f3bf0d35da17cbcc6dfb3df03df21969f042cca8212440fddf0ae7bdd824158
|
|
| MD5 |
6da35e28853f86c749dfea38a6ae5131
|
|
| BLAKE2b-256 |
86c6e692bb66852a78efc90a503b530cb8f88cf4ed7811c4a1bf68afba4dde49
|
File details
Details for the file fabricatio_memory-0.3.6-cp313-cp313-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: fabricatio_memory-0.3.6-cp313-cp313-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 6.5 MB
- Tags: CPython 3.13, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b24ec566d1ce05c9ca9ff2c3c1fd86cdd3dff04a9681d8ac2ced885cd61fda7d
|
|
| MD5 |
75219ffd9a95dbb6d7fa0c7c5a7ed50c
|
|
| BLAKE2b-256 |
c31ac22e7b771d7d1e8091fa08ee3e31e9d77f697fb4a96666b6b7dd69f4e208
|
File details
Details for the file fabricatio_memory-0.3.6-cp313-cp313-manylinux_2_34_aarch64.whl.
File metadata
- Download URL: fabricatio_memory-0.3.6-cp313-cp313-manylinux_2_34_aarch64.whl
- Upload date:
- Size: 5.9 MB
- Tags: CPython 3.13, manylinux: glibc 2.34+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa286fef86f840f4f710c5139fe37730c2ebd077b1d990dbfc581f41b978480c
|
|
| MD5 |
cf4d198538052ff09962201fd5008419
|
|
| BLAKE2b-256 |
e5effc4e0a8285b5996d2a1da75898ddee06d78bf98d5c93540a6c5a882a098b
|
File details
Details for the file fabricatio_memory-0.3.6-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: fabricatio_memory-0.3.6-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 6.0 MB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5987dc383752c98cfa30b192e678880b96ad0fec905240f508d55f968250558f
|
|
| MD5 |
ef68a347a5afcf214a8d2bd9f7854620
|
|
| BLAKE2b-256 |
4e2e1cf3e5535406e4195276714092e8ebadd8709bf4c8d33f36cac3f9ac5b23
|
File details
Details for the file fabricatio_memory-0.3.6-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: fabricatio_memory-0.3.6-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 6.0 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df1e9bb0e90307d2c3782887607775c6a2e02626d3bb01a8578efd566dd3b9f9
|
|
| MD5 |
04b8d1e8696e1f60a13f9ccf675f55f3
|
|
| BLAKE2b-256 |
0bfa1cd1c548f08de559b98051b6de59ea41a1a178c3621c92257fa04b0a033c
|
File details
Details for the file fabricatio_memory-0.3.6-cp312-cp312-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: fabricatio_memory-0.3.6-cp312-cp312-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 6.5 MB
- Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3a2a53a126ce866b5e4092e4c826c4e14a0c1ec76e90352b48b559c98c8a26c
|
|
| MD5 |
2b54fe461d45f4009f09216b2dc23dbc
|
|
| BLAKE2b-256 |
98e5188e9994bf0a0f42534ca4bc88a715428eef3e4de0e4df2baf2146c9fccd
|
File details
Details for the file fabricatio_memory-0.3.6-cp312-cp312-manylinux_2_34_aarch64.whl.
File metadata
- Download URL: fabricatio_memory-0.3.6-cp312-cp312-manylinux_2_34_aarch64.whl
- Upload date:
- Size: 5.9 MB
- Tags: CPython 3.12, manylinux: glibc 2.34+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d24d7c5cbb38dac3a3377bd18234d32df614cbd73669abcdf545051e6dc79fc2
|
|
| MD5 |
512af1c59cf34ed380b462c6145ebb61
|
|
| BLAKE2b-256 |
a10172592db8f103c5bf7261143020514163c46cee4182e5dc0b28cd8206f2fb
|
File details
Details for the file fabricatio_memory-0.3.6-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: fabricatio_memory-0.3.6-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 6.0 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2769e215baf7accd3b1652238168c27af272f9a326ee9f3a12ff0d4667d4528
|
|
| MD5 |
dbc6b7ad91f2792a92333287736dd548
|
|
| BLAKE2b-256 |
3ddeeeccebea259a2421c2c7430120be5c6ac2a988dcf05a9d8ea5f7a8844c74
|