Persistent memory for Codex
OnlyBots gives Codex a record of where the work stands that survives new sessions and carries over to Claude Code. It is the setup we benchmarked: 19% lower estimated token spend than cold restarts across 54 Codex runs.
Set up Codex
-
Install the CLI
curl -fsSL https://onlybots.ai/install | bashNeeds Node.js 18+, npm, curl and tar on macOS or Linux. The installer verifies the release checksum before unpacking; read the script first if you prefer.
-
Put it first on your PATH
export PATH="$HOME/.onlybots/bin:$PATH"This puts the OnlyBots
codexwrapper ahead of the real one, which is what turns Codex hooks on. Add the line to your shell profile. -
Connect Codex
onlybotsctl quickstart --api-base https://onlybots.ai --adapter codexQuickstart creates your agent's identity, installs the Codex hooks, starts the local daemon and checks the connection.
-
Check it
onlybotsctl status onlybotsctl doctorAfter a restart, run
onlybotsctl startto bring the daemon back.
What happens in a Codex session
| Hook | What OnlyBots does |
|---|---|
SessionStart | Attaches the session to this repository's memory. |
UserPromptSubmit | Returns a compact context pack (about 360 tokens at most) as additional context: the current goal, recent turns and how the last session ended. |
Stop | Records the turn's outcome and saves the updated working state. |
PreCompact / PostCompact | Saves working state immediately around compaction. |
Moving work between Codex and Claude Code
When both adapters run under the same OnlyBots profile, there is nothing to do: each tool reads the working state the other saved for the same repository.
For an explicit, auditable transfer, export a signed handoff capsule from one tool and import it in the other. The capsule carries the task state, memory references and open questions, and the receiver verifies the signature before loading it.
onlybotsctl handoff export --source codex --target claude-code --workspace-root "$PWD" --session-id <session> --prompt "Finish the token-expiry fix"onlybotsctl handoff import --target claude-code --id <handoff_id> --workspace-root "$PWD" --session-id <session>Use onlybotsctl handoff explain --id <handoff_id> to see exactly what a capsule contains.
Codex memory questions
Does Codex remember between sessions?
Codex reads AGENTS.md at the start of a session and can resume an earlier session's transcript. It doesn't keep a running record of where the work stands across new sessions. OnlyBots adds that through Codex lifecycle hooks.
Why does OnlyBots install its own codex command?
Codex only runs lifecycle hooks when hooks are enabled. The codex wrapper in ~/.onlybots/bin starts the real Codex with hooks enabled. If ~/.onlybots/bin isn't first on your PATH, Codex runs without OnlyBots.
Can I move work from Claude Code to Codex?
Yes, in two ways. If both tools are installed under the same OnlyBots profile, working state flows between them automatically, per repository. For an explicit transfer, onlybotsctl handoff export packages the task state, memory references and open questions into a signed capsule, and onlybotsctl handoff import verifies and loads it on the other side.
Is the Codex install per project?
No. The Codex adapter installs into ~/.codex/hooks.json for your user, and memory is still kept separately for each repository.