feat(agent-hooks): ship the two Codex CLI lifecycle hooks#1601
Merged
Conversation
Codex CLI had a README and nothing else. The hooks existed only inside the documentation-refactor draft, which is not close to merging — so a working, self-contained integration was blocked behind an unrelated review. `SessionStart` asks the model to resume its rolling working context, and carries the post-compaction reminder: per the Codex hooks reference, `PreCompact`/`PostCompact` support neither `additionalContext` nor a documented `decision`/`reason`, so a Codex PreCompact hook has no channel that reaches the model at all. `SessionStart` does, and it fires with `source: "compact"` afterwards. `Stop` blocks the first stop per session with a `save_working_context` reminder and lets every later one through, guarded by a session-keyed sentinel — the same shape as the Claude Code hook, with a `codex-` prefix so both can run side by side. Two claims went false the moment these shipped, and are corrected here: `integrations/agent-hooks/README.md` said Codex "has no equivalent hook mechanism yet", and `crates/velesdb-memory/README.md` repeated it twice. Codex does have one — `[[hooks.*]]` TOML tables — and we now use it. Verified: both scripts parse, and driven with a real payload `session-start.sh` emits `hookSpecificOutput.additionalContext` while `stop.sh` emits `decision: "block"` with its reason.
Up to standards ✅🟢 Issues
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Codex CLI had a README and nothing else. The hooks existed only inside the documentation-refactor draft (#1593), which is not close to merging — so a working, self-contained integration was blocked behind an unrelated review.
What ships
session-start.shSessionStarthookSpecificOutput.additionalContextstop.shStopdecision: "block"+reasonSessionStartasks the model to resume its rolling working context, and also carries the post-compaction reminder. That placement is deliberate: per the Codex hooks reference,PreCompact/PostCompactsupport neitheradditionalContextnor a documenteddecision/reason, so a CodexPreCompacthook has no channel that reaches the model at all.SessionStartdoes, and it fires withsource: "compact"after a compaction.Stopblocks the first stop per session with asave_working_contextreminder and lets every later one through, guarded by a session-keyed sentinel — the same shape as the Claude Code hook, with acodex-prefix so both can run side by side in the same environment.Two claims went false the moment these shipped
Corrected in the same change, because shipping the hooks is what made them false:
integrations/agent-hooks/README.md— "Codex CLI (a documented instruction-file convention, since Codex has no equivalent hook mechanism yet)"crates/velesdb-memory/README.md— "Codex CLI has no hook mechanism yet; the same directory documents anAGENTS.md-based convention for it." (twice)Codex does have one —
[[hooks.*]]TOML tables — and this PR uses it.Verification
Both scripts parse (
bash -n). Driven with a real payload:session-start.sh→hookSpecificOutput.additionalContextwith theload_working_contextinstructionstop.sh→decision: "block"with thesave_working_contextreasoncheck-promise-contract.pyand the 35 guard-contract tests stay green.Coverage after this PR
SessionStart,Stop,PreCompact,PostToolUseSessionStart,Stoppre_user_prompt(advisory)Devin is deliberately untouched: it is wired as an MCP client by the installer but has no hook surface here, and whether it is a real target is a product decision, not something to invent.