Codex
How Hindsight hooks into Codex (the CLI, the desktop app and the editor extension), and the one thing you have to do yourself.
Codex needs one step from you. Hindsight adds its hooks, but Codex won’t run a hook until you trust it.
What gets installed
Hindsight writes hooks to hooks.json in Codex’s home folder: $CODEX_HOME if you’ve set it, otherwise ~/.codex
(on Windows, C:\Users\you\.codex\hooks.json). If that folder doesn’t exist, Codex isn’t installed as far as
Hindsight can tell, and nothing is written.
The Codex CLI, the desktop app and the editor extension all read this one file, so one connection covers all three.
There are five hooks:
| Event | When it fires |
|---|---|
UserPromptSubmit |
You send a prompt |
PostToolUse |
A tool call finished |
PostModelRequest |
A model request finished, with its token usage |
Stop |
The agent finished its run |
Interrupt |
You stopped a run |
Each hook has two commands, because Codex runs a different one on Windows:
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "\"C:/Users/you/AppData/Local/Hindsight/hindsight-daemon.exe\" emit --source codex",
"commandWindows": "& 'C:\\Users\\you\\AppData\\Local\\Hindsight\\hindsight-daemon.exe' emit --source codex",
"timeout": 5
}
]
}
]
Interrupt has a timeout of 3. The commandWindows form calls the daemon with & and single quotes because Codex
runs it through PowerShell, which won’t take a quoted path followed by arguments.
Trust the hooks
Open Codex and trust them, one time:
- In the CLI, type
/hooks. - In the desktop app, go to Settings, then Hooks.
Until you do, Codex skips them and Hindsight sees nothing from Codex. connect says so when it adds them: “trust them in
Codex (Settings > Hooks, or /hooks)”.
Codex remembers your trust by each hook’s position in the file and a hash of the hook. That’s why Hindsight never
reorders hooks.json. If its hooks are already there, it updates them where they sit. If one is missing, it goes at the
end. A hook that moved would land on a position you’d trusted for something else, and Codex would quietly skip it. If you
edit the file by hand and move things around, you may have to trust the hooks again.
What Hindsight sees
- Your prompts. A length and a keyed hash.
- The run. A prompt starts it.
Stopends it, orInterruptif you stopped it. - Tool calls. The tool, how long it took, and whether it failed. For
apply_patchit counts the lines added and removed across every file in the patch, and takes the language and a hashed path from the patch’s file headers. - Tokens. Every model request ends with a hook that carries its token usage. The daemon adds them up per run and puts the total on the run’s end, along with the model. Cached input is counted as cache reads, not plain input.
- How much it said. Only the length of the agent’s last message, from
Stop.
Prompt text, code, file paths and tool output are used only for lengths, counts and hashes, then dropped. The one
other thing Hindsight opens is the first line of Codex’s transcript, to read the session’s source.
Things to know
codex execisn’t you. A headless run triggers the same hooks. Hindsight reads the first line of the session transcript, and when the session came fromcodex exec, its prompts start runs but don’t count as prompts.- Subagents. A subagent’s prompt is the agent talking to itself, so it starts a run without counting as a prompt. Its tokens are added to the run that started it.
- Commits. A commit made from Codex’s shell is recorded as Codex’s. See Commits.
- The desktop app. Hindsight treats the Codex window as an app you work in, so keyboard and mouse input in it counts as presence.
Check that it’s working
Send Codex a prompt after trusting the hooks, then look at the timeline on your Today page.
hindsight-daemon status prints a count of stored events if you want to watch it go up.
If nothing shows up, the usual reason is trust. Open /hooks in the CLI, or Settings, then Hooks, in the app, and look for
the Hindsight hooks.
Disconnect
hindsight-daemon disconnect
This removes Hindsight’s hooks from hooks.json. If the file held nothing else, it’s deleted. Your own hooks stay. Like
every tool, Codex is hooked up again at Hindsight’s next start unless you’ve uninstalled it.