Skip to content

feat(codex): Hindsight memory integration for OpenAI Codex CLI#713

Closed
benfrank241 wants to merge 1 commit intomainfrom
feat/codex-integration
Closed

feat(codex): Hindsight memory integration for OpenAI Codex CLI#713
benfrank241 wants to merge 1 commit intomainfrom
feat/codex-integration

Conversation

@benfrank241
Copy link
Contributor

Summary

  • Hooks-based long-term memory integration for OpenAI Codex CLI (v0.116.0+ hooks support)
  • Three hooks: SessionStart (daemon pre-warm), UserPromptSubmit (recall + context injection), Stop (retain conversation)
  • install.sh copies scripts to ~/.hindsight/codex/scripts/, writes ~/.codex/hooks.json with absolute paths, and enables codex_hooks = true in ~/.codex/config.toml
  • Supports both Hindsight Cloud and local hindsight-embed daemon mode

Key differences from Claude Code integration

Claude Code Codex
Transcript format {type: "user", message: {role, content}} {msg: {type: "user_message", message: "..."}}
Hook config location Plugin marketplace (auto-installed) ~/.codex/hooks.json (written by install.sh)
Script root env var $CLAUDE_PLUGIN_ROOT None — absolute paths in hooks.json
State directory $CLAUDE_PLUGIN_DATA/state/ ~/.hindsight/codex/state/
Config file ~/.hindsight/claude-code.json ~/.hindsight/codex.json
Async hooks async: true supported Not supported — Stop runs sync
SessionEnd event Yes No

Test plan

  • python3 -c "from lib.config import load_config; from lib.content import read_transcript" imports cleanly
  • Transcript parser correctly maps user_messagerole: user, agent_messagerole: assistant, skips other event types
  • install.sh writes hooks.json with correct absolute paths
  • install.sh --uninstall removes hooks.json and codex_hooks flag
  • Recall hook outputs hookSpecificOutput.additionalContext JSON
  • Retain hook upserts session to Hindsight bank

Files

hindsight-integrations/codex/
├── hooks/hooks.json          # Template (install.sh writes the real one with absolute paths)
├── install.sh                # Installs to ~/.hindsight/codex/ + patches ~/.codex/
├── settings.json             # Default configuration
├── README.md
└── scripts/
    ├── session_start.py      # SessionStart hook
    ├── recall.py             # UserPromptSubmit hook
    ├── retain.py             # Stop hook
    └── lib/
        ├── config.py         # Settings loading (~/.hindsight/codex.json)
        ├── content.py        # Codex transcript parser + recall/retain formatting
        ├── state.py          # File-based state (~/.hindsight/codex/state/)
        ├── bank.py           # Bank ID derivation
        ├── daemon.py         # hindsight-embed lifecycle (PROFILE_NAME="codex")
        ├── client.py         # HTTP client (identical to claude-code)
        └── llm.py            # LLM provider detection (identical to claude-code)

Hooks-based integration that gives Codex CLI long-term memory via Hindsight.
Three hooks keep memory in sync: SessionStart (daemon pre-warm), UserPromptSubmit
(recall + context injection), Stop (retain conversation to memory).

Key differences from the Claude Code integration:
- Codex transcript format: JSONL with {msg: {type, message}} (user_message/agent_message)
- No CODEX_PLUGIN_ROOT env var — install.sh writes hooks.json with absolute paths
- State stored in ~/.hindsight/codex/state/ (not CLAUDE_PLUGIN_DATA)
- No async: true in hooks (not supported by Codex)
- No SessionEnd event
- hooks.json written to ~/.codex/hooks.json with codex_hooks = true in config.toml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant