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
Install
The Codex plugin requires hooks. Enable them, then install from the Codex marketplace:You can enable hooks manually instead by adding
[features]\nhooks = true to ~/.codex/config.toml.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-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 — by default a new
session_idis generated each launch. SetCOGNEE_SESSION_IDto resume or share a named session across terminals. - 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:| Hook | Behavior |
|---|---|
SessionStart | mode select, identity setup, dataset readiness, watcher bootstrap |
UserPromptSubmit | context lookup + async prompt staging |
PostToolUse | async trace write |
Stop | assistant answer write |
PreCompact | memory anchor build before compaction |
SessionEnd | trigger detached final sync worker |
Configuration Reference
Precedence: environment variables →~/.cognee-plugin/config.json → defaults.
| Setting | Env var | Default | Notes |
|---|---|---|---|
| Dataset | COGNEE_PLUGIN_DATASET | agent_sessions | Dataset for writes and recall |
| Session ID | COGNEE_SESSION_ID | per-launch | Override to resume a named session |
| Session strategy | COGNEE_SESSION_STRATEGY | per-directory | per-directory, git-branch, static |
| Base URL | COGNEE_BASE_URL | unset | Set to use a managed/remote endpoint |
| API key | COGNEE_API_KEY | unset | Auto-minted if absent in local mode |
| Local API URL | COGNEE_LOCAL_API_URL | http://localhost:8011 | Local API base URL |
| Local LLM | LLM_API_KEY, LLM_MODEL | unset | Required for local mode |
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