memory-cn
OpenClaw + Ollama 中文记忆系统优化。诊断 FTS5 unicode61 中文分词 bug,优化搜索参数,自动维护记忆文件。命中率从 55% 提升到 100%。
Best use case
memory-cn is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
OpenClaw + Ollama 中文记忆系统优化。诊断 FTS5 unicode61 中文分词 bug,优化搜索参数,自动维护记忆文件。命中率从 55% 提升到 100%。
Teams using memory-cn should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/memory-cn/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How memory-cn Compares
| Feature / Agent | memory-cn | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
OpenClaw + Ollama 中文记忆系统优化。诊断 FTS5 unicode61 中文分词 bug,优化搜索参数,自动维护记忆文件。命中率从 55% 提升到 100%。
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
SKILL.md Source
# 中文记忆优化 Skill (memory-cn)
当用户请求诊断或优化记忆系统时,按以下步骤执行:
## 1. 诊断
运行诊断脚本检测问题:
```bash
bash SKILL_DIR/scripts/diagnose.sh
```
报告包括:
- FTS5 中文分词 bug 检测(unicode61 把连续中文粘成一个 token)
- 记忆文件大小分布
- tags 标签覆盖率
- lessons 知识库健康度
## 2. 优化搜索配置
如果诊断发现问题,应用优化配置:
```json
{
"agents": {
"defaults": {
"memorySearch": {
"chunking": { "tokens": 250, "overlap": 60 },
"query": {
"maxResults": 10,
"minScore": 0.15,
"hybrid": {
"enabled": true,
"vectorWeight": 0.75,
"textWeight": 0.25,
"candidateMultiplier": 8,
"mmr": { "enabled": true, "lambda": 0.7 },
"temporalDecay": { "enabled": true, "halfLifeDays": 90 }
}
}
}
}
}
}
```
使用 `gateway config.patch` 应用。
## 3. 优化 memoryFlush prompt
让新日志自动加 tags + 中文分词:
```json
{
"agents": {
"defaults": {
"compaction": {
"memoryFlush": {
"prompt": "将对话内容整理为结构化日志,写入 memory/YYYY-MM-DD.md。\n\n格式要求:\n1. 文件第一行必须是 <!-- tags: 关键词1, 关键词2, ... --> 标签行\n2. 中文关键词之间加空格分隔\n3. 只保留有价值的信息\n4. 控制在 5KB 以内"
}
}
}
}
}
```
## 4. 批量加 tags
对 memory/projects/*.md 中缺少 tags 的文件,根据内容自动添加 `<!-- tags: ... -->` 行。
```bash
python3 SKILL_DIR/scripts/add-tags.py /path/to/memory/projects/
```
## 5. 压缩日志
压缩 >8KB 的旧日志到 <5KB,原文备份到 archive/:
```bash
python3 SKILL_DIR/scripts/compress-logs.py /path/to/memory/ --max-kb 5
```
## 6. 重建索引
```bash
openclaw memory index --force
```
## 7. 设置自动维护 cron
建议每周日凌晨自动执行压缩+清理+补标签+重建索引。
## 关键技术点
### FTS5 unicode61 Bug
- `unicode61` 分词器把连续 CJK 字符当作一个 token
- 搜索 "怀孕" 无法匹配 "老婆刚怀孕"(因为后者是一个 token)
- Workaround:中文关键词之间加空格 → FTS5 正确分词
### 0.6B 模型参数调优
- vectorWeight 0.75:向量主导(FTS5 中文不可靠)
- minScore 0.15:小模型分数普遍偏低
- chunking 250 tokens:更小的 chunk 帮助弱模型匹配
### 三层架构
- P0 (MEMORY.md):核心事实,<2KB
- P1 (projects/ + lessons/):按需搜索,带 tags
- P2 (日志 + archive):历史记录Related Skills
Agent Memory Architecture
Complete zero-dependency memory system for AI agents — file-based architecture, daily notes, long-term curation, context management, heartbeat integration, and memory hygiene. No APIs, no databases, no external tools. Works with any agent framework.
memory-cache
High-performance temporary storage system using Redis. Supports namespaced keys (mema:*), TTL management, and session context caching. Use for: (1) Saving agent state, (2) Caching API results, (3) Sharing data between sub-agents.
Memory
Infinite organized memory that complements your agent's built-in memory with unlimited categorized storage.
auto-memory
Indestructible agent memory — permanently stored, never lost. Save decisions, identity, and context as a memory chain on the Autonomys Network. Rebuild your full history from a single CID, even after total state loss.
Triple-Layer Memory System
三层记忆系统 - 解决 AI Agent 长对话记忆丢失和上下文管理问题
agent-memory-os
Stop agents from "forgetting, mixing projects, and rotting over time" by giving them a practical memory operating system: global memory, project memory, promotion rules, validation cases, and a maintenance loop.
benos-memory-core
Core runtime/volatile memory module for BenOS agent environment. Use to: store and retrieve active session state, open loops, decisions, and scratch notes at runtime.
elite-longterm-memory
Ultimate AI agent memory system with WAL protocol, vector search, git-notes, and cloud backup. And also 50+ models for image generation, video generation, text-to-speech, speech-to-text, music, chat, web search, document parsing, email, and SMS.
memory-agent
维护用户审美偏好与创作历史,为其他 Agent 提供可复用的风格参考。当开始新任务或用户表达喜好时触发。
bamdra-memory-upgrade-operator
Safely install, uninstall, reinstall, or upgrade the Bamdra OpenClaw memory suite when stale config, existing plugin directories, or partial installs break normal `openclaw plugins install` flows.
hierarchical-memory
Manage and navigate a multi-layered, branch-based memory system. This skill helps organize complex agent context into Root, Domain, and Project layers to prevent context bloat. It includes a helper script `add_branch.py` which creates local markdown files and directories to structure your memory.
agentmemory
End-to-end encrypted cloud memory for AI agents. 100GB free storage. Store memories, files, and secrets securely.