Enhanced workspace memory with auto-recall and auto-capture for OpenClaw.
memory-core-plus is an OpenClaw plugin that extends the built-in memory-core with two automated hooks:
- Auto-Recall -- Before each LLM turn, semantically search workspace memory and inject relevant memories into the prompt context.
- Auto-Capture -- After each agent run, extract durable facts, preferences, and decisions from the conversation and persist them to memory files.
Together they form a closed-loop memory system: information captured from past conversations is automatically surfaced when contextually relevant in future interactions.
openclaw plugins install memory-core-plusopenclaw plugins install memory-core-plusThis single command does the following:
- Downloads and installs the plugin to
~/.openclaw/extensions/memory-core-plus/ - Enables the plugin (
plugins.entries.memory-core-plus.enabled = true) - Sets the memory slot (
plugins.slots.memory = "memory-core-plus") - Disables competing memory plugins (e.g. built-in
memory-core)
Restart the gateway to load the plugin:
openclaw gateway restartAuto-recall and auto-capture are both enabled by default. To disable either:
openclaw config set plugins.entries.memory-core-plus.config.autoRecall false
openclaw config set plugins.entries.memory-core-plus.config.autoCapture falseImportant: The
plugins.slots.memoryfield must be set to"memory-core-plus"to activate this plugin as the memory provider. Runningopenclaw plugins install memory-core-plushandles slot assignment and enabling automatically. Useopenclaw plugins enable memory-core-plusonly to re-enable after a previousplugins disable. Do not enablememory-coreat the same time -- they would register duplicate tools.
| Key | Type | Default | Description |
|---|---|---|---|
autoRecall |
boolean |
true |
Enable automatic memory recall before each agent turn |
autoRecallMaxResults |
number |
5 |
Maximum number of memories to inject per turn |
autoRecallMinPromptLength |
number |
5 |
Minimum prompt length (chars) to trigger recall |
autoCapture |
boolean |
true |
Enable automatic memory capture after each agent run |
autoCaptureMaxMessages |
number |
10 |
Maximum recent messages to analyze for capture |
To remove this plugin and revert to the built-in memory-core:
# Uninstall — removes config entry, memory slot, and installed files
openclaw plugins uninstall memory-core-plus
# Restart gateway — memory-core will be used as the default memory provider
openclaw gateway restartAfter uninstalling, the gateway falls back to the built-in memory-core plugin automatically. No extra configuration is needed.
Registered on the before_prompt_build hook. Triggered every time the user sends a message, before the LLM processes it.
flowchart LR
A[Prompt] --> B{Length OK?}
B -- No --> X[Skip]
B -- Yes --> C{Memory trigger?}
C -- Yes --> X
C -- No --> D{Manager ready?}
D -- No --> X
D -- Yes --> E[Vector search]
E --> F{Score >= min?}
F -- No --> X
F -- Yes --> G[Inject memories]
G --> H[LLM processes]
Processing steps:
- When the user sends a prompt, the hook first checks whether the prompt length meets the
autoRecallMinPromptLengththreshold. Very short inputs (e.g. "hi") are skipped. - If the current trigger is
"memory", the hook exits to avoid recall during memory-related subagent runs. - The hook obtains the memory search manager. If no manager is available (e.g. embeddings are not configured), the hook exits.
- The prompt is used as a query for semantic vector search across all workspace memory files.
- Results are filtered by the core search manager's
minScorethreshold (memorySearch.query.minScoreinopenclaw.json). Only memories above this score are returned. - Matching memories are formatted as
<relevant-memories>XML (marked as untrusted data to prevent prompt injection) and prepended to the user prompt via the hook'sprependContextfield. - The LLM then sees the original user question together with relevant historical context.
The recall hook skips execution when:
- The prompt is shorter than
autoRecallMinPromptLength - The trigger is
"memory"(avoids recall during memory-related subagent runs) - No memory search manager is available (e.g., no embeddings configured)
Registered on the agent_end hook. Triggered every time an agent run completes.
flowchart LR
A[Agent ends] --> B{Memory session?}
B -- Yes --> X[Skip]
B -- No --> C[Get messages]
C --> D[Strip & filter]
D --> E{Capturable?}
E -- No --> X
E -- Yes --> F[LLM extract]
F --> G[Write to memory file]
Processing steps:
- When an agent run completes, the hook checks recursion guards: if
ctx.trigger === "memory"orctx.sessionKeycontains:memory-capture:, capture is skipped to prevent infinite loops. - The most recent user and assistant messages are extracted (up to
autoCaptureMaxMessages). - Any
<relevant-memories>blocks injected by the recall hook are stripped from the text, so previously recalled content is not re-persisted as new memory. - Each message is checked via
isCapturableMessage(), which filters out: text that is too short or too long, code blocks, HTML/XML markup, headings, suspected prompt injections, and messages with excessive emojis. - If capturable content exists, an LLM subagent is spawned to extract durable facts, preferences, and decisions as bullet points.
- The extracted facts are appended to
memory/YYYY-MM-DD.md. AnidempotencyKeyprevents duplicate captures within the same run.
The capture hook includes multiple recursion guards:
- Checks
ctx.trigger === "memory"to skip memory-triggered runs - Checks
ctx.sessionKeyfor:memory-capture:marker (the subagent uses this session key pattern) - Uses
idempotencyKeyto prevent duplicate captures
- Prompt injection detection: Messages containing patterns like "ignore previous instructions", "you are now", "jailbreak", etc. are filtered out before capture.
- HTML entity escaping: All memory content injected into prompts is escaped (
&,<,>,",') to prevent markup injection. - Untrusted data marking: Recalled memories are wrapped in
<relevant-memories>tags with an explicit instruction to treat them as untrusted historical data. - Recall marker stripping: Before capture, any
<relevant-memories>blocks are stripped from conversation text to avoid persisting injected context as new memories. - Recursion prevention: The capture subagent's session key contains
:memory-capture:, and the hook checks bothtriggerandsessionKeyto break potential infinite loops.
This plugin is a superset of the built-in memory-core plugin. It inherits and re-registers the same memory_search and memory_get tools, as well as the memory CLI command. On top of that, it adds the auto-recall and auto-capture hooks.
MIT
{ "plugins": { "entries": { "memory-core-plus": { "enabled": true, "config": { "autoRecall": true, "autoCapture": true } } }, "slots": { "memory": "memory-core-plus" } } }