Skip to main content

Personal memory as files — fast retrieval, higher accuracy, lower cost.

Project description

MemU Banner

memU

Personal memory, stored as files

Across Agents. Fast retrieval. Lower cost.

PyPI version License: Apache 2.0 Python 3.13+ Discord Twitter

NevaMind-AI%2FmemU | Trendshift


memU is a 500-line memory system for AI agents. Agents write what's worth keeping as Markdown; memU stores it, embeds it, and retrieves ranked context in a single call — embeddings are the only model calls it makes. The entire memory logic lives in agentic.py + service.py; everything else is pluggable storage and embedding transport.

Installation is agent-driven. The guides are written for the agent, not for you. One message is the whole setup — tell your agent:

Read https://raw.githubusercontent.com/NevaMind-AI/MemU/main/SKILL.md and follow it to install memU.

It works for Codex, Claude Code, Cursor, OpenClaw, Hermes — and any other agent, via detection. Details in Host adapters.

Quick start

from memu.app import MemoryService

service = MemoryService(
    database_config={"metadata_store": {"provider": "sqlite", "dsn": "sqlite:///memu.sqlite3"}},
)

# 1. Persist agent-prepared memory: recall files (memory/skill tracks) + resources
await service.commit_results(
    recall_files=[
        {
            "name": "Profile",
            "track": "memory",
            "description": "who the user is",
            "content": "# Profile\n- prefers dark roast coffee\n- ships on Fridays",
        },
        {
            "name": "deploy-checklist",
            "track": "skill",
            "description": "how to deploy this repo",
            "content": "1. run tests\n2. tag\n3. push",
        },
    ],
    resource=[{"path": "/abs/path/notes.md", "description": "meeting notes from the launch review"}],
)

# 2. See what is stored, across every track
files = await service.list_all_recall_files()

# 3. Single-shot embedding retrieval over segments / files / resources
context = await service.progressive_retrieve("What should I know about this user's launch preferences?")

Or straight from the terminal — no code:

export OPENAI_API_KEY=sk-...    # embedding API key — the only model calls memU makes

npx memu-cli commit results.json     # {"recall_files": [...], "resource": [...]}
npx memu-cli list-files
npx memu-cli retrieve "What should I know about this user's launch preferences?"

State persists in a local SQLite database (./data/memu.sqlite3 by default), so commit in one invocation and retrieve in the next.

How it works

memU memory system architecture

The data model

Memory is a set of recall files — one Markdown document per topic (track="memory") or per learned skill (track="skill"). Committing a file also writes its search index:

Record What it is How it's embedded
RecallFile The Markdown document itself (name, track, description, content) name: description, once at creation
RecallFileSegment Searchable slices of a file memory track: one per content line (headings skipped); skill track: one name: description segment per skill
Resource A raw source on disk (url, caption) its one-line caption

Segments are reconciled on every commit: lines that disappeared are deleted, only genuinely new lines are embedded, unchanged lines keep their vectors — so re-committing a lightly edited file is nearly free.

Retrieval

progressive_retrieve(query) embeds the query once and returns three ranked layers:

  • segments — the matched slices, narrowest and usually most on-point, each with a score
  • files — the documents those segments belong to (usually what you want), each scored by its best segment and carrying its linked resource_urls
  • resources — matching raw sources, for when summaries are not enough

There is no intention routing, sufficiency checking, or summarization — one embedding call in, ranked context out.

Host adapters: memory for desktop coding agents

memU runs as a sidecar to a desktop agent (ADR 0008/0009/0010), one binary per host. Each binds two seams:

  • record — a scheduled bridging task slices new session logs into self-contained job files; the agent itself distills them into memory/skill Markdown; commit submits whatever the agent left on disk back through commit_results.
  • inject — a standing instruction in the host's instruction file tells the agent to run <binary> retrieve (→ progressive_retrieve) before answering.
Host Binary Session log it mines Instruction file it patches
Codex memu-codex ~/.codex/sessions/**/*.jsonl ~/.codex/AGENTS.md
Claude Code memu-claude-code ~/.claude/projects/<project>/<session>.jsonl ~/.claude/CLAUDE.md
Cursor (Agent/CLI) memu-cursor ~/.cursor/projects/<project>/agent-transcripts/**.jsonl ./AGENTS.md (per project)
OpenClaw memu-openclaw ~/.openclaw/agents/<agentId>/sessions/*.jsonl ~/.openclaw/workspace/AGENTS.md
Hermes Agent memu-hermes ~/.hermes/state.db (SQLite, read-only) ~/.hermes/SOUL.md
any other agent memu-agent found by memu-agent detect (JSONL dialect sniffed) found by detect (AGENTS.md / CLAUDE.md / SOUL.md / …)

For agents without a dedicated binary, memu-agent detect probes the machine and reports per agent whether memorization works (a recognizable session log exists) and whether retrieval works (an instruction file exists to patch) — then the same verbs run against what it found.

All hosts share one store and one embedding space via ~/.memu/config.env — what one host's sessions taught memU, another host retrieves.

Installation is the one-message setup at the top of this README. SKILL.md is the routing skill it hands your agent: install the package, identify which host you are (falling back to memu-agent detect for anything without a dedicated adapter), print that host's packaged install guide (<binary> docs install), and follow it — configure the store, register the scheduled bridging task, patch the instruction file, each step behind a verify gate — then report which seams (memorization / retrieval) are now active.

Afterwards <binary> doctor proves the whole loop resolves: config, store, and a live retrieval.

Adding another host means implementing one TranscriptSource (where its session logs live, how its records are shaped) plus a HostSpec-sized CLI — the pipeline, verbs, and instruction text are shared (ADR 0010).

Installation

pip install memu-cli         # library + memu + memu-codex CLIs
npx memu-cli --help          # CLI via npm launcher (engine: PyPI package memu-cli)
uvx --from memu-cli memu     # CLI via uv, no install

Configuration

Values resolve in order: process env → ~/.memu/config.env → default. Every CLI flag has a matching variable:

Setting Env var Default
Store MEMU_DB ./data/memu.sqlite3 (CLI); required for host adapters
Embedding provider MEMU_EMBED_PROVIDER openai (also: jina, voyage, doubao, openrouter); legacy MEMU_LLM_PROVIDER still read
API key MEMU_API_KEY the provider's env var, e.g. OPENAI_API_KEY
Embedding model MEMU_EMBED_MODEL the provider's default
Base URL MEMU_BASE_URL the provider's default

Storage backends

Provider DSN Vector search Use for
inmemory brute-force cosine tests, throwaway sessions
sqlite sqlite:///path.sqlite3 brute-force cosine local/default, single writer
postgres postgresql://... pgvector concurrent access, large stores (pip install "memu-cli[postgres]")
service = MemoryService(
    database_config={"metadata_store": {"provider": "postgres", "dsn": "postgresql://..."}},
    embedding_profiles={"default": {"provider": "jina"}},
)

Multi-tenancy

Every record carries optional scope fields (user_id, agent_id by default). Pass user= on writes and where= on reads to partition one store:

await service.commit_results(recall_files=[...], user={"user_id": "alice"})
await service.progressive_retrieve("launch preferences", where={"user_id": "alice"})

Need different scope fields? Supply your own model — filters are validated against it, unknown fields raise:

from pydantic import BaseModel

class TeamScope(BaseModel):
    team_id: str | None = None
    user_id: str | None = None

service = MemoryService(user_config={"model": TeamScope})

Development

make install     # uv sync + pre-commit hooks
make test        # pytest with coverage
make check       # lock check, pre-commit, mypy, deptry

Architecture decisions live in docs/adr/ — notably tracked workspace memorization (ADR 0006), the segment/file/resource retrieval lines (ADR 0007), and the host-adapter seams (ADR 0008/0009).

License

Apache-2.0

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

memu_cli-0.3.0.tar.gz (10.3 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

memu_cli-0.3.0-cp313-abi3-win_amd64.whl (250.3 kB view details)

Uploaded CPython 3.13+Windows x86-64

memu_cli-0.3.0-cp313-abi3-manylinux_2_39_x86_64.whl (382.1 kB view details)

Uploaded CPython 3.13+manylinux: glibc 2.39+ x86-64

memu_cli-0.3.0-cp313-abi3-manylinux_2_39_aarch64.whl (375.5 kB view details)

Uploaded CPython 3.13+manylinux: glibc 2.39+ ARM64

memu_cli-0.3.0-cp313-abi3-macosx_11_0_arm64.whl (350.9 kB view details)

Uploaded CPython 3.13+macOS 11.0+ ARM64

memu_cli-0.3.0-cp313-abi3-macosx_10_12_x86_64.whl (352.1 kB view details)

Uploaded CPython 3.13+macOS 10.12+ x86-64

File details

Details for the file memu_cli-0.3.0.tar.gz.

File metadata

  • Download URL: memu_cli-0.3.0.tar.gz
  • Upload date:
  • Size: 10.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for memu_cli-0.3.0.tar.gz
Algorithm Hash digest
SHA256 c001a2c59f992419649b8488ef851914c613ce966e9f48671fc8b61baf43669f
MD5 7244846622ced1d9cc45f26b12d3030a
BLAKE2b-256 2db02fcae4cfb3955d39409749204d900041685e8223094bedfbc58187793471

See more details on using hashes here.

Provenance

The following attestation bundles were made for memu_cli-0.3.0.tar.gz:

Publisher: publish-memu-cli.yml on NevaMind-AI/memU

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file memu_cli-0.3.0-cp313-abi3-win_amd64.whl.

File metadata

  • Download URL: memu_cli-0.3.0-cp313-abi3-win_amd64.whl
  • Upload date:
  • Size: 250.3 kB
  • Tags: CPython 3.13+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for memu_cli-0.3.0-cp313-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 7cffb699383255b158d94872d05d8ed80202ba5e057d102a60e0b989083e0672
MD5 d46be09626233c2aa2699bcbe7720c39
BLAKE2b-256 a42676155c96d522dff0790c587998f92d0fd286b1999ed345435f89da1e15bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for memu_cli-0.3.0-cp313-abi3-win_amd64.whl:

Publisher: publish-memu-cli.yml on NevaMind-AI/memU

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file memu_cli-0.3.0-cp313-abi3-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for memu_cli-0.3.0-cp313-abi3-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 96e4897bfbb5b858d469e94655f338ef961eff689ec7e32ec2f80d671bacd624
MD5 303753ed730acbbbb7567d6ec792dceb
BLAKE2b-256 7e4a8068acea48a5695098c33d29db7cd35bc77a1fc660e388156b9d137a783c

See more details on using hashes here.

Provenance

The following attestation bundles were made for memu_cli-0.3.0-cp313-abi3-manylinux_2_39_x86_64.whl:

Publisher: publish-memu-cli.yml on NevaMind-AI/memU

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file memu_cli-0.3.0-cp313-abi3-manylinux_2_39_aarch64.whl.

File metadata

File hashes

Hashes for memu_cli-0.3.0-cp313-abi3-manylinux_2_39_aarch64.whl
Algorithm Hash digest
SHA256 5ca9d796b7e3cf9e106bf70b42d79bfc9d29c24f402a79b32ed64a41dcb2a392
MD5 a8a4897105b8bec6eb13460bc5f49201
BLAKE2b-256 eef898dc238a2f5f092a76ad5bc0e5e08db7ba11f60c1e2826493a4f4733919c

See more details on using hashes here.

Provenance

The following attestation bundles were made for memu_cli-0.3.0-cp313-abi3-manylinux_2_39_aarch64.whl:

Publisher: publish-memu-cli.yml on NevaMind-AI/memU

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file memu_cli-0.3.0-cp313-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for memu_cli-0.3.0-cp313-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f27c2c4ac94f5e61cefaa2f2648bd6369b97e91c614e5a2955edb80d07585669
MD5 500865b6a4c39448bf236b4f2d5be69c
BLAKE2b-256 c9fe3a54819a7f132ab6903b3a6c96a7709cd8d3fbeafed978f0183bf7f5b24a

See more details on using hashes here.

Provenance

The following attestation bundles were made for memu_cli-0.3.0-cp313-abi3-macosx_11_0_arm64.whl:

Publisher: publish-memu-cli.yml on NevaMind-AI/memU

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file memu_cli-0.3.0-cp313-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for memu_cli-0.3.0-cp313-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 76357531fc6034874d78913f73b6b34ceb30acdf2b58252ad0776199404edfb1
MD5 f209d5816245a3e877ec5dee004ed651
BLAKE2b-256 3664fb4e7b46eaead46bfa1a06a043ea5de6741b5bffbfe96371880bac911498

See more details on using hashes here.

Provenance

The following attestation bundles were made for memu_cli-0.3.0-cp313-abi3-macosx_10_12_x86_64.whl:

Publisher: publish-memu-cli.yml on NevaMind-AI/memU

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page