Overview
The OpenClaw plugin gives claude-mem persistent memory to agents running on the OpenClaw gateway. It handles three things:- Observation recording — Captures tool usage from OpenClaw’s embedded runner and sends it to the claude-mem worker for AI processing
- MEMORY.md live sync — Writes a continuously-updated timeline to each agent’s workspace so agents always have context from previous sessions
- Observation feed — Streams new observations to messaging channels (Telegram, Discord, Slack, etc.) in real-time via SSE
OpenClaw’s embedded runner (
pi-embedded) calls the Anthropic API directly without spawning a claude process, so claude-mem’s standard hooks never fire. This plugin bridges that gap by using OpenClaw’s event system to capture the same data.How It Works
Event Lifecycle
Agent starts (before_agent_start)
When an OpenClaw agent starts, the plugin does two things:
-
Syncs MEMORY.md — Fetches the latest timeline from the worker’s
/api/context/injectendpoint and writes it toMEMORY.mdin the agent’s workspace directory. This gives the agent context from all previous sessions before it starts working. -
Initializes a session — Sends the user prompt to
POST /api/sessions/initso the worker can create a new session and start processing.
Tool use recorded (tool_result_persist)
Every time the agent uses a tool (Read, Write, Bash, etc.), the plugin:
- Sends the observation to
POST /api/sessions/observationswith the tool name, input, and truncated response (max 1000 chars) - Re-syncs MEMORY.md with the latest timeline from the worker
memory_ are skipped to avoid recursive recording.Agent finishes (agent_end)
When the agent completes, the plugin extracts the last assistant message and sends it to
POST /api/sessions/summarize, then calls POST /api/sessions/complete to close the session. Both are fire-and-forget.MEMORY.md Live Sync
The plugin writes aMEMORY.md file to each agent’s workspace directory containing the full timeline of observations and summaries from previous sessions. This file is updated:
- On every
before_agent_startevent (agent gets fresh context before starting) - On every
tool_result_persistevent (context stays current during the session)
GET /api/context/inject?projects=<project> endpoint, which generates a formatted markdown timeline from the SQLite database.
MEMORY.md updates are fire-and-forget. They run in the background without blocking the agent. The file reflects whatever the worker has processed so far — it doesn’t wait for the current observation to be fully processed before writing.
Observation Feed (SSE → Messaging)
The plugin runs a background service that connects to the worker’s SSE stream (GET /stream) and forwards new_observation events to a configured messaging channel. This lets you monitor what your agents are learning in real-time from Telegram, Discord, Slack, or any supported OpenClaw channel.
The SSE connection uses exponential backoff (1s → 30s) for automatic reconnection.
Setting Up the Observation Feed
The observation feed sends a formatted message to your OpenClaw channel every time claude-mem creates a new observation. Each message includes the observation title and subtitle so you can follow along as your agents work. Messages look like this in your channel:Step 1: Choose your channel
The observation feed works with any channel that your OpenClaw gateway has configured. You need two pieces of information:- Channel type — The name of the channel plugin registered with OpenClaw (e.g.,
telegram,discord,slack,signal,whatsapp,line) - Target ID — The chat ID, channel ID, or user ID where messages should be sent
Telegram
Telegram
Channel type:
telegramTarget ID: Your Telegram chat ID (numeric). To find it:- Message @userinfobot on Telegram
- It will reply with your chat ID (e.g.,
123456789) - For group chats, the ID is negative (e.g.,
-1001234567890)
Discord
Discord
Channel type:
discordTarget ID: The Discord channel ID. To find it:- Enable Developer Mode in Discord (Settings → Advanced → Developer Mode)
- Right-click the channel → Copy Channel ID
Slack
Slack
Channel type:
slackTarget ID: The Slack channel ID (not the channel name). To find it:- Open the channel in Slack
- Click the channel name at the top
- Scroll to the bottom of the channel details — the ID looks like
C01ABC2DEFG
Signal
Signal
Channel type:
signalTarget ID: The Signal phone number or group ID configured in your OpenClaw gateway.WhatsApp
Channel type:
whatsappTarget ID: The WhatsApp phone number or group JID configured in your OpenClaw gateway.LINE
LINE
Channel type:
lineTarget ID: The LINE user ID or group ID from the LINE Developer Console.Step 2: Add the config to your gateway
Add theobservationFeed block to your claude-mem plugin config in your OpenClaw gateway configuration:
Step 3: Verify the connection
After starting the gateway, check that the feed is connected:-
Check the logs — You should see:
-
Use the status command — Run
/claude-mem-feedin any OpenClaw chat to see: - Trigger a test — Have an agent do some work. When the worker processes the tool usage into an observation, you’ll receive a message in your configured channel.
The feed only sends
new_observation events — not raw tool usage. Observations are generated asynchronously by the worker’s AI agent, so there’s a 1-2 second delay between tool use and the observation message appearing in your channel.Troubleshooting the Feed
| Symptom | Cause | Fix |
|---|---|---|
Connection: disconnected | Worker not running or wrong port | Check workerPort config, run npm run worker:status |
Connection: reconnecting | Worker was running but connection dropped | The plugin auto-reconnects with backoff — wait up to 30s |
Unknown channel type in logs | Channel plugin not loaded on gateway | Verify your OpenClaw gateway has the channel plugin configured |
| No messages appearing | Feed connected but no observations being created | Check that agents are running and the worker is processing observations |
Observation feed disabled in logs | enabled is false or missing | Set observationFeed.enabled to true |
Observation feed misconfigured in logs | Missing channel or to | Both channel and to are required |
Installation
Addclaude-mem to your OpenClaw gateway’s plugin configuration:
The claude-mem worker service must be running on the same machine as the OpenClaw gateway. The plugin communicates with it via HTTP on
localhost:37777.Configuration
Project name for scoping observations in the memory database. All observations from this gateway will be stored under this project name.
Enable automatic MEMORY.md sync to agent workspaces. Set to
false if you don’t want the plugin writing files to workspace directories.Port for the claude-mem worker service. Override if your worker runs on a non-default port.
Enable live observation streaming to messaging channels.
Channel type:
telegram, discord, signal, slack, whatsapp, lineTarget chat/user/channel ID to send observations to.
Commands
/claude-mem-feed
Show or toggle the observation feed status./claude-mem-status
Check worker health and session status.Architecture
The plugin uses HTTP calls to the already-running claude-mem worker service rather than spawning subprocesses. This means:- No
bundependency required on the gateway - No process spawn overhead per event
- Uses the same worker API that Claude Code hooks use
- All operations are non-blocking (fire-and-forget where possible)
Session Tracking
Each OpenClaw agent session gets a uniquecontentSessionId (format: openclaw-<sessionKey>-<timestamp>) that maps to a claude-mem session in the worker. The plugin tracks:
sessionIds— Maps OpenClaw session keys to content session IDsworkspaceDirsBySessionKey— Maps session keys to workspace directories sotool_result_persistevents can sync MEMORY.md even when the event context doesn’t includeworkspaceDir
gateway_start.
Requirements
- Claude-mem worker service running on
localhost:37777(or configured port) - OpenClaw gateway with plugin support
- Network access between gateway and worker (localhost only)

