AgentMemory is a local-first, provider-neutral memory subsystem for agentic applications. It provides durable SQLite storage, privacy-aware exposure policy, prompt assembly, and a stable integration boundary for Python, C++, and C consumers.
- Persistent memory records with correction, soft deletion, hard deletion, and search.
- Append-only interaction events, persona blocks, and auditable memory proposals.
- Privacy classes:
generic,team, andprivate. - Provider classes:
external_public,external_team, andlocal_private. - Configurable prompt budgets and policy decisions before memory is exposed.
- Python runtime tools, deterministic distillation, sync interfaces, CLI, and JSON process API.
- Native C++ SQLite implementation with a standalone C ABI and CPython binding.
- No network, database service, embedding service, or provider SDK required.
Higher-level orchestration remains in Python; both Python and native consumers share the same storage and policy model.
| Consumer | Entry point | Reference |
|---|---|---|
| Python application | agentmemory package; NativeSQLiteMemoryStore for the native backend |
Python API reference |
| C++ application | CMake target AgentMemory::core |
C++ API reference |
| C or runtime-loaded integration | Shared library agentmemory_capi and agentmemory_capi.h |
C++/C API reference |
| Process-isolated integration | JSON command and prompt boundary | API contract |
The public compatibility rules are documented in the API contract. Public API changes must be additive, preserve existing behavior, update the references and tests, and retain backward compatibility.
The portable Python backend works after installing the package:
python -m pip install -e .
python -m unittest discover -s testsfrom agentmemory import MemoryRecord, MemoryToolRuntime, SQLiteMemoryStore
store = SQLiteMemoryStore(".agentmemory/memory.sqlite3")
tools = MemoryToolRuntime(store)
result = tools.call("memory_remember", {
"content": "Use local inference for confidential code",
"privacy_class": "private",
})The native backend is selected explicitly after the native extension is built:
from agentmemory import NativeSQLiteMemoryStore, open_store
store = NativeSQLiteMemoryStore(".agentmemory/native.sqlite3")
# Or: store = open_store(".agentmemory/native.sqlite3", backend="native")open_store(..., backend="python") remains the backward-compatible default.
backend="auto" uses native storage only for a new path when the extension is
available; existing databases remain on the Python backend until explicitly
migrated with migrate_to_native.
Build the native library for Windows x64:
cmake -S . -B build\x64 -G "Visual Studio 17 2022" -A x64
cmake --build build\x64 --config ReleaseOn Linux or macOS, use the host CMake generator. For macOS/ARM64 or Ubuntu
ARM64, provide the platform toolchain and normally set
-DAGENTMEMORY_BUILD_PYTHON=OFF; see the native build guide.
Subproject consumers can use:
add_subdirectory(third_party/AgentMemory)
target_link_libraries(my_app PRIVATE AgentMemory::core) # C++
# Or AgentMemory::capi for the C ABI shared library.The native build exports AgentMemory::core, AgentMemory::capi, and
AgentMemory::python when enabled. The C ABI allocates JSON output strings;
release them with agentmemory_free_string. See the C++ and C API reference.
agentmemory remember --class private "Use local inference for confidential code"
agentmemory search "confidential" --json
agentmemory show <memory-id>
agentmemory forget <memory-id>Non-Python clients can use the documented JSON commands and schemas in
schemas/; this avoids embedding Python in a system integration.
- Default native Python bindings target 64-bit x86 (
amd64/x86_64). - Native C++ and C builds require C++17 and SQLite3 development headers/libraries.
- The repository validates Windows x64 plus an external CMake consumer fixture.
- Linux, macOS, and ARM builds use normal CMake/toolchain workflows and require validation with the target toolchain.
- The native extension is not built by
pip installautomatically; build it with CMake as documented above.
See native build guide, Python API reference, C++ API reference, and API contract.
MIT. See LICENSE.