> ## Documentation Index
> Fetch the complete documentation index at: https://agent-memory.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenClaw

> MCP wiring plus a memory-slot plugin that recalls before and captures after each run

## Setup

<Steps>
  <Step title="Start agentmemory">
    ```bash theme={"dark"}
    npx @agentmemory/agentmemory
    ```
  </Step>

  <Step title="Wire MCP">
    ```bash theme={"dark"}
    npx @agentmemory/agentmemory connect openclaw
    ```

    The adapter detects `~/.openclaw/`, backs up `openclaw.json`, merges the standard `mcpServers.agentmemory` entry, and verifies it after writing.
  </Step>

  <Step title="Install the memory plugin (optional, deeper)">
    From a repo checkout:

    ```bash theme={"dark"}
    openclaw plugins install ./integrations/openclaw
    ```

    The installer copies the plugin into `~/.openclaw/extensions/agentmemory` and switches OpenClaw's exclusive memory slot from `memory-core` to `agentmemory`. Then allow conversation access in `~/.openclaw/openclaw.json` (config below) — without it, OpenClaw silently blocks the `agent_end` hook and turn capture never fires.
  </Step>

  <Step title="Restart OpenClaw">
    Restart so both the MCP server and the plugin load.
  </Step>

  <Step title="Verify">
    ```bash theme={"dark"}
    curl http://localhost:3111/agentmemory/health
    ```

    Open `http://localhost:3113` and confirm observations appear after an agent run.
  </Step>
</Steps>

## What connect writes

```json ~/.openclaw/openclaw.json theme={"dark"}
{
  "mcpServers": {
    "agentmemory": {
      "command": "npx",
      "args": ["-y", "@agentmemory/mcp"],
      "env": {
        "AGENTMEMORY_URL": "${AGENTMEMORY_URL:-http://localhost:3111}",
        "AGENTMEMORY_SECRET": "${AGENTMEMORY_SECRET:-}",
        "AGENTMEMORY_TOOLS": "${AGENTMEMORY_TOOLS:-all}"
      }
    }
  }
}
```

## The memory-slot plugin

The plugin in `integrations/openclaw/` claims OpenClaw's memory slot. `hooks.allowConversationAccess` is required: OpenClaw blocks conversation-reading hooks from non-bundled plugins by default, and without it the plugin loads but never captures turns. Enable it with:

```json ~/.openclaw/openclaw.json theme={"dark"}
{
  "plugins": {
    "slots": {
      "memory": "agentmemory"
    },
    "entries": {
      "agentmemory": {
        "enabled": true,
        "hooks": { "allowConversationAccess": true },
        "config": {
          "base_url": "http://localhost:3111",
          "token_budget": 2000,
          "min_confidence": 0.5,
          "fallback_on_error": true,
          "timeout_ms": 5000
        }
      }
    }
  }
}
```

What it does:

* claims `plugins.slots.memory = "agentmemory"` via `api.registerMemoryCapability({ promptBuilder })`, the documented API for occupying the slot
* recalls relevant long-term memory before the agent starts (`before_agent_start` hook)
* captures completed conversation turns after the agent finishes (`agent_end` hook)
* shares the same backend with every other connected agent

<Note>
  The plugin registers a `promptBuilder` only, not a full memory-runtime adapter. OpenClaw's `MemoryRuntimeBackendConfig` currently accepts only its internal `builtin` and `qmd` backends, which do not fit agentmemory's external REST shape. Hook-driven recall plus capture is the working integration path.
</Note>

## Troubleshooting

<AccordionGroup>
  <Accordion title="Plugin validates but does not load">
    The extension folder must contain `package.json`, `openclaw.plugin.json`, and `plugin.mjs`, and `plugins.slots.memory` must be set to `agentmemory`. Copy the whole `integrations/openclaw` folder, not just the plugin file.
  </Accordion>

  <Accordion title="Memory slot reports unavailable">
    Upgrade the plugin to v0.9.11 or later. Older versions registered hooks but never called `api.registerMemoryCapability(...)`, so OpenClaw did not consider the slot claimed.
  </Accordion>

  <Accordion title="Connection refused on port 3111">
    The agentmemory server is not running. Start it with `npx @agentmemory/agentmemory`. With `fallback_on_error: true` the agent keeps working without memory until the server returns.
  </Accordion>
</AccordionGroup>

Adapter source: `src/cli/connect/openclaw.ts` (shared JSON adapter). Plugin: `integrations/openclaw/plugin.mjs` and its README.
