Skip to content

Agent frameworks

OpenClaw

The @surrealdb/agent-memory-openclaw plugin backs OpenClaw agent memory with SurrealDB Agent Memory. It gives an agent long-term memory that survives session restarts and fresh chats: relevant memory is recalled before each turn, each turn is persisted afterwards, and the agent gains tools and a CLI for deliberate memory access.

By default the plugin augments OpenClaw's built-in memory. It can optionally take over the memory slot (see Memory modes).

  • OpenClaw 2026.4.27 or newer

  • a SurrealDB Agent Memory endpoint, API key, and context id (SurrealDB Cloud or the self-hosted Agent Memory binary)

openclaw plugins install @surrealdb/agent-memory-openclaw
openclaw agentMemory setup
openclaw gateway restart

openclaw agentMemory setup prints the config block and the two hook flags to add.

Configuration lives in ~/.openclaw/openclaw.json under plugins.entries.agentMemory. Connection fields accept ${ENV_VAR} references so secrets stay out of the file:

{
  "plugins": {
    "entries": {
      "agentMemory": {
        "enabled": true,
        "hooks": {
          "allowConversationAccess": true,
          "allowPromptInjection": true
        },
        "config": {
          "endpoint": "${AGENT_MEMORY_ENDPOINT}",
          "apiKey": "${AGENT_MEMORY_API_KEY}",
          "context": "${AGENT_MEMORY_CONTEXT}"
        }
      }
    }
  }
}
Important

Both hook flags are required. allowConversationAccess lets OpenClaw deliver the agent_end event to the plugin. Without it, per-turn persistence is silently skipped. allowPromptInjection lets the plugin inject recalled context.

KeyDefaultPurpose
endpointrequiredSurrealDB Agent Memory API origin, no trailing slash
apiKeyrequiredBearer API key
contextrequiredContext id (namespace and database)
recallScopewhole regionRead lens narrowing recall (scope path, or array of paths)
writeScopekey defaultScope written memories are tagged with
autoRecalltrueInject memory before each turn
autoCapturetruePersist each turn
autoConsolidatetrueConsolidate at session end
autoIndextrueSeed workspace memory files on start or index
recallK5Max hits per recall
injectMode"context"context (formatted text) or recall (ranked hits)

The plugin maps SurrealDB Agent Memory's operations onto OpenClaw's agent lifecycle:

OpenClaw hookWhat happens
before_prompt_buildRelevant memory is injected as <agent_memory> before the model runs
agent_endThe turn is persisted, with platform metadata stripped
session_endRecent facts are consolidated into durable observations
gateway_start / agentMemory indexWorkspace memory files (MEMORY.md, memory/**) are seeded

The agent can call these directly: agent_memory_recall, agent_memory_context, agent_memory_remember, agent_memory_reflect, agent_memory_forget, agent_memory_upload, and agent_memory_inspect.

openclaw agentMemory setup [--takeover]   # print config + required hook flags
openclaw agentMemory status               # config, slot mode, and identity
openclaw agentMemory health               # check the connection
openclaw agentMemory index                # seed workspace memory files
openclaw agentMemory recall <query>       # search memory
openclaw agentMemory reflect <query>      # synthesise an answer from memory
openclaw agentMemory forget <query>       # forget matching memories
  • Augment (default): runs alongside the built-in memory core. Nothing about the memory slot changes.

  • Takeover (experimental): openclaw agentMemory setup --takeover prints a patch that sets plugins.slots.memory to agentMemory, making SurrealDB Agent Memory the sole memory provider.

Was this page helpful?