OpenClaw Hook Pack: Automatic Memory for Your Agent


If you run OpenClaw, you can add persistent memory without changing your agent’s code. One command installs hooks that automatically store and recall memories at the right moments.

Install

openclaw hooks install memoclaw

That’s the whole setup. If you haven’t initialized MemoClaw yet, it’ll run memoclaw init for you and generate a wallet.

What the hooks do

The hook pack adds three hooks to your OpenClaw agent:

on_session_start — When a new session begins, the hook takes the first message (or session context) and recalls relevant memories. These get injected into the system prompt as additional context. Your agent doesn’t see the mechanism, it just has relevant background.

# What happens under the hood:
# 1. User sends first message: "Let's continue working on the API"
# 2. Hook runs: memoclaw recall "working on the API" --limit 5
# 3. Results injected into system context:
#    - "API uses tRPC v11 with RSC support"
#    - "Auth is handled by wallet signature, no JWT"
#    - "Rate limiting is 100 req/min per wallet"

on_session_end — When a session ends (timeout or explicit close), the hook summarizes what happened and stores it. This means tomorrow’s session starts with yesterday’s context available for recall.

# End of session, hook runs automatically:
# memoclaw ingest "Session summary: Fixed the batch store endpoint.
#   Changed max batch size from 50 to 100. Updated tests.
#   Next: need to add rate limiting per wallet."

on_memory_request — When your agent outputs text containing “remember this” or similar phrases, the hook intercepts and stores the relevant content. When the agent needs to recall something, it can use its normal tools, or the hook picks up recall-like queries.

Configuration

The defaults work for most people, but you can tweak things in .openclaw/hooks/memoclaw/config.yaml:

# How many memories to recall at session start
recall_limit: 5

# Minimum relevance score to include (0.0 to 1.0)
min_score: 0.3

# Auto-store session summaries
auto_store_sessions: true

# Tags to add to all auto-stored memories
default_tags:
  - openclaw
  - auto

How it plays with existing MEMORY.md

If your agent already uses a MEMORY.md file, the hook pack doesn’t touch it. You can run both in parallel. The recalled memories show up as additional context alongside whatever your MEMORY.md provides.

When you’re ready to fully switch, migrate the file:

memoclaw migrate ./MEMORY.md

Then remove the MEMORY.md loading from your agent config. Your agent still gets its context, just from MemoClaw instead of a static file.

Checking what’s stored

The hook stores memories with an openclaw tag, so you can see everything it auto-stored:

# List auto-stored memories
memoclaw list --tag openclaw --limit 20

# See what would be recalled for a query
memoclaw recall "API work" --limit 5

Cost

Each session start costs one recall ($0.005 after free tier). Each session end costs one ingest ($0.01 after free tier). If you run 10 sessions a day, that’s about $0.15/day. The 100 free calls cover roughly a week of normal use.

The 17 management endpoints (list, delete, update, export, etc.) are always free, so browsing and cleaning up your memories costs nothing.

What I changed after a week

I bumped recall_limit to 8 because 5 wasn’t enough for context-heavy projects. I also added a custom tag per project so I could filter memories by project:

default_tags:
  - openclaw
  - auto
  - project:memoclaw

And I lowered min_score to 0.2 because some borderline-relevant memories turned out to be useful. Your mileage will vary — start with defaults and adjust after a few days.