Memory Manager
Header: claw_memory.h
Init configuration
Section titled “Init configuration”Common fields in claw_memory_config_t:
| Field | Meaning | basic_demo default |
|---|---|---|
session_root_dir | Root for session history files | /fatfs/sessions |
memory_root_dir | Long-term memory directory (claw_memory manages MEMORY.md and all structured memory files under this directory) | /fatfs/memory |
max_session_messages | Max messages kept per session | 20 |
max_message_chars | Max characters per message | 1024 |
enable_async_extract_stage_note | Enable async extract-stage notes for structured memory | true in full mode |
max_session_messages and max_message_chars together bound history size to avoid unbounded growth on flash and oversized history in prompts.
Wiring into claw_core
Section titled “Wiring into claw_core”claw_memory connects via multiple Context Providers and Callback:
Context Providers (registered after claw_core_init):
claw_memory_profile_provider: inject editable profile/persona files (user.md/soul.md/identity.md).claw_memory_long_term_provider(full mode): inject only the long-term summary-tag catalog, not the full memory text.claw_memory_long_term_lightweight_provider(lightweight mode): injectMEMORY.mdtext directly.claw_memory_session_history_provider: inject recent turns for the current session.
Write-back Callback:
claw_memory_append_session_turn_callback: passed asclaw_core_config_t.append_session_turn; after each Agent turn, user/assistant text is appended to the session file.- Full mode also enables
on_request_startandcollect_stage_notefor structured-memory auto-extraction.
Long-term memory file layout
Section titled “Long-term memory file layout”basic_demo uses claw_memory_init to create required memory files under /fatfs/memory/:
Directoryfatfs/
Directorymemory/
- memory_records.jsonl Structured memory records
- memory_index.json Summary-tag and keyword index
- memory_digest.log Memory-operation digest log
- MEMORY.md Human-readable memory view (read-only)
- user.md User profile
- soul.md Persona
- identity.md Identity
Memory Init fields, full/lightweight mode differences, and memory directory layout