Codex Plugin
Automatically save conversation facts and inject context into prompts.
Installation
npx @audaxic/memory-codex install
This will:
- Prompt for your Audaxic general API key (saved to
~/.config/audaxic/config.json) - Copy hook scripts to
~/.codex/audaxic/ - Register hooks in
~/.codex/hooks.json - Configure the directory-aware MCP server in
~/.codex/config.toml
Get your API key from: memory-dashboard.audaxic.com
How It Works
The installer registers two Codex CLI hooks:
UserPromptSubmit → recall.js
When you submit a prompt, this hook:
- Parks the prompt in
~/.codex/audaxic/pending/as a per-message file - Searches Audaxic Memory for relevant context (POST /search) and drains one stale parked message in parallel
- Injects retrieved memories as
<audaxic_memory_context>into the agent
Stop → capture.js
When the agent finishes responding, this hook:
- Parks the assistant response in
~/.codex/audaxic/pending/ - Drains up to 3 stale parked messages
- Deletes a parking file only after
POST /addconfirms receipt; failed sends stay parked and retry
Architecture
┌──────────────────────────────────────────────────────────────┐
│ Codex CLI │
│ │
│ User types prompt │
│ │ │
│ ▼ │
│ UserPromptSubmit ──► recall.js │
│ │ ├─ buffer user prompt to disk │
│ │ └─ POST /search → inject context │
│ ▼ │
│ LLM responds │
│ │ │
│ ▼ │
│ Stop ──────────────► capture.js │
│ ├─ buffer assistant msg to disk │
│ └─ if buffer >= 30 → POST /add │
└──────────────────────────────────────────────────────────────┘
Environment Variable Alternative
Instead of the setup prompt, you can set the API key as an environment variable:
export AUDAXIC_API_KEY="ak_your_key_here"
The scripts check in this order:
AUDAXIC_API_KEYenvironment variabledirectoryKeysentry matching the sessioncwd~/.config/audaxic/config.jsongeneralapiKey
Directory-specific API keys
Give each project its own memory project by mapping a directory to an API key:
npx @audaxic/memory-codex key set --global
cd C:\projeler\my-project
npx @audaxic/memory-codex key set
npx @audaxic/memory-codex key list
npx @audaxic/memory-codex key resolve
The shared config:
{
"apiKey": "ak_general...",
"directoryKeys": {
"C:\\projeler\\my-project": "ak_project_a...",
"C:\\projeler\\another-project": "ak_project_b..."
}
}
Matching uses the nearest parent directory. Git worktrees fall back to the main checkout's key. The config is stored with mode 0600; keys never go into a repository. Each parked message stores the key it was captured with, so parallel sessions cannot route one directory's memory to another project.
See Directory-Specific API Keys for the full precedence, worktree behavior, and parallel-session rules.
The MCP server uses http_headers_helper to print the Authorization header for the current session directory. If Codex is launched from a non-project working directory, set AUDAXIC_PROJECT_DIR or add --directory <path> to the helper command in ~/.codex/config.toml.
If you already have an [mcp_servers.audaxic-memory] table in ~/.codex/config.toml, the installer leaves it unchanged. Remove or update that table to use the generated http_headers_helper block.
Uninstall
Remove the plugin by deleting the hook files:
# Remove hooks directory
rm -rf ~/.codex/audaxic/
# Remove hooks from ~/.codex/hooks.json
# (Edit the file and remove the Audaxic entries)
API Endpoints
| Endpoint | Method | Description |
|---|---|---|
https://api.memory.audaxic.com/search | POST | Search memories for context injection |
https://api.memory.audaxic.com/add | POST | Save conversation messages in batch |
Behavioral Triggers
AUTO-SEARCH before:
- Making architectural decisions
- Adding new dependencies
- Fixing bugs (check for prior solutions)
- Starting new sessions (load preferences)
AUTO-SAVE after:
- User states a preference
- Decision with rationale made
- Complex bug fixed
- Project conventions learned
DO NOT save:
- Temporary state, debug info, secrets
Content Rules
- One fact per memory
- Natural language, not keywords
- Include reasoning, not just outcomes
- Be specific for better semantic matching
Lifecycle
Add → Search → Update (delete + re-add) → Delete (when obsolete)
Troubleshooting
Hooks stopped after an update
Codex requires review for changed hook commands. Start codex, run /hooks, and trust the Audaxic recall.js and capture.js hooks. For automation only, codex exec --dangerously-bypass-hook-trust bypasses trust for that invocation.
MCP uses the wrong project
http_headers_helper resolves the key from the session working directory. If Codex is launched from a non-project directory, set AUDAXIC_PROJECT_DIR or add --directory <path> to the helper command in ~/.codex/config.toml.
npx @audaxic/memory-codex key resolve
If an existing [mcp_servers.audaxic-memory] table is present, the installer leaves it unchanged. Remove or update it to use the generated http_headers_helper block.
Plugin not working
- Verify hooks are registered: Check
~/.codex/hooks.json - Verify API key is set:
cat ~/.config/audaxic/config.json - Check
~/.codex/audaxic/pending/for unsent message files
Context not being injected
- Check that
recall.jsexists in~/.codex/audaxic/ - Verify API key is valid at memory-dashboard.audaxic.com
- Check network connectivity to
api.memory.audaxic.com
Messages not saving
- Check that
capture.jsexists in~/.codex/audaxic/ - Check
~/.codex/audaxic/pending/for unsent message files - Verify API endpoint is reachable