engramai 🧠
Cognitive memory system implementing ACT-R activation, Memory Chain consolidation, Ebbinghaus forgetting, and Hebbian learning.
Installation
CODEBLOCK0
Quick Start
CODEBLOCK1
CLI Usage
CODEBLOCK2
AI Agent Integration (Important!)
For AI agents to use engram correctly, follow these patterns:
When to Call What
| Trigger | Action | Example |
|---|
| Learn user preference | INLINECODE0 | "User prefers concise answers" |
| Learn important fact |
store(type="factual") | "Project uses Python 3.12" |
| Learn how to do something |
store(type="procedural") | "Deploy requires running tests first" |
| Question about history |
recall() first, then answer | "What did I say about X?" |
| User satisfied |
reward("positive feedback") | Strengthens recent memories |
| User unsatisfied |
reward("negative feedback") | Suppresses recent memories |
| Daily maintenance |
consolidate() +
forget() | Run via cron or heartbeat |
What to Store
✅ Store:
- - User preferences and habits
- Important facts and decisions
- Lessons learned
- Procedural knowledge
❌ Don't store:
- - Every conversation message (too noisy)
- Temporary information
- Publicly available facts
- Sensitive data (unless requested)
Importance Guide
| Level | Use For |
|---|
| 0.9-1.0 | Critical info (API keys location, absolute preferences) |
| 0.7-0.8 |
Important (code style, project structure) |
| 0.5-0.6 | Normal (general facts, experiences) |
| 0.3-0.4 | Low priority (casual chat, temp notes) |
Hybrid Mode (Recommended)
Use engram alongside file-based memory:
- - engram: Active memory — retrieval, associations, dynamic weighting
- Files (memory/*.md): Logs — transparency, debugging, manual editing
Heartbeat Maintenance
Add to your heartbeat or cron:
CODEBLOCK3
Memory Types
- -
factual — Facts and knowledge - INLINECODE9 — Events and experiences
- INLINECODE10 — Relationships and preferences
- INLINECODE11 — Emotional moments
- INLINECODE12 — How-to knowledge
- INLINECODE13 — Beliefs and opinions
MCP Server
For Claude/Cursor/Clawdbot integration:
CODEBLOCK4
MCP Config (Clawdbot):
CODEBLOCK5
Tools: engram.store, engram.recall, engram.consolidate, engram.forget, engram.reward, engram.stats, INLINECODE20
Key Features
| Feature | Description |
|---|
| ACT-R Activation | Retrieval ranked by recency × frequency × context |
| Memory Chain |
Dual-system consolidation (working → core) |
|
Ebbinghaus Forgetting | Natural decay with spaced repetition |
|
Hebbian Learning | "Neurons that fire together wire together" |
|
Confidence Scoring | Metacognitive monitoring |
|
Reward Learning | User feedback shapes memory |
|
Zero Dependencies | Pure Python stdlib + SQLite |
Links
- - PyPI: https://pypi.org/project/engramai/
- npm: https://www.npmjs.com/package/neuromemory-ai
- GitHub: https://github.com/tonitangpotato/neuromemory-ai
- Docs: https://github.com/tonitangpotato/neuromemory-ai/blob/main/docs/USAGE.md
engramai 🧠
实现ACT-R激活、记忆链巩固、艾宾浩斯遗忘和赫布学习的认知记忆系统。
安装
bash
pip install engramai
快速开始
python
from engram import Memory
mem = Memory(./agent.db)
mem.add(用户偏好简洁回答, type=relational, importance=0.8)
results = mem.recall(用户偏好, limit=5)
mem.consolidate() # 日常维护
CLI使用
bash
添加记忆
neuromem add 用户偏好深色模式 --type preference --importance 0.8
回忆记忆
neuromem recall 用户偏好
查看统计
neuromem stats
运行巩固(类似睡眠)
neuromem consolidate
修剪弱记忆
neuromem forget --threshold 0.01
列出记忆
neuromem list --limit 20
显示赫布链接
neuromem hebbian 深色模式
AI代理集成(重要!)
AI代理正确使用engram需遵循以下模式:
何时调用什么
| 触发条件 | 操作 | 示例 |
|---|
| 学习用户偏好 | store(type=relational) | 用户偏好简洁回答 |
| 学习重要事实 |
store(type=factual) | 项目使用Python 3.12 |
| 学习操作方法 | store(type=procedural) | 部署前需先运行测试 |
| 询问历史记录 | 先recall(),再回答 | 我之前关于X说过什么? |
| 用户满意 | reward(positive feedback) | 强化近期记忆 |
| 用户不满意 | reward(negative feedback) | 抑制近期记忆 |
| 日常维护 | consolidate() + forget() | 通过cron或心跳运行 |
存储什么
✅ 存储:
- - 用户偏好和习惯
- 重要事实和决策
- 经验教训
- 程序性知识
❌ 不存储:
- - 每条对话消息(过于嘈杂)
- 临时信息
- 公开可用的事实
- 敏感数据(除非要求)
重要性指南
| 级别 | 用途 |
|---|
| 0.9-1.0 | 关键信息(API密钥位置、绝对偏好) |
| 0.7-0.8 |
重要(代码风格、项目结构) |
| 0.5-0.6 | 普通(一般事实、经验) |
| 0.3-0.4 | 低优先级(闲聊、临时笔记) |
混合模式(推荐)
将engram与基于文件的记忆结合使用:
- - engram:活跃记忆——检索、关联、动态加权
- 文件(memory/*.md):日志——透明性、调试、手动编辑
心跳维护
添加到心跳或cron:
markdown
记忆维护(每日)
- - [ ] engram.consolidate
- [ ] engram.forget --threshold 0.01
记忆类型
- - factual — 事实和知识
- episodic — 事件和经历
- relational — 关系和偏好
- emotional — 情感时刻
- procedural — 操作知识
- opinion — 信念和观点
MCP服务器
用于Claude/Cursor/Clawdbot集成:
bash
python -m engram.mcp_server --db ./agent.db
MCP配置(Clawdbot):
yaml
mcp:
servers:
engram:
command: python3
args: [-m, engram.mcp_server]
env:
ENGRAMDBPATH: ~/.clawdbot/agents/main/memory.db
工具: engram.store、engram.recall、engram.consolidate、engram.forget、engram.reward、engram.stats、engram.export
关键特性
| 特性 | 描述 |
|---|
| ACT-R激活 | 按近因×频率×上下文排序的检索 |
| 记忆链 |
双系统巩固(工作→核心) |
|
艾宾浩斯遗忘 | 带间隔重复的自然衰减 |
|
赫布学习 | 一起放电的神经元连接在一起 |
|
置信度评分 | 元认知监控 |
|
奖励学习 | 用户反馈塑造记忆 |
|
零依赖 | 纯Python标准库+SQLite |
链接
- - PyPI:https://pypi.org/project/engramai/
- npm:https://www.npmjs.com/package/neuromemory-ai
- GitHub:https://github.com/tonitangpotato/neuromemory-ai
- 文档:https://github.com/tonitangpotato/neuromemory-ai/blob/main/docs/USAGE.md