Sovereign persistence for OpenClaw AI agents — encrypted memories on Nostr relays
Project description
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
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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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 sense_memory-0.1.1.tar.gz.
File metadata
- Download URL: sense_memory-0.1.1.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1170bd09c45744bb5795c6c919cb9eae354b9217df812a8b81a98d05f5a793ac
|
|
| MD5 |
5615c35903d703a1683e7d3c6ffacb8b
|
|
| BLAKE2b-256 |
83e18682ac0c7fbe8c4d65cdb7d986889af21605760db5614857f2cc76ee4362
|
File details
Details for the file sense_memory-0.1.1-py3-none-any.whl.
File metadata
- Download URL: sense_memory-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b95ad3a93cdb4d2a8b707b05bfa85d64c924ed9423237aac742d6c45a3664764
|
|
| MD5 |
5056cdf959d7e2f07197d6068e166699
|
|
| BLAKE2b-256 |
8168f979c6f4b95435ce3b6298e989a4a3f38d04a71b25852a12fec863e434eb
|