Install
openclaw skills install cyber-memoryFive-layer memory system with automatic fact extraction via local LLM (Ollama). Processes session transcripts locally — no external API required.
openclaw skills install cyber-memoryA complete memory system for OpenClaw agents. Five layers of storage, automatic fact extraction via local LLM, hybrid search, and behavioral rules that prevent context loss.
🔒 Local-first by default — all fact extraction runs on your local Ollama instance. No data leaves your machine.
This skill includes a hook (memory-flush) that:
~/.openclaw/agents/*/sessions/*.jsonl)What is processed: Recent user/assistant messages (last 30 messages, each truncated to 500 chars).
Where it runs: Local Ollama endpoint (http://localhost:11434/v1/chat/completions by default).
What is saved locally: Extracted facts as Markdown files in workspace/memory/.
Optional: You can configure an external OpenAI-compatible API by setting baseUrl and apiKey in the hook config, but local Ollama is the default and recommended setup.
🔥 Hot → SESSION-STATE.md (WAL protocol, survives compaction)
🌤 Warm → memory/YYYY-MM-DD.md (daily event summaries)
🧊 Cold → MEMORY.md (decisions, preferences, rules — always loaded)
🕸 Graph → memory/ontology/ (entity relationships)
📚 Learn → .learnings/ (errors, best practices)
| Mechanism | Trigger | What it does |
|---|---|---|
| session-memory (built-in) | /new /reset | Saves conversation to memory/ |
| memory-flush (this skill) | Compaction + /new | LLM extracts structured facts (local Ollama) |
| command-logger (built-in) | Any command | Audit log |
| session indexing | Automatic | Historical sessions searchable |
Install Ollama and pull a chat model:
# Install Ollama (https://ollama.ai)
ollama pull qwen2.5:7b # or any chat model you prefer
ollama serve # ensure Ollama is running on localhost:11434
openclaw hooks enable session-memory
openclaw hooks enable command-logger
Copy the hooks/memory-flush/ directory to ~/.openclaw/hooks/:
cp -r hooks/memory-flush ~/.openclaw/hooks/
openclaw hooks enable memory-flush
By default, the hook uses local Ollama — no configuration needed. To customize:
{
hooks: {
internal: {
enabled: true,
entries: {
"memory-flush": {
enabled: true,
extractionModel: "qwen2.5:7b", // Ollama model name
baseUrl: "http://localhost:11434/v1/chat/completions" // Ollama endpoint
}
}
}
}
}
Works with any OpenAI-compatible API (Ollama, LM Studio, vLLM, etc.). Set baseUrl and apiKey to use an external provider.
{
agents: {
defaults: {
memorySearch: {
provider: "local", // or "openai", "ollama", "gemini", "voyage", etc.
experimental: {
sessionMemory: true
},
sources: ["memory", "sessions"],
extraPaths: ["SESSION-STATE.md"]
}
}
}
}
openclaw gateway restart
Add these rules to your AGENTS.md:
memory_search for historical queriesWhen spawning sub-agents, inject relevant context from MEMORY.md:
[Key context from memory, max 500 words]
---
[Actual task]
workspace/
├── AGENTS.md # Behavioral rules (loaded every session)
├── SOUL.md # Agent personality
├── USER.md # User preferences
├── TOOLS.md # Tool notes (keep lean, <2KB)
├── MEMORY.md # Long-term curated memory
├── SESSION-STATE.md # Hot working memory (WAL)
├── memory/
│ ├── YYYY-MM-DD.md # Daily logs (summaries only)
│ ├── YYYY-MM-DD-facts-* # Auto-extracted facts
│ ├── YYYY-MM-DD-compact # Pre-compaction snapshots
│ └── ontology/
│ ├── graph.jsonl # Knowledge graph
│ └── schema.yaml # Entity type definitions
├── .learnings/
│ ├── LEARNINGS.md # Best practices
│ ├── ERRORS.md # Error log
│ └── FEATURE_REQUESTS.md
└── hooks/
└── memory-flush/
├── HOOK.md
└── handler.ts # LLM fact extraction (local Ollama default)
| File | When |
|---|---|
| AGENTS.md, SOUL.md, USER.md, TOOLS.md | Every session start |
| MEMORY.md | DM session start |
| memory/today + yesterday | Every session start |
| SESSION-STATE.md | Via memory_search (indexed) |
| Other memory files | Via memory_search on demand |
tools/ subdirectoryFacts not extracted? Check Ollama is running (ollama serve) and the model is available (ollama list).
Session search not working? Verify experimental.sessionMemory: true and sources: ["memory", "sessions"].
Hook not loading? Run openclaw hooks list --verbose and check for errors.
Want to use external API? Set baseUrl and apiKey in the hook config to use OpenAI or any compatible provider.
MIT