Skip to main content
Add persistent memory to the Codex CLI with the Cognee memory plugin — no code and no pip install. 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
Sessions are disposable; your memory isn’t.

Install

The Codex plugin requires hooks. Enable them, then install from the Codex marketplace:
codex features enable hooks
codex plugin marketplace add topoteretes/cognee-integrations --ref main
codex plugin add cognee@cognee
You can enable hooks manually instead by adding [features]\nhooks = true to ~/.codex/config.toml.
On startup the status line shows cognee: <dataset> · <mode> to confirm the plugin is active.

Configure your backend

Set environment variables in the shell that launches Codex.
Point the plugin at Cognee Cloud or a remote server by setting both:
export COGNEE_BASE_URL="https://your-tenant.aws.cognee.ai"
export COGNEE_API_KEY="ck_..."
You can also persist settings in ~/.cognee-plugin/config.json:
{
  "base_url": "https://your-tenant.aws.cognee.ai",
  "dataset": "agent_sessions"
}

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 — by default a new session_id is generated each launch. Set COGNEE_SESSION_ID to resume or share a named session across terminals.
  • Datasets — all writes and recall are scoped to one dataset (agent_sessions by default). Set COGNEE_PLUGIN_DATASET to 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:
HookBehavior
SessionStartmode select, identity setup, dataset readiness, watcher bootstrap
UserPromptSubmitcontext lookup + async prompt staging
PostToolUseasync trace write
Stopassistant answer write
PreCompactmemory anchor build before compaction
SessionEndtrigger detached final sync worker
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.

Configuration Reference

Precedence: environment variables → ~/.cognee-plugin/config.json → defaults.
SettingEnv varDefaultNotes
DatasetCOGNEE_PLUGIN_DATASETagent_sessionsDataset for writes and recall
Session IDCOGNEE_SESSION_IDper-launchOverride to resume a named session
Session strategyCOGNEE_SESSION_STRATEGYper-directoryper-directory, git-branch, static
Base URLCOGNEE_BASE_URLunsetSet to use a managed/remote endpoint
API keyCOGNEE_API_KEYunsetAuto-minted if absent in local mode
Local API URLCOGNEE_LOCAL_API_URLhttp://localhost:8011Local API base URL
Local LLMLLM_API_KEY, LLM_MODELunsetRequired for local mode

Update or Remove

Reinstall to pull a new plugin version:
codex plugin remove cognee@cognee
codex plugin add cognee@cognee

GitHub Repository

View source code and the full configuration reference

Claude Code plugin

The same memory plugin for Claude Code