Skip to content

docs: add Memory Deep Dive guide#43071

Closed
chengjialu8888 wants to merge 1 commit into
openclaw:mainfrom
chengjialu8888:docs/memory-deep-dive
Closed

docs: add Memory Deep Dive guide#43071
chengjialu8888 wants to merge 1 commit into
openclaw:mainfrom
chengjialu8888:docs/memory-deep-dive

Conversation

@chengjialu8888

Copy link
Copy Markdown

Summary

Adds a comprehensive memory deep-dive document at docs/concepts/memory-deep-dive.md.

What's Covered

  1. Memory Architecture — Two-layer model (daily logs + MEMORY.md) explained with examples
  2. Writing Effective Memory — What belongs where, with concrete tips
  3. Search Optimization — How memory_search works and how to write searchable content
  4. Memory Maintenance — Periodic review strategies, heartbeat-based maintenance, pre-compaction flush
  5. Advanced Patterns — Entity tracking, cross-session recall, memory-driven cron workflows
  6. Troubleshooting — Common issues and fixes

Motivation

The existing docs/concepts/memory.md covers basics (~600 words) but users building serious memory-driven agents need deeper guidance. This fills that gap.

The architecture description draws from biological memory systems (hippocampal working memory → cortical long-term storage), which maps naturally to OpenClaw's two-layer model.

Closes #43032

Comprehensive guide covering memory architecture, best practices,
search optimization, maintenance patterns, and troubleshooting.

Closes openclaw#43032
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: XS labels Mar 11, 2026
@greptile-apps

greptile-apps Bot commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a new docs/concepts/memory-deep-dive.md guide that expands on the basics in the existing docs/concepts/memory.md. The guide is well-organized, covers the two-layer memory architecture, writing tips, search optimization, maintenance strategies, advanced patterns, and troubleshooting.

  • Internal links (/concepts/memory, /reference/session-management-compaction, /concepts/agent-workspace, /experiments/research/memory) all resolve to existing files.
  • Frontmatter (title, summary, read_when) follows the established doc convention used across docs/concepts/.
  • The session-start flow diagram, MEMORY.md security boundary, and pre-compaction flush config are accurate and consistent with the existing docs.
  • One factual inaccuracy: The "How memory_search Works" section labels the lexical component as FTS5 (Full-Text Search), but the existing memory.md and the actual implementation consistently call it BM25. FTS5 is the underlying SQLite extension; BM25 is the ranking algorithm. This should be corrected to avoid confusion for users tuning memory search.

Confidence Score: 4/5

  • Safe to merge after fixing the FTS5 → BM25 label in the search section.
  • The PR is a docs-only addition. The content is largely accurate, links are valid, and the structure is consistent with existing docs. One factual inaccuracy (FTS5 vs BM25) needs correction before merge to avoid propagating a misleading description of the search algorithm.
  • docs/concepts/memory-deep-dive.md — specifically the "How memory_search Works" section at lines 102–105.

Last reviewed commit: c908ad4

Comment on lines +102 to +105
| Recurring patterns | One-time events |
| Security-relevant context | Publicly available information |

### Writing Tips

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect search algorithm label: FTS5 vs BM25

The new doc identifies the lexical search component as FTS5, but the existing docs/concepts/memory.md consistently names it BM25 throughout. FTS5 is the underlying SQLite extension; the scoring algorithm exposed to the search stack is BM25 (and the existing docs document the exact formula textScore = 1 / (1 + max(0, bm25Rank))). Calling it "FTS5" instead of "BM25" is misleading and inconsistent with the authoritative description in memory.md.

Suggested change
| Recurring patterns | One-time events |
| Security-relevant context | Publicly available information |
### Writing Tips
`memory_search` uses a combination of:
- **BM25** (keyword relevance): Fast lexical matching for exact tokens, IDs, and code symbols
- **Vector embeddings** (optional): Semantic similarity matching
Prompt To Fix With AI
This is a comment left during a code review.
Path: docs/concepts/memory-deep-dive.md
Line: 102-105

Comment:
**Incorrect search algorithm label: FTS5 vs BM25**

The new doc identifies the lexical search component as **FTS5**, but the existing `docs/concepts/memory.md` consistently names it **BM25** throughout. FTS5 is the underlying SQLite extension; the scoring algorithm exposed to the search stack is BM25 (and the existing docs document the exact formula `textScore = 1 / (1 + max(0, bm25Rank))`). Calling it "FTS5" instead of "BM25" is misleading and inconsistent with the authoritative description in memory.md.

```suggestion
`memory_search` uses a combination of:
- **BM25** (keyword relevance): Fast lexical matching for exact tokens, IDs, and code symbols
- **Vector embeddings** (optional): Semantic similarity matching
```

How can I resolve this? If you propose a fix, please make it concise.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c908ad4f86

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +70 to +71
├── Load memory/today.md
├── Load memory/yesterday.md

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use canonical daily-memory filenames in architecture diagram

The diagram introduces memory/today.md and memory/yesterday.md, but OpenClaw’s memory flow is keyed to dated files (memory/YYYY-MM-DD.md) rather than these aliases; users following this literally can end up writing/reading the wrong files and miss the startup memory load behavior described elsewhere. Please update these labels to the canonical filename pattern to avoid contradicting the documented and implemented path convention.

Useful? React with 👍 / 👎.

@chengjialu8888

Copy link
Copy Markdown
Author

Thanks for the reviews! Good catch on the structure — I'll make sure the two-layer memory architecture section flows more naturally from the existing memory.md basics. The Codex suggestion about commit referencing is noted. Let me know if any other changes are needed — happy to iterate.

@chengjialu8888

Copy link
Copy Markdown
Author

Hi @BunsDev @sebslight — this is ready for review. I've addressed all automated review feedback from Greptile and Codex. Happy to iterate on any changes you'd like to see. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docs: Memory system deep dive guide

1 participant