Skip to main content

fabricatio-memory

MIT Python Versions PyPI Version PyPI Downloads PyPI Downloads Build Tool: uv

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

Configuration

All options below are read through the fabricatio configuration chain (see the Configuration Guide). Set them under the [ext.memory] table in fabricatio.toml, equivalently under [tool.fabricatio.ext.memory] in pyproject.toml, or via FABRICATIO_EXT__MEMORY__<FIELD_UPPER> environment variables.

[ext.memory]
memory_store_root = "~/.fabricatio-memory"
Option Type Default Description
memory_record_template str "built-in/memory_record" Template for recording memory.
memory_recall_template str "built-in/memory_recall" Template for recalling memory.
sremember_template str "built-in/sremember" Template for selective remembering.
memory_store_root Path ~/.fabricatio-memory Root directory for memory store.
writer_buffer_size int 50000000 Buffer size for memory store writer. In bytes.
cache_size int 10 Cache size for memory store.

Access at runtime: from fabricatio_memory.config import memory_config.

Dependencies

  • fabricatio-core — core interfaces, configuration, template management
  • Optional: fabricatio-judge — required by SelectiveRemember for conditional recording

License

MIT — see LICENSE

Metadata

Release files for fabricatio-memory 0.3.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for fabricatio-memory 0.3.7
File
fabricatio_memory-0.3.7-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
fabricatio_memory-0.3.7-cp314-cp314-manylinux_2_34_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.34+ x86-64 Details
fabricatio_memory-0.3.7-cp314-cp314-manylinux_2_34_aarch64.whl CPython 3.14 CPython 3.14 Linux glibc 2.34+ ARM64 Details
fabricatio_memory-0.3.7-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details
fabricatio_memory-0.3.7-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
fabricatio_memory-0.3.7-cp313-cp313-manylinux_2_34_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.34+ x86-64 Details
fabricatio_memory-0.3.7-cp313-cp313-manylinux_2_34_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.34+ ARM64 Details
fabricatio_memory-0.3.7-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
fabricatio_memory-0.3.7-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
fabricatio_memory-0.3.7-cp312-cp312-manylinux_2_34_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ x86-64 Details
fabricatio_memory-0.3.7-cp312-cp312-manylinux_2_34_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ ARM64 Details
fabricatio_memory-0.3.7-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details

Total release size: 67.4 MB

Release files / fabricatio_memory-0.3.7-cp314-cp314-win_amd64.whl

Download URL fabricatio_memory-0.3.7-cp314-cp314-win_amd64.whl
Size 5.4 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
c80cf0844adefac793746a22793e87f7034e7cb92123d7731d1a6c3b317b931d
BLAKE2b-256 checksum
How to use checksums
40a92fa6f4bc734c285340c19b2a008ab95fd2d3bdb4085c57824df461707b92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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}

Release files / fabricatio_memory-0.3.7-cp314-cp314-manylinux_2_34_x86_64.whl

Download URL fabricatio_memory-0.3.7-cp314-cp314-manylinux_2_34_x86_64.whl
Size 6.1 MB
Tags CPython 3.14 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
b8b6c9fa8b7a30350680fc2982683e39d1eb446de9dd996637c4c7af9898bec6
BLAKE2b-256 checksum
How to use checksums
3da8536bf4ffa9c94b500e8fc58f54a408d748ff123c56c6cc0e5ca2aaee7797
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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}

Release files / fabricatio_memory-0.3.7-cp314-cp314-manylinux_2_34_aarch64.whl

Download URL fabricatio_memory-0.3.7-cp314-cp314-manylinux_2_34_aarch64.whl
Size 5.5 MB
Tags CPython 3.14 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
e266cc16a3ee8bbfc0e1810b5c9bfd410580c2534833d88a1b32e59f67cfaf42
BLAKE2b-256 checksum
How to use checksums
fc9440247e43465e048089feff8b03b15f61bf44548759a9a2b99faa2af2a30f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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}

Release files / fabricatio_memory-0.3.7-cp314-cp314-macosx_11_0_arm64.whl

Download URL fabricatio_memory-0.3.7-cp314-cp314-macosx_11_0_arm64.whl
Size 5.5 MB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9e4eb88485c1772c0034193386bcaebe07f99ebeff8f0743fd12a90dd24a3420
BLAKE2b-256 checksum
How to use checksums
a734a3b2f010ed6944cff0c560e03e314f4faa520da86e2aaa0bc0c9b3176159
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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}

Release files / fabricatio_memory-0.3.7-cp313-cp313-win_amd64.whl

Download URL fabricatio_memory-0.3.7-cp313-cp313-win_amd64.whl
Size 5.4 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
2d8a04453485546bf56c66277aaf5f8d5915bf7022888dfe022d1b5435730911
BLAKE2b-256 checksum
How to use checksums
25c36cfb7ac96e7595765dbbbe3461fe3eae4471cfb99984a989f4d0d25a839a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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}

Release files / fabricatio_memory-0.3.7-cp313-cp313-manylinux_2_34_x86_64.whl

Download URL fabricatio_memory-0.3.7-cp313-cp313-manylinux_2_34_x86_64.whl
Size 6.1 MB
Tags CPython 3.13 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
711dbe9bfd9bf37d5bd1fdb9648139265ae03c577575cd41d826f60dd1f28696
BLAKE2b-256 checksum
How to use checksums
2e3a6ae9e1c77fed5a1a2fa47525974d1dffb5bdec0d101b3c1952bd2bb04457
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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}

Release files / fabricatio_memory-0.3.7-cp313-cp313-manylinux_2_34_aarch64.whl

Download URL fabricatio_memory-0.3.7-cp313-cp313-manylinux_2_34_aarch64.whl
Size 5.5 MB
Tags CPython 3.13 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
aa4b8e2ed991f452235b092ed91c64e8ba4494a46a44c121ec1324ab9430e35b
BLAKE2b-256 checksum
How to use checksums
30e4a5428ad3b0f8803488e06dae709f214b99790cbd5c6d6ecc5d2844641eb6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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}

Release files / fabricatio_memory-0.3.7-cp313-cp313-macosx_11_0_arm64.whl

Download URL fabricatio_memory-0.3.7-cp313-cp313-macosx_11_0_arm64.whl
Size 5.5 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
bf2ebf10425823586d798c0f4045c7ff4f55d3a75debbe16940b0bb71ccc6f8c
BLAKE2b-256 checksum
How to use checksums
2808af1aa85fe37ab77071c7ab2ef77ee155ef4c712c22e293590a6db2840b40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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}

Release files / fabricatio_memory-0.3.7-cp312-cp312-win_amd64.whl

Download URL fabricatio_memory-0.3.7-cp312-cp312-win_amd64.whl
Size 5.4 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
a5fb5bea93be42148eeff43a10105bc444161ddfa3934e33584ec247db5a9329
BLAKE2b-256 checksum
How to use checksums
154cf84c5ea26509e6546beed11817d73c8a6ec55246dcda75f05fc6105d73e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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}

Release files / fabricatio_memory-0.3.7-cp312-cp312-manylinux_2_34_x86_64.whl

Download URL fabricatio_memory-0.3.7-cp312-cp312-manylinux_2_34_x86_64.whl
Size 6.1 MB
Tags CPython 3.12 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
358ef214fd72f88a49bdb75dfc3a83077ee4117c17266f9e459dff4cb176b4b3
BLAKE2b-256 checksum
How to use checksums
9a577ff5eebbd86affe97c13e672778622624bebb85fd91f4893072d6b304d10
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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}

Release files / fabricatio_memory-0.3.7-cp312-cp312-manylinux_2_34_aarch64.whl

Download URL fabricatio_memory-0.3.7-cp312-cp312-manylinux_2_34_aarch64.whl
Size 5.5 MB
Tags CPython 3.12 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
77d7987f3aad6146ae29a0038e7486a9716272ed592a04236f4fe188c968a57e
BLAKE2b-256 checksum
How to use checksums
7d36e348e794cecf5f641615ec8b143ad8e3a66e1a23510a1016a84ddf7c0da8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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}

Release files / fabricatio_memory-0.3.7-cp312-cp312-macosx_11_0_arm64.whl

Download URL fabricatio_memory-0.3.7-cp312-cp312-macosx_11_0_arm64.whl
Size 5.5 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d8dec447cdc1f187380c4fff7b471da13c9a16828b826fe5139c6a3c245a8462
BLAKE2b-256 checksum
How to use checksums
481e0c04cd037bffda9090a1762b6fa194c7d09a50e3356f0584d04d55163416
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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}
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page