Skip to content

Latest commit

ย 

History

History
321 lines (234 loc) ยท 7.84 KB

File metadata and controls

321 lines (234 loc) ยท 7.84 KB

๐Ÿงฌ DNA Memory

Make AI Agents learn, reinforce, forget, and generalize like a human brain

Stars License Python OpenClaw

English | ็ฎ€ไฝ“ไธญๆ–‡


Most AI memory systems only solve storage. DNA Memory is about how agents actually learn and evolve.

It is not just a memory store. It is a memory evolution system with:

  • 3-layer memory architecture
  • reinforcement and decay
  • reflection (reflect)
  • promotion to long-term memory (promote)
  • duplicate cleanup (dedupe)
  • FTS5-powered recall search
  • background daemon maintenance

๐Ÿ†š Why not just use a normal memory store?

Capability Mem0 Zep LangChain Memory DNA Memory
Basic storage โœ… โœ… โœ… โœ…
Vector / semantic retrieval โœ… โœ… โœ… โš ๏ธ extensible
Multi-layer architecture โŒ โš ๏ธ โŒ โœ… working / short / long
Active forgetting โŒ โŒ โŒ โœ…
Reflection loop โŒ โŒ โŒ โœ…
Pattern extraction โŒ โŒ โŒ โœ…
Long-term promotion โŒ โŒ โŒ โœ…
Local-first / minimal core deps โŒ โŒ โŒ โœ…
Built for agent workflows โš ๏ธ โš ๏ธ โš ๏ธ โœ…

Positioning in one sentence:

DNA Memory helps AI agents not only remember, but also reinforce, forget, summarize, and evolve like a real cognitive system.


๐Ÿš€ Quick Start in 30 Seconds

# 1) Clone into your OpenClaw skills directory
git clone https://github.com/AIPMAndy/dna-memory.git ~/.openclaw/skills/dna-memory

# 2) Remember one preference
python3 ~/.openclaw/skills/dna-memory/scripts/evolve.py remember "The user prefers concise and direct responses" -t preference -i 0.9

# 3) Recall related memories
python3 ~/.openclaw/skills/dna-memory/scripts/evolve.py recall "concise direct"

# 4) Inspect stats
python3 ~/.openclaw/skills/dna-memory/scripts/evolve.py stats

Why it is practical:

  • core features run on Python + SQLite
  • no external database required
  • local-first by default
  • ideal for personal assistants, local agents, and autonomous workflows

โœจ Core Capabilities

1. Three-layer memory architecture

Working Memory
  โ†“ filter
Short-term Memory
  โ†“ consolidate / promote
Long-term Memory
Layer Role Typical content
Working temporary session context current task state, fresh facts
Short-term recent important information preferences, lessons, recent errors
Long-term stable knowledge and patterns rules, skills, persistent preferences

2. Reinforcement and forgetting

  • used often โ†’ higher weight
  • unused for a long time โ†’ decay
  • low-weight memories โ†’ removable
  • stable high-value memories โ†’ promoted to long-term memory

3. Reflection (reflect)

reflect does two things:

  • extracts recurring patterns from recent high-weight memories
  • promotes stable short-term memories into long-term memory

4. Better recall search

Current recall supports:

  • multi-keyword AND search
  • type filters like type:error / type:skill
  • SQLite FTS5 full-text search
  • automatic fallback to LIKE search if FTS5 is unavailable

Examples:

python3 scripts/evolve.py recall "feishu api"
python3 scripts/evolve.py recall "type:error github"
python3 scripts/evolve.py recall "user preference concise"

5. Background maintenance daemon

The daemon can automatically run:

  • reflect
  • decay
  • throttled maintenance so the same batch is not repeatedly summarized

It can also be registered with macOS launchd for auto-start on boot.


๐Ÿ“ฆ Actual current architecture

dna-memory/
โ”œโ”€โ”€ scripts/
โ”‚   โ”œโ”€โ”€ evolve.py              # core CLI: remember / recall / stats / reflect / dedupe ...
โ”‚   โ”œโ”€โ”€ dna_memory_daemon.py   # background maintenance daemon
โ”‚   โ”œโ”€โ”€ semantic_search.py     # experimental semantic search module
โ”‚   โ”œโ”€โ”€ analyze.py
โ”‚   โ”œโ”€โ”€ api.py
โ”‚   โ”œโ”€โ”€ autocollect.py
โ”‚   โ”œโ”€โ”€ backup.py
โ”‚   โ”œโ”€โ”€ cli.py
โ”‚   โ”œโ”€โ”€ detailed_stats.py
โ”‚   โ”œโ”€โ”€ knowme_link.py
โ”‚   โ”œโ”€โ”€ reminder.py
โ”‚   โ”œโ”€โ”€ trigger.py
โ”‚   โ””โ”€โ”€ visualize.py
โ”œโ”€โ”€ memory/
โ”‚   โ”œโ”€โ”€ memory.db              # SQLite primary store (memories + operations)
โ”‚   โ””โ”€โ”€ working.json           # working memory
โ”œโ”€โ”€ assets/
โ”‚   โ””โ”€โ”€ config.json            # daemon / decay config
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ README_EN.md
โ””โ”€โ”€ SKILL.md

Note: memory/*.db should not be committed. The repo now ignores real memory database files by default.


๐Ÿงช Core Commands

Remember

python3 scripts/evolve.py remember "Andy prefers concise and direct responses" -t preference -i 0.95

Recall

python3 scripts/evolve.py recall "concise response"
python3 scripts/evolve.py recall "type:skill feishu"

Stats

python3 scripts/evolve.py stats

Reflect

python3 scripts/evolve.py reflect

Promote

python3 scripts/evolve.py promote --id 12

Dedupe

python3 scripts/evolve.py dedupe

Daemon

# start
python3 scripts/dna_memory_daemon.py start

# check status
python3 scripts/dna_memory_daemon.py status

# stop
python3 scripts/dna_memory_daemon.py stop

โš™๏ธ Use Cases

1. Personal AI assistants

  • remember user preferences
  • develop a stable collaboration style over time
  • learn from mistakes instead of repeating them

2. Agent workflow orchestration

  • turn finished tasks into reusable skills
  • store failure cases as error memories
  • extract patterns from long-running work

3. AI products with personalization

  • accumulate user profiles
  • track behavioral patterns
  • build long-term personalization

4. Self-improving agent systems

  • works well with OpenClaw, self-improving-agent, and custom agent stacks
  • turns operational experience into reusable memory assets

๐Ÿงญ Recommended Workflow

Receive task
  โ†“
Recall related memories
  โ†“
Execute
  โ†“
Remember new preferences / skills / errors
  โ†“
Reflect recurring patterns
  โ†“
Promote into long-term memory

This workflow is especially useful when:

  • the user corrects the agent
  • a new preference is learned
  • an API/tool fails
  • a long task finishes
  • a repeatable pattern appears

๐Ÿ—บ๏ธ Roadmap

  • SQLite single-store refactor
  • remember / recall / reflect / promote / dedupe CLI
  • daemon for automatic reflect / decay
  • FTS5-based recall search
  • launchd auto-start setup
  • better Chinese tokenization and ranking
  • real embedding-based semantic retrieval
  • stronger memory graph visualization
  • more complete import / export / migration tooling
  • shared memory spaces for multi-agent systems

๐Ÿค Contributing

Issues and PRs are welcome.

High-impact contribution areas:

  • recall ranking quality
  • Chinese search experience
  • pattern extraction quality
  • memory visualization
  • embedding provider integrations

๐Ÿ‘จโ€๐Ÿ’ป Author

Andy / AI้…‹้•ฟAndy
Ex-Tencent / Baidu AI Product Expert โ†’ LLM Unicorn VP โ†’ Startup CEO

Focus areas:

  • AI agents
  • AI commercialization
  • memory systems
  • human augmentation

GitHub: https://github.com/AIPMAndy


๐Ÿ“„ License

Apache 2.0


If this project helps you, give it a โญ Star.