Skip to main content
Give your OpenClaw agents Cognee-backed memory with multi-scope support (company / user / agent), session tracking, native memory tools, and automatic recall. The plugin indexes your Markdown memory files, recalls relevant context before each run, captures every turn into Cognee’s session cache, and bridges it into the permanent graph when the session ends.

Why Use This Integration

  • Multi-scope memory: Separate datasets for company-wide knowledge, per-user preferences, and per-agent context, routed automatically by file path
  • Auto-recall: Relevant memories are injected as a <cognee_memories> block before every prompt — the retrieved graph context, trimmed to what the agent does not already have, plus this session’s guidance
  • Auto-index: Memory files sync to Cognee (add new, update changed, forget removed, skip unchanged)
  • Session tracking: Each tool call and prompt/answer pair is captured in Cognee’s session cache and, by default, bridged into the graph on session end. A capture policy chooses which tool calls are stored and redacts secrets first
  • Native memory tools: memory_search / memory_get (the tools OpenClaw’s memory slot expects), plus memory_forget, memory_switch_dataset, memory_code_search, and memory_recap
  • Code graph: openclaw cognee index-repo indexes a repository so the agent can answer callers / impact / path questions exactly
  • Zero-config server: With a loopback baseUrl, the plugin installs and boots its own Cognee server on first gateway start
  • One-command setup: openclaw cognee setup configures Cognee as the memory provider and sets the required hook permissions

Installation

Pin to an exact version (supply-chain best practice):
Or install locally for development, as a symlink so npm run build takes effect on the next gateway start:
The plugin targets OpenClaw plugin API >=2026.6.5.
OpenClaw auto-loads any plugin it discovers unless plugins.allow is set. Restrict it to an explicit allowlist — a JSON array, not an object:

Quick Start

1. Run setup

Both modes set plugins.slots.memory to cognee-openclaw and write the two hook permissions the plugin needs (allowPromptInjection, allowConversationAccess). Default mode also disables memory-core and memory-lancedb; hybrid mode keeps memory-core enabled in config, though on OpenClaw versions with exclusive memory slots only the slot winner loads at runtime.

2. Start Cognee — or let the plugin do it

You have two options:
Leave baseUrl at its default, http://localhost:8011. On gateway start the plugin checks /health; if nothing answers on a loopback address it writes a bootstrap script to ~/.cognee-plugin/, builds a virtualenv with cognee==1.6.5, and starts the server on that port from ~/.cognee-plugin with the default user (default_user@example.com / default_password) set via DEFAULT_USER_EMAIL / DEFAULT_USER_PASSWORD — export those yourself to override them. A cold first install can take several minutes; later starts are near-instant. When the pin changes, the venv is upgraded on the next cold boot.Requirements: python3 3.9 or newer on the host to run the bootstrap (only the standard library is used), and a Python 3.10–3.14 already on the machine for the server’s virtualenv. The bootstrap never downloads an interpreter or installer: if uv is installed it is used with UV_PYTHON_DOWNLOADS=never; otherwise, or when uv finds no suitable interpreter, the script probes python3.14 … python3.10, python3, python and builds the venv with -m venv. The pinned cognee package from PyPI is the only download. With no suitable interpreter the plugin refuses and records why in ~/.cognee-plugin/.venv-error.json, which the gateway log’s “server did not become ready” warning quotes.The server needs an LLM key. Put it, and any other server setting, in ~/.cognee/.env (the file the Claude Code and Codex plugins read too), or point COGNEE_ENV_FILE at another file:
KEY=VALUE lines, # comments, an optional leading export and optional quotes are accepted. A variable already exported in the gateway’s environment wins over the file, and names such as PATH or LD_* are skipped. Because the server runs from ~/.cognee-plugin, a .env in the directory you start the gateway from is not read — move any LLM_API_KEY kept there to ~/.cognee/.env, or export it.

3. Configure the connection

Add the Cognee connection to ~/.openclaw/openclaw.json:
allowConversationAccess: true is the one that is strictly required: OpenClaw withholds the conversation hooks (llm_output, agent_end) from installed plugins without it, so Q&A session capture and post-run file sync are silently skipped, and the only trace is a warning in gateway diagnostics. allowPromptInjection gates the prompt-injection hooks (before_prompt_build) that carry recall and the memory steer; it defaults to allowed, but openclaw cognee setup writes it explicitly because it also signals hook startup intent. Restart the gateway after changing either: openclaw gateway stop && openclaw gateway start.
That’s it. Your OpenClaw memory files are now backed by Cognee’s knowledge graph. If you omit apiKey against a local server, the plugin logs in once with the default credentials (default_user@example.com / default_password), mints an API key, caches it in ~/.cognee-plugin/api_key.json, and authenticates with X-Api-Key from then on. That login works on the auto-managed server, which the plugin starts with the default user; a Cognee 1.6.0+ server you run yourself has no default-user password unless it starts with DEFAULT_USER_PASSWORD set (see Default user credentials), so pass apiKey or set that variable.
Cognee 1.6.0 no longer ships a built-in default-user password: the server creates the default user only when DEFAULT_USER_PASSWORD is set at startup. The auto-managed server handles this for you. For a server you start yourself (Docker, another host), either set DEFAULT_USER_PASSWORD to the password the plugin logs in with, or supply apiKey / COGNEE_API_KEY. A login failing with 400 "This user does not have a password" means the server was started without it. The plugin’s username / password only select which user it logs in as; a non-default user must already exist on the server.

Cognee Cloud

Cognee Cloud tenants serve the same /api/v1/* API as a self-hosted server, so connecting is the default configuration pointed at your tenant URL with an API key:
COGNEE_API_KEY is mandatory for a Cognee Cloud tenant, which exposes no login route to mint a key from, and it must be present in the environment the gateway process starts from. Do not set mode: "cloud": it switches every request to a legacy path scheme without the /api/v1 prefix, which no current tenant serves. See OpenClaw with Cognee Cloud for the full walkthrough.

Multi-Scope Memory

For production use, enable multi-scope mode by setting any scope-specific dataset name. Memory files are routed to the right dataset by path.
Default routing: memory/company/** → company, memory/user/** → user, memory/** and MEMORY.md → agent (catch-all). Override it with a scopeRouting list of { pattern, scope } rules; the first match wins. With userDatasetPrefix set but no userId (or OPENCLAW_USER_ID), the user scope falls back to <prefix>-default, one dataset every user shares; the gateway logs a warning on start. Cognee rejects dataset names that contain a space or a dot. Since 2026.10.13, the plugin replaces each run of spaces and dots with _ in the configured datasetName and in every scope’s dataset name, including explicit companyDataset, prefix, and template values. For example, user id a.b@x.com with datasetName: "team" gives team-user-a_b@x_com, and companyDataset: "acme.shared" gives acme_shared. Names without a space or dot are used unchanged. A name made only of spaces and dots falls back to agent_sessions for datasetName, and to the configured datasetName for a scope.

Multiple agents

By default every agent in a gateway reads and writes the same dataset (agent_sessions unless you set datasetName). Agents stay distinguishable within it — each registers its own session and its turns are keyed by its own Cognee session id — and shared memory is usually what you want. To give each agent its own dataset, set agentDatasetPrefix (or agentDatasetTemplate, e.g. "{agentId}"). The agent scope is then resolved per turn from the runtime agent id — which OpenClaw hands to plugins already lowercased — for recall, session capture, and memory-file sync alike. With agentDatasetPrefix: "myorg-agent", agent Will writes to myorg-agent-will and recalls only from it plus any shared company/user scopes.

How It Works

  1. On gateway start: Health check (booting the local server if needed), register a gateway anchor with the Cognee server, then scan memory/ and call /remember — one batched upload per scope; Cognee runs add + cognify + improve server-side.
  2. Before each prompt: Send two /recall requests together, the same pair as the Claude Code and Codex plugins, plus — when the prompt names an identifier and a code graph is indexed — one code-graph recall:
    • Graph: scope: ["graph"], only_context: true, across the datasets of every configured scope, without the session id. On Cognee ≥ 1.6.0 the server answers with one item per dataset; the plugin keeps only its retrieved context: the question template goes, passages recorded in this session go (the agent already has them), each passage is capped at recallPassageChars (cut at a paragraph break), and entity lines that say nothing are pruned. Text it cannot parse (an older server’s bare context) is injected whole.
    • Guidance: scope: ["session_context"] with this conversation’s session id against its capture dataset — the lessons the server distilled from this session.
    The lanes are independent: guidance and code facts are still injected when the graph has nothing or fails, and a lane not done by the recall deadline is dropped instead of costing the turn the others. Everything is injected at recallInjectionPosition, held together to recallContextChars (guidance first, then each dataset’s memory, then code facts; the block that crosses the cap is cut at a line and marked …[truncated], or dropped whole if it is code facts):
    In single-scope mode there is one <cognee_memory> block. Harness-generated turns (heartbeat probes, cron payloads, System: lines) are skipped, for both recall and Q&A capture.
  3. During the run: Each tool call is stored as a trace entry and each prompt/answer pair as a QA entry in Cognee’s session cache (captureSession), filtered by the capture policy. A capture the server never received — the connection could not be opened (refused while it boots, host unreachable, DNS failure) or it answered 503 — is queued in ~/.openclaw/memory/cognee/pending-entries.json (newest 500, kept a week) and replayed after the next successful write, on gateway start, and, for the ending session, before its session-end /improve. A write that timed out or failed otherwise is not replayed, since the server may already have stored it. On turns where recall injected at least one memory, the final reply gets a one-line [cognee: N memories] footer (memoryHitFooter).
  4. After each agent run: Re-scan memory files — new files batch into /remember, changed files go through PATCH /update, removed files are dropped via /forget.
  5. On session end: Final sync sweep; with persistSessionsAfterEnd and improveOnSessionEnd both on, dispatches /improve for the ended session to bridge session QAs into the permanent graph. With persistSessionsAfterEnd: false, the turns stay in the session cache and are not bridged — including if the gateway exits uncleanly.
State is tracked under ~/.openclaw/memory/cognee/ (datasets.json, scoped-sync-indexes.json, legacy sync-index.json, plus dataset-overrides.json, code-graphs.json, digest-stats.json, update-check.json, and pending-entries.json). Files are uploaded under sanitized relative paths — / becomes _ (since 2026.10.13, so does \) and . becomes -, so memory/tools.md is stored as memory_tools-md.

Capture policy and redaction

Before anything is stored, captured prompts, answers, and tool calls pass through the same capture rules as the Claude Code and Codex plugins’ COGNEE_CAPTURE_* settings:
  • captureTools / captureDenyTools choose which tool calls are captured. Each entry is a tool name, an fnmatch glob (web_*), or Tool(prefix:*) matched against the first word of a shell command (exec(git:*); cd x && git … counts as cd). Tool names are compared case-insensitively; the command prefix is case-sensitive.
  • Tool calls touching .env*, *.pem, *.key, ssh and cloud credentials, secrets.*, or credentials.* — plus any captureDenyPaths globs — are never captured.
  • captureRedact (on by default) scrubs private keys, bearer and basic tokens, DB URLs, credential assignments, vendor keys (sk-, ghp_, xox…, whsec_), bcrypt hashes, and secret-named fields, plus anything matching captureRedactPatterns.
A pattern the plugin cannot parse fails closed until it is fixed, and the gateway log says why: a bad tool or path entry (for example exec(rg) without :*) stops tool-call capture, and an invalid redaction regex stops all capture, prompts and answers included.

Agent Tools

The plugin registers Cognee-backed tools the model can call directly. OpenClaw’s memory slot expects exactly memory_search and memory_get (the bundled active-memory extension allow-lists them), so they work with no toolsAllow override and independently of autoRecall. Turn any of them off with memoryTools, memoryForgetTool, datasetSwitchTool, codeSearchTool, or recapTool. A short memory steer line is also appended to the system prompt on every real agent run (memorySteer), asserting Cognee as the authoritative long-term memory and naming these tools.

Code Graph

Index a repository into a deterministic code graph (no LLM or embedding calls) and let the agent answer callers / impact / path / endpoint questions exactly. Nothing is indexed automatically — OpenClaw agents are rarely launched inside a checkout — so the operator opts a repository in. Requires Cognee ≥ 1.5.4.
One dataset per repository (codebase-<repo>-<digest> by default, lowercased with dots in the repo name turned into -, so Foo.JS becomes codebase-foo-js-<digest>). --index-vectors also embeds the facts so memory_search can see them; without it the graph is reachable only through memory_code_search and the code recall lane. memory_code_search supports query_facts (default), explore, traverse, find_path (args.source / args.target), impact_analysis, and delta; dataset is optional when exactly one repository is indexed. The recall lane fires only when a prompt contains an identifier-shaped token (backticked symbol, file path, snake_case, CamelCase, dotted name) and a code graph is indexed or listed in codeDatasets.

Configuration Reference

Defaults below are what the plugin resolves when a key is absent. Every option goes under plugins.entries.cognee-openclaw.config.

Connection

Memory scopes

Setting any one of companyDataset, userDatasetPrefix, agentDatasetPrefix, or agentDatasetTemplate turns on multi-scope mode.

Sessions

Search and recall

After three prompts in a row whose recall only timed out, each prompt first spends a 3-second /health probe and skips recall while the server does not answer, instead of waiting out the whole budget. Any answered recall ends that state.

Tools and visibility

Automation and timeouts

Deprecated options. Accepted but ignored: maxTokens — recall is bounded by recallPassageChars / recallContextChars; autoCognify and autoMemify — now run server-side via /remember; deleteMode — /forget always deletes permanently. Still honored but deprecated: mode: "cloud" (and COGNEE_MODE=cloud) switches to a legacy path scheme without the /api/v1 prefix that no current deployment serves — see Cognee Cloud.
Advanced options. Since 2026.10.13 the plugin manifest also accepts perAgentMemory (per-agent file-sync isolation, default off; only takes effect together with agentDatasetPrefix or agentDatasetTemplate), noiseTriggers (trigger values treated as harness turns, default ["heartbeat", "cron"]), and noisePatterns (regexes matched against the prompt; replaces the defaults — prompts starting with Read HEARTBEAT.md, System: , or [cron — when set). An empty list disables that noise layer.

Environment variables

Search Types

The plugin supports all 15 of Cognee’s search types: HYBRID_COMPLETION (default — combined vector + graph retrieval), GRAPH_COMPLETION, GRAPH_COMPLETION_COT, GRAPH_COMPLETION_CONTEXT_EXTENSION, GRAPH_SUMMARY_COMPLETION, RAG_COMPLETION, TRIPLET_COMPLETION, CHUNKS, CHUNKS_LEXICAL, SUMMARIES, TEMPORAL, NATURAL_LANGUAGE, CYPHER, CODING_RULES, and FEELING_LUCKY (auto-selects per query). CYPHER and NATURAL_LANGUAGE are disabled by default and need ALLOW_CYPHER_QUERY=true on the Cognee server. See Search Types for details.

CLI Commands

The recap commands print the same output as the memory_recap tool and accept --since, --projects <a,b>, --all-sessions, --agent <id>, and --json. Since 2026.10.26, openclaw cognee keys lists the per-machine API keys of every cognee plugin agent of your user (Claude Code, Codex, …), most recently used first, with never-used keys last. A Cognee server with per-machine plugin keys caps how many keys a plugin agent holds, and an agent at the cap refuses a new machine a key; revoking an old machine’s key frees a slot. --plugin <key> (for example claude-code) limits the listing to one agent and is required with --revoke; --json prints the listing as JSON. A revoke of a key that does not exist reports it and exits with code 3. Against a server without the plugin-key routes, such as cognee 1.6.5 that the plugin installs for its local server, the listing comes back empty and every revoke reports the key as not found.

Troubleshooting

Installed plugins only receive the conversation hooks (llm_output, agent_end) when hooks.allowConversationAccess: true is set under the plugin entry; without it both Q&A capture and post-run sync are silently skipped. Re-run openclaw cognee setup or add the key to ~/.openclaw/openclaw.json, then restart the gateway:
The gateway log’s server did not become ready warning quotes the bootstrap’s recorded reason when there is one (~/.cognee-plugin/.venv-error.json) — most often no Python 3.10–3.14 on the machine (the plugin never downloads one), or a missing LLM_API_KEY in ~/.cognee/.env. Since 2026.10.26, when building the venv with -m venv fails, the recorded reason gives uv’s error first (if uv was tried) and the venv module’s own stderr after it (for example a missing ensurepip), rather than only a non-zero exit status. Fix the cause and restart the gateway; a cold first install can legitimately take several minutes.
Check connectivity and sync state:
Healthy status shows the plugin version, the dataset ID, indexed file count, and a recent last-sync timestamp. On the Cognee side, confirm the server logs show Backend server has started (Docker: docker compose logs cognee) before starting OpenClaw.
Trigger the same sync autoIndex runs at any time:
If this fails, verify baseUrl points to a reachable Cognee server and that your apiKey (or default credentials) are valid.

GitHub Repository

View source code and examples

Blog Post

Deep dive into building this plugin

OpenClaw Docs

Learn about OpenClaw’s memory system