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 — one graph recall that, on Cognee ≥ 1.6.0, already carries this conversation’s history and session 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
- Native memory tools:
memory_search/memory_get(the tools OpenClaw’s memory slot expects), plusmemory_forget,memory_switch_dataset, andmemory_code_search - Code graph:
openclaw cognee index-repoindexes 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 setupconfigures Cognee as the memory provider and sets the required hook permissions
Installation
Pin to an exact version (supply-chain best practice):npm run build takes effect on the next gateway start:
>=2026.6.5.
Quick Start
1. Run setup
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:- Auto-managed (default)
- Docker Compose
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 uv-managed Python 3.12 virtualenv with cognee==1.6.0, and starts the server on that port 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.Requirements: python3 3.9 or newer on the host (only the standard library is used to bootstrap). If uv is unavailable and cannot be downloaded, the fallback python3 -m venv needs Python 3.10+; on an older host 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. Set LLM_API_KEY in the environment the gateway process starts from.3. Configure the connection
Add the Cognee connection to~/.openclaw/openclaw.json:
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 pinned 1.5.4 server; 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.
Cognee rejects dataset names that contain a space or a dot. In releases after 2026.9.22, 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
-
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. -
Before each prompt: Send one
/recallrequest across the datasets of every configured scope (scope: ["graph"],only_context: true, this conversation’s session id) and — when the prompt names an identifier and a code graph is indexed — one code-graph recall in parallel. On Cognee ≥ 1.6.0 the server answers with one item per dataset whose text is the full input the completion would have received: this conversation’s history, the question with the retrieved context, and the session guidance distilled by/improve. Each item is injected verbatim as its own block atrecallInjectionPosition:In single-scope mode there is one<cognee_memory>block. Older (1.5.x) servers return the bare retrieved context, which is injected the same way. Harness-generated turns (heartbeat probes, cron payloads,System:lines) are skipped, for both recall and Q&A capture. -
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). On turns where recall injected at least one memory, the final reply gets a one-line[cognee: N memories]footer (memoryHitFooter). -
After each agent run: Re-scan memory files — new files batch into
/remember, changed files go throughPATCH /update, removed files are dropped via/forget. -
On session end: Final sync sweep; with
persistSessionsAfterEndandimproveOnSessionEndboth on, dispatches/improvefor the ended session to bridge session QAs into the permanent graph. WithpersistSessionsAfterEnd: false, the turns stay in the session cache and are not bridged — including if the gateway exits uncleanly.
~/.openclaw/memory/cognee/ (datasets.json, scoped-sync-indexes.json, legacy sync-index.json, plus dataset-overrides.json, code-graphs.json, digest-stats.json, and update-check.json). Files are uploaded under sanitized relative paths — / becomes _ (in releases after 2026.9.22, so does \) and . becomes -, so memory/tools.md is stored as memory_tools-md.
Agent Tools
The plugin registers Cognee-backed tools the model can call directly. OpenClaw’s memory slot expects exactlymemory_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, or codeSearchTool. 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.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 underplugins.entries.cognee-openclaw.config.
Connection
Memory scopes
Setting any one ofcompanyDataset, userDatasetPrefix, agentDatasetPrefix, or agentDatasetTemplate turns on multi-scope mode.
Sessions
Search and recall
Tools and visibility
Automation and timeouts
Deprecated options. Accepted but ignored:
maxTokens — use maxResults; autoCognify and autoMemify — now run server-side via /remember; deleteMode — /forget is always a soft delete. 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.perAgentMemory (per-agent file-sync isolation), noiseTriggers, and noisePatterns — are missing from the plugin manifest’s config schema, which rejects unknown keys, so putting them in openclaw.json fails validation instead of taking effect. Their built-in defaults apply: per-agent sync isolation off, and the harness-noise filter on for the heartbeat and cron triggers plus prompts starting with Read HEARTBEAT.md, System: , or [cron.
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). See Search Types for details.
CLI Commands
Troubleshooting
Session capture or file sync not running after each agent turn
Session capture or file sync not running after each agent turn
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:Local server did not become ready
Local server did not become ready
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 a host python3 older than 3.10 with uv unavailable, or a missing LLM_API_KEY. Fix the cause and restart the gateway; a cold first install can legitimately take several minutes.Verifying the plugin can reach Cognee
Verifying the plugin can reach Cognee
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.Manual fallback
Manual fallback
Trigger the same sync If this fails, verify
autoIndex runs at any time: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