pip install. It works in the Codex CLI and can also be activated through the Codex IDE plugin. The plugin hooks into Codex’s lifecycle, so it:
- captures your prompts, tool traces, and assistant responses into session memory
- injects relevant context on every prompt submit
- syncs the session into your knowledge graph on session end
Install
The Cognee memory plugin depends on Codex lifecycle hooks. Enable hooks before installing it.- CLI
- Manual
Enable hooks, then install from the Codex marketplace with the Codex CLI:
Make sure Cognee hooks are enabled for both the Codex CLI and the Codex IDE plugin. If Codex asks you to review hooks, open
/hooks and allow or trust the Cognee hooks. Until hooks are enabled and trusted, Codex will not call the plugin on prompt submit, tool use, stop, compaction, or session end.cognee: <dataset> · <mode> to confirm the plugin is active.
Configure your backend
Set environment variables in the shell that launches Codex.- Cognee Cloud / remote
- Local (default)
Point the plugin at Cognee Cloud or a remote server by setting both:
Cognee’s LLM calls do not run through Codex. Your Codex plan pays only for your conversation with the model. Everything Cognee does on its own — entity and relationship extraction during cognify, summarization, embeddings, and search-time completions — happens inside the Cognee backend against the LLM provider configured there, and is billed by that provider. In local mode you configure it with
LLM_API_KEY; in Cloud/remote mode your tenant holds the key server-side, so no local LLM key is needed.LLM_API_KEY above covers extraction, summarization, and embeddings: Cognee defaults to openai/gpt-5-mini for the LLM and openai/text-embedding-3-large for embeddings, and embeddings reuse LLM_API_KEY when EMBEDDING_API_KEY is unset. To use another provider, set LLM_PROVIDER, LLM_MODEL, and — for Azure, Ollama, or OpenAI-compatible endpoints — LLM_ENDPOINT. Changing only the LLM leaves embeddings on OpenAI, so also set the EMBEDDING_* variables or set EMBEDDING_API_KEY to an OpenAI key so the default embeddings keep working. See LLM providers and embedding providers.
You can also persist settings in ~/.cognee-plugin/config.json:
Use it
Use Codex as usual — memory is captured and recalled automatically. To verify, end a session with/exit (which syncs it into Cognee), then start a fresh session and ask: “What do you know from cognee?” Answering from a clean session proves it’s recalling from your memory.
Sessions & datasets
- Sessions — set
COGNEE_SESSION_IDbefore launching Codex to resume or share a named live session across terminals. If you do not set it, the plugin chooses a session id from its configured session strategy. - Datasets — all writes and recall are scoped to one dataset (
agent_sessionsby default). SetCOGNEE_PLUGIN_DATASETto use a custom one. The Codex and Claude Code plugins share the default dataset, so memory carries across both.
How It Works
The plugin registers Codex lifecycle hooks:
A background idle watcher persists the session cache after periods of inactivity, and a final sync on session end bridges the session into the permanent graph.
Session distillation (self-improvement)
The Cognee coding-agent plugins (Claude Code, Codex) run session distillation for you — you never callimprove() by hand. A distillation pass fires on three triggers:
Overlapping triggers are safe. A per-session improve lock on the server serializes concurrent runs, and unchanged session content dedups server-side by content hash — so a repeat improve over content that hasn’t changed is a cheap no-op, not duplicated work.
Configuration
All triggers are tuned through environment variables read by the plugin. The defaults are chosen so distillation stays out of your way; you rarely need to change them.Turning it down or off
- Stop idle-triggered improves: set
COGNEE_IDLE_DISABLED=1before launching the agent. Session-end and per-turn improves still run. - Reduce mid-session improves: raise
COGNEE_AUTO_IMPROVE_EVERYto a large value so the per-turn trigger effectively never fires within a session. - Session-end distillation always runs when the plugin is active — it’s how a finished session reaches permanent memory.
Confirming it happened
- Cloud UI: the Self-improvement card at the top of a session on the Sessions page shows the status of the last graph enrichment and the dataset it wrote to.
- Plugin hook log: each automatic run emits an
improve_firedevent you can grep for when debugging (in local SDK mode, where the plugin calls the library directly instead of the HTTP endpoint, look forauto_improve_firedinstead). improve-unsupported.jsonmarker: if this file appears in the plugin’s shared state directory (24h TTL), the server rejected the improve endpoint and the plugin fell back to the legacyrememberbridge for that window — a signal the server predates session-aware improve.
Debugging & Resuming Sessions
Hooks are callbacks from Codex, not a durable job queue: events that happen while hooks are disabled or untrusted, or while the plugin cannot reach the backend, are not replayed later. When memory does not appear, check these layers first:
A resumed or second terminal continues the same live session only when the session id and dataset match: set
COGNEE_SESSION_ID before launching Codex and keep COGNEE_PLUGIN_DATASET unchanged, otherwise the resumed work lands in a new session. After changing hook trust, credentials, dataset, or session id, restart Codex so SessionStart can run with the new state.
Hook commands run with
python3, falling back to python if python3 isn’t found. If neither resolves on PATH — most commonly on Windows, where the python.org installer doesn’t always register a python3 alias — every hook fails with a “hook failure” error and no session is ever created. Run python3 --version or python --version in the same shell that launches Codex to confirm one is available, or reinstall Python with “Add python.exe to PATH” checked./exit) when you want SessionEnd to trigger the final graph sync. If the process is killed instead, recent session cache entries may exist, but the final session-to-graph sync may not have run yet.
Configuration Reference
Precedence: environment variables →~/.cognee-plugin/config.json → defaults.
Update or Remove
Reinstall to pull a new plugin version:GitHub Repository
View source code and the full configuration reference
Claude Code plugin
The same memory plugin for Claude Code