Skip to content

OpenClaw Integration

The MemoryLayer OpenClaw plugin (@scitrera/memorylayer-openclaw-plugin, new in 0.2.0) makes MemoryLayer the backend for OpenClaw’s first-class memory capability. It provides:

  • Memory search: OpenClaw’s memory search and read calls are answered by MemoryLayer recall
  • Message persistence: Every successfully sent agent message is appended to a MemoryLayer chat thread
  • Opt-in skills sync: With MEMORYLAYER_SKILLS_SYNC=1, MemoryLayer skills are materialized into a directory that OpenClaw watches

Requirements

  • OpenClaw 2026.9.3 or newer (peer dependency)
  • Node.js 24.16 or newer
  • An Aether sidecar relay reachable from the OpenClaw process. Unlike the Claude Code, Codex, and OpenCode integrations, this plugin does not call the MemoryLayer HTTP API directly (see below)

Architecture

The plugin is designed to run inside an OpenClaw container that is launched as part of a per-principal sandbox. It uses the MemoryLayer TypeScript SDK with an AetherFetchTransport, so all MemoryLayer traffic is tunneled through the sandbox’s Aether sidecar relay. The plugin holds no real credentials. The sidecar terminates the relay locally and injects the proper Aether identity upstream.

OpenClaw ──┬── plugin: @scitrera/memorylayer-openclaw-plugin
│ └── @scitrera/memorylayer-sdk
│ └── AetherFetchTransport (custom `fetch`)
│ └── @scitrera/aether-client
│ └── ProxyHttp → localhost:<sidecar-port>
│
└── sidecar (Aether relay + identity injection)
└── upstream Aether → MemoryLayer service

The plugin registers a single OpenClaw MemoryPluginCapability (covering runtime, flushPlanResolver, promptBuilder, and publicArtifacts), a message-persistence hook, and a skills-sync hook. The Aether connection is opened lazily on first use, so plugin load is never blocked.

Installation from Source

Terminal window
git clone https://github.com/scitrera/memorylayer.git
cd memorylayer/memorylayer-openclaw-plugin
npm install
npm run build # tsc → dist/, then an esbuild bundle → dist/bundle/
npm test # vitest

OpenClaw loads the plugin through its plugin manifest mechanism:

  • package.json declares openclaw.extensions: ["./dist/bundle/index.js"], which exports the definePluginEntry(...) result
  • openclaw.plugin.json is the manifest: id @scitrera/memorylayer-openclaw-plugin, kind: "memory", with no plugin-level config schema (all configuration comes from environment variables)

The plugin id in OpenClaw’s host configuration must match @scitrera/memorylayer-openclaw-plugin. OpenClaw rejects the plugin if the manifest, config, and entry ids don’t agree.

Configuration

All configuration comes from environment variables. In a sandboxed deployment, the sandbox provider sets them when it launches the OpenClaw container. The plugin throws at registration if a required variable is missing.

VariableRequiredDescription
AETHER_GATEWAY_ADDRESSYeshost:port of the sidecar Aether relay
AETHER_WORKSPACEYesAether workspace identity
AETHER_IMPLEMENTATIONYesAether implementation identity
AETHER_SPECIFIERNoAether specifier (default: default)
MEMORYLAYER_TARGET_TOPICYesAether target topic of the MemoryLayer service
MEMORYLAYER_BASE_URLNoNominal base URL passed to the SDK (default: http://memorylayer.aether-relay; traffic is tunneled regardless)
MEMORYLAYER_TIMEOUT_MSNoPer-request timeout in milliseconds (default: 30000)
WORKCLAW_TENANT_IDYesTenant the principal belongs to
WORKCLAW_PRINCIPAL_TYPEYesuser or agent
WORKCLAW_PRINCIPAL_IDYesPrincipal identifier
WORKCLAW_DEFAULT_WORKSPACENoDefault MemoryLayer workspace ID for recall and skills
WORKCLAW_GRANT_IDNoDefault Aether grant ID (sets the default on-behalf-of authority)
MEMORYLAYER_SKILLS_SYNCNo1 or true to turn on skills sync (default: off)
MEMORYLAYER_SKILLS_DIRNoAbsolute path of the managed skills directory (default: <workspaceDir>/.memorylayer-skills)

OpenClaw asks the plugin’s memory runtime for a MemorySearchManager per agent. The manager backs OpenClaw’s memory tools (such as memory_search):

  • Search calls MemoryLayer recall(), passing OpenClaw’s maxResults and minScore as the recall limit and minimum relevance, scoped to WORKCLAW_DEFAULT_WORKSPACE when set.
  • MemoryLayer memories have no filesystem path, so results carry a synthetic path, memorylayer://<memory-id>. Reads of that path fetch the memory with getMemory(). Reads of any other path return empty text rather than an error.
  • Managers are cached per agent ID, which keeps agents isolated from each other.

Message Persistence

The plugin registers a message:sent hook. After OpenClaw successfully sends an outbound agent message with content, the plugin appends it to a MemoryLayer chat thread as an assistant message. The metadata includes messageId, conversationId, channelId, and sentAt.

The thread ID comes from the OpenClaw session key, which the sidecar bridge formats as agent:<agent-id>:<thread_id>. The thread must already exist, because creating it is the app server’s job when a user opens a thread. Persistence is best-effort: parse failures and API errors (for example, a 404 for a missing thread) are logged and never block the agent’s turn.

See Chat History Tools for how threads decompose into memories.

Skills Sync (Opt-in)

With MEMORYLAYER_SKILLS_SYNC=1 (or true), on each agent:bootstrap event the plugin fetches the principal’s enabled MemoryLayer skills. It writes each SKILL.md and its bundle files into a dedicated managed directory with the SDK’s client.skills.materialize(...). MemoryLayer is the source of truth, and OpenClaw keeps a local cache that it discovers and hot-reloads natively.

  • Managed directory: MEMORYLAYER_SKILLS_DIR if set, otherwise <workspaceDir>/.memorylayer-skills. This is deliberately a sibling of OpenClaw’s native skills/ directory, not a subfolder of it, so the plugin never overwrites user-authored, bundled, or other plugin skills.
  • Reconcile: The sync runs with reconcile: true. After listing and writing the enabled set, it removes any skill directory in the managed directory that is no longer enabled (disabled, deleted, or renamed in MemoryLayer). Pruning happens only after a successful list, so a server outage can’t wipe the directory.
  • Scoping: Skills are scoped to WORKCLAW_DEFAULT_WORKSPACE, and to the principal’s on-behalf-of authority when WORKCLAW_GRANT_ID is set.
  • Best-effort: Errors are logged and never block agent bootstrap.

OpenClaw must be told to scan the managed directory. Add it to skills.load.extraDirs in openclaw.json, using the same path the plugin writes to:

{ "skills": { "load": { "extraDirs": ["/abs/path/to/workspace/.memorylayer-skills"] } } }

The plugin does not edit openclaw.json itself. In sandboxed deployments, the sandbox provider sets the same value in both MEMORYLAYER_SKILLS_DIR and extraDirs so the two always agree. See Skills & MCP Servers for managing skills in MemoryLayer.

Current Limitations

  • The flush-plan resolver, prompt builder, and public-artifact provider are registered but currently return no additional content, so OpenClaw’s own transcript flush and memory prompt behavior are unchanged.
  • The plugin talks to MemoryLayer only through the Aether transport. There is no direct-HTTP mode.