sense-memory
Give your AI agent a memory.
Sovereign persistence for OpenClaw agents — encrypted memories stored on Nostr relays using the agent's own keypair. Nobody else can read them.
Why?
AI agents forget everything between conversations. Every tool that fixes this puts your agent's memories on someone else's server, behind someone else's API key.
sense-memory takes a different approach: your agent already has a cryptographic identity (via NostrKey). That identity can sign and encrypt Nostr events. So instead of storing memories in a database you manage, the agent writes encrypted notes to itself on a Nostr relay — the same way it would send a DM to another agent, except the recipient is itself.
The result: persistent memory that only the agent can read, stored on infrastructure that already exists, using a protocol that's open and sovereign.
How It Fits Together
sense-memory is part of the NSE sovereign identity ecosystem:
- NostrKey gives the agent its identity — a Nostr keypair it owns
- sense-memory uses that identity to encrypt and store memories on any relay
- NostrCalendar uses the same identity for scheduling
- NostrSocial uses it for the social graph
- NSE Orchestrator wires all five pillars into a coherent whole
The agent's keypair is the thread that runs through everything. One identity, many capabilities — and now, persistent memory.
Install
pip install sense-memory
v0.2.1 — part of the coordinated 2026-07 correctness release (staged, pending PyPI publish). The whole Nostr library family was audited together and every package is now verified against a shared spine of known-answer test vectors (NIP-44 v2, NIP-49, NIP-19 TLV, BIP-340) so encode/decode bugs can't hide inside self-round-trip tests. This release fixes
recent()ordering and journal starvation so "newest first" is guaranteed regardless of relay stream order. SeeCHANGELOG.md.
Quick Start
import asyncio, os
from nostrkey import Identity
from sense_memory import MemoryStore
async def main():
identity = Identity.from_nsec(os.environ["NOSTR_NSEC"])
store = MemoryStore(identity, "wss://relay.nostrkeep.com")
# Remember something
await store.remember("user_timezone", "America/Vancouver")
# Recall it later
memory = await store.recall("user_timezone")
print(memory.value) # "America/Vancouver"
# Write a journal entry
await store.journal("Had a great conversation about scheduling today")
# Read recent journal
entries = await store.recent(limit=5)
for entry in entries:
print(entry.content)
# Forget a memory
await store.forget("user_timezone")
asyncio.run(main())
How It Works
| Mode | Nostr Kind | Behavior | Use Case |
|---|---|---|---|
| Key-value | 30078 (NIP-78) | Replaceable by key | Preferences, state, facts |
| Journal | 4 (NIP-04 DM to self) | Append-only | Conversation logs, observations |
Both modes encrypt content with NIP-44. Only the agent's keypair can decrypt. Any Nostr relay that supports these event kinds will work — no custom infrastructure needed.
API
| Function | Returns | Description |
|---|---|---|
remember(key, value) |
str |
Store or overwrite a memory. Returns event ID. |
recall(key) |
Memory | None |
Retrieve a memory by key. |
recall_all() |
list[Memory] |
Retrieve all stored memories. |
forget(key) |
str |
Delete a memory (NIP-09). Returns event ID. |
journal(content) |
str |
Write an append-only journal entry. Returns event ID. |
recent(limit=20) |
list[JournalEntry] |
Retrieve recent journal entries. |
NIPs Used
| NIP | Purpose |
|---|---|
| NIP-01 | Basic event structure and relay protocol |
| NIP-04 | DM to self (journal entries) |
| NIP-09 | Event deletion (forget) |
| NIP-44 | Encryption for all stored content |
| NIP-78 | App-specific replaceable data (key-value memories) |
OpenClaw Skill
sense-memory is published on ClawHub as the sense-memory skill. It's part of the huje.tools collection — open-source tools for the agentic age.
License
MIT — Humanjava Enterprises Inc.
Release files for sense-memory 0.3.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 | |
|---|---|---|---|
| sense_memory-0.3.1.tar.gz | 28.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sense_memory-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 40.1 kB
Release files / sense_memory-0.3.1.tar.gz
| Download URL | sense_memory-0.3.1.tar.gz |
|---|---|
| Size | 28.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
90c48fbab868aca2a1a19e06b1dfbd9efd2f859130bdf5ff2980d74d69c75cc4
|
|
BLAKE2b-256 checksum How to use checksums |
4dbe8f281bd9232e039947432a316e3fc42abc2b150e4de2dbb7babc5b30b38f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / sense_memory-0.3.1-py3-none-any.whl
| Download URL | sense_memory-0.3.1-py3-none-any.whl |
|---|---|
| Size | 11.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8e7c3933d1d2d6bad1ce809090393ae949f5c7be5ffd656d2624c40c4e10e50f
|
|
BLAKE2b-256 checksum How to use checksums |
4ba2d7256808a90986a397642688b87df24abbd1f727982598fa00326b9bdb9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|