# chat-logger-plugin **Version:** v1.0.1 Logs recent chat turns to `/tmp/openclaw-chat.log` so the mem0 auto-capture hook can attach the *previous assistant* reply when storing conversational memories. ## What it does - Listens to `session_start`, `message_received`, and `agent_end` events - Resolves the best available `sessionKey` and caches it - Writes the **last two turns** (user + assistant) to `/tmp/openclaw-chat.log` ## Why it matters The mem0 hook reads the log to retrieve the last assistant reply and include it in the capture payload. This avoids losing context when auto-capturing a new user message. ## Output format Each log line is a JSON object: ```json { "ts": "2026-03-16T02:30:46.827Z", "sessionKey": "agent:main:main", "messages": [ { "role": "user", "content": "..." }, { "role": "assistant", "content": "..." } ] } ``` ## Install / reload 1) Edit in `workspace/chat-logger-plugin/` 2) Restart gateway so the plugin is reloaded ## Related - Hook: `workspace/hooks/mem0-auto-capture/hook/handler.ts` - The hook falls back to the latest assistant message if sessionKey is missing.