|
@@ -1,10 +1,12 @@
|
|
|
# mem0-auto-capture hook
|
|
# mem0-auto-capture hook
|
|
|
|
|
|
|
|
|
|
+**Version:** v1.0.1
|
|
|
|
|
+
|
|
|
A self-contained OpenClaw hook that wires incoming messages to your Mem0 instance for auto-capture and auto-recall. It runs as a message hook inside the OpenClaw gateway, transcribes audio, decides what to store, queries memories/knowledge before the agent responds, and injects the results back into the prompt.
|
|
A self-contained OpenClaw hook that wires incoming messages to your Mem0 instance for auto-capture and auto-recall. It runs as a message hook inside the OpenClaw gateway, transcribes audio, decides what to store, queries memories/knowledge before the agent responds, and injects the results back into the prompt.
|
|
|
|
|
|
|
|
## Key behaviors
|
|
## Key behaviors
|
|
|
|
|
|
|
|
-1. **Auto-Capture** — whenever a received message matches the configured trigger (default: every message or the phrase “please remember”), the hook gathers the most recent lines from that session (controlled by `recentKeep`) and POSTs them to `<baseUrl>/memories` with the resolved user id. It deduplicates captures by hashing the text and short-circuiting identical payloads within one minute.
|
|
|
|
|
|
|
+1. **Auto-Capture** — whenever a received message matches the configured trigger (default: every message or the phrase “please remember”), the hook POSTs the **current user input** plus the **previous assistant reply** to `<baseUrl>/memories` with the resolved user id. It deduplicates captures by hashing the payload and short-circuiting identical sends within one minute.
|
|
|
|
|
|
|
|
2. **Auto-Recall** — before the agent answers (on the `preprocessed` or `transcribed` event) it queries `<baseUrl>/memories/search` (conversational memory only), filters by rerank score, and injects `[MEMORY - Personal]` into `bodyForAgent`. Knowledge base retrieval is now tool-only.
|
|
2. **Auto-Recall** — before the agent answers (on the `preprocessed` or `transcribed` event) it queries `<baseUrl>/memories/search` (conversational memory only), filters by rerank score, and injects `[MEMORY - Personal]` into `bodyForAgent`. Knowledge base retrieval is now tool-only.
|
|
|
|
|
|
|
@@ -26,7 +28,6 @@ All options are read from environment variables (prefixed `MEM0_`) or a JSON fil
|
|
|
| `triggerPhrase` | `MEM0_TRIGGER_PHRASE` | `please remember` | Used when `captureTrigger` is `phrase`. |
|
|
| `triggerPhrase` | `MEM0_TRIGGER_PHRASE` | `please remember` | Used when `captureTrigger` is `phrase`. |
|
|
|
| `autoCapture` | `MEM0_AUTO_CAPTURE` | `true` | Enable/disable captures. |
|
|
| `autoCapture` | `MEM0_AUTO_CAPTURE` | `true` | Enable/disable captures. |
|
|
|
| `autoRecall` | `MEM0_AUTO_RECALL` | `true` | Enable/disable recalls. |
|
|
| `autoRecall` | `MEM0_AUTO_RECALL` | `true` | Enable/disable recalls. |
|
|
|
-| `recentKeep` | `MEM0_RECENT_KEEP` | `5` | How many lines of recent context to bundle for a capture. |
|
|
|
|
|
| `debugCapture` | `MEM0_DEBUG_CAPTURE` | `false` | When `true`, logs full outgoing `messages` payload for capture; otherwise logs only summary counts. |
|
|
| `debugCapture` | `MEM0_DEBUG_CAPTURE` | `false` | When `true`, logs full outgoing `messages` payload for capture; otherwise logs only summary counts. |
|
|
|
|
|
|
|
|
> Example `~/.openclaw/mem0.json`:
|
|
> Example `~/.openclaw/mem0.json`:
|
|
@@ -78,7 +79,7 @@ All options are read from environment variables (prefixed `MEM0_`) or a JSON fil
|
|
|
- `README.md` & `PROJECT.md` — explain intent, configuration, and deployment.
|
|
- `README.md` & `PROJECT.md` — explain intent, configuration, and deployment.
|
|
|
|
|
|
|
|
## Recent implementation notes
|
|
## Recent implementation notes
|
|
|
-- **Assistant lookup fallback:** auto-capture first tries to fetch the previous assistant message by matching `sessionKey` in `/tmp/openclaw-chat.log`. If that fails, it falls back to the latest assistant message globally, logs a warning, and still sends the capture.
|
|
|
|
|
|
|
+- **Assistant lookup:** auto-capture grabs the previous assistant reply by scanning the session JSONL (via `sessions.json`) for the last assistant message **before** the current user event. It falls back to `/tmp/openclaw-chat.log` only if the session file is unavailable.
|
|
|
- **Capture payload shape:** auto-capture sends `messages: [...]` to `/memories` in all cases. Minimum payload is one user item; assistant entry is appended when available.
|
|
- **Capture payload shape:** auto-capture sends `messages: [...]` to `/memories` in all cases. Minimum payload is one user item; assistant entry is appended when available.
|
|
|
- **Personal memory age prefix:** injected `[MEMORY - Personal]` lines prepend age from `created_at` when present (for example `[25m ago]` / `[1d ago]`).
|
|
- **Personal memory age prefix:** injected `[MEMORY - Personal]` lines prepend age from `created_at` when present (for example `[25m ago]` / `[1d ago]`).
|
|
|
|
|
|