loci — Structured Memory for AI Agents
GitHub: https://github.com/bayhax/loci | ClawHub: INLINECODE0
Quick Start
CODEBLOCK0
Core Concepts
Domains — Categories that organize memories (like rooms). Each has a capacity limit.
Default domains: work, knowledge, people, tools, preferences, archive.
Memories — Individual pieces of context stored in a domain. Each has:
- - Unique ID (e.g.
e3a7f2c1) - Content text
- Tags for categorization
- Links to related memories
- Weight that decays over time
Decay — Memories lose weight exponentially based on time since last access.
Formula: weight = base_weight × e^(-decay_rate × days_since_access)
Default decay rate: 0.05 (half-life ≈ 14 days).
Links — Bidirectional connections between related memories across any domain.
Commands
| Command | Purpose |
|---|
| INLINECODE3 | Create new palace (once) |
| INLINECODE4 |
Add memory. Options:
--tag,
--link |
|
recall <query> | Search. Options:
--domain,
--top N |
|
walk | Traverse all memories, report health |
|
prune | Remove decayed memories. Options:
--threshold,
--dry-run |
|
status | Overview of all domains |
|
inspect <id> | View memory details + links |
|
link <id1> <id2> | Connect two memories |
|
domains | List/add/remove domains |
|
export | Export as markdown or JSON. Options:
--format md\|yaml |
Integration with Heartbeats
During heartbeat walks, run:
CODEBLOCK1
This reports domain health, identifies fading memories, and updates the walk timestamp.
Periodically follow with $LOCI prune --dry-run to review candidates for removal.
When to Store vs. When to Skip
Store: Decisions, user preferences, environment quirks, lessons learned, important people/relationships, recurring patterns.
Skip: Transient task details, one-off commands, things already in daily memory files.
Rule of thumb: If future-you would benefit from knowing this in 2 weeks, store it.
Palace File
Default location: ~/.openclaw/workspace/loci_palace.json
Override with --palace PATH on any command.
Format: JSON. Zero external dependencies — only requires Node.js (ships with OpenClaw).
loci — AI代理的结构化记忆系统
GitHub: https://github.com/bayhax/loci | ClawHub: clawhub install loci
快速开始
bash
LOCI=node /scripts/loci.mjs
初始化记忆宫殿(仅首次)
$LOCI init
存储一条记忆
$LOCI store work 根据用户偏好切换到Claude Opus模型 --tag model --tag preference
回忆记忆
$LOCI recall 用户偏好什么模型
漫步记忆宫殿(在心跳检测期间执行)
$LOCI walk
查看概览
$LOCI status
核心概念
领域 — 组织记忆的分类(如同房间)。每个领域有容量上限。
默认领域:工作、知识、人物、工具、偏好、归档。
记忆 — 存储在领域中的独立上下文片段。每条记忆包含:
- - 唯一ID(例如 e3a7f2c1)
- 内容文本
- 用于分类的标签
- 关联记忆的链接
- 随时间衰减的权重
衰减 — 记忆根据上次访问后的时间呈指数级衰减。
公式:权重 = 基础权重 × e^(-衰减率 × 访问天数)
默认衰减率:0.05(半衰期 ≈ 14天)。
链接 — 跨领域相关记忆之间的双向连接。
命令
| 命令 | 用途 |
|---|
| init | 创建新宫殿(仅一次) |
| store <领域> <内容> |
添加记忆。选项:--tag,--link |
| recall <查询> | 搜索。选项:--domain,--top N |
| walk | 遍历所有记忆,报告健康状况 |
| prune | 移除衰减记忆。选项:--threshold,--dry-run |
| status | 所有领域概览 |
| inspect
| 查看记忆详情及链接 |
| link | 连接两条记忆 |
| domains | 列出/添加/删除领域 |
| export | 导出为markdown或JSON。选项:--format md\|yaml |
与心跳检测集成
在心跳检测漫步期间,运行:
bash
$LOCI walk --decay 0.05
这将报告领域健康状况,识别正在消退的记忆,并更新漫步时间戳。
定期执行 $LOCI prune --dry-run 以审查可移除的候选记忆。
何时存储与何时跳过
存储: 决策、用户偏好、环境特性、经验教训、重要人物/关系、重复模式。
跳过: 临时任务细节、一次性命令、已存在于日常记忆文件中的内容。
经验法则: 如果两周后的你会因知晓此信息而受益,就存储它。
宫殿文件
默认位置:~/.openclaw/workspace/loci_palace.json
通过任意命令中的 --palace PATH 覆盖。
格式:JSON。零外部依赖——仅需Node.js(随OpenClaw一起提供)。