Skip to content

feat(agent-hooks): ship the two Codex CLI lifecycle hooks#1601

Merged
cyberlife-coder merged 1 commit into
developfrom
feat/codex-lifecycle-hooks
Jul 25, 2026
Merged

feat(agent-hooks): ship the two Codex CLI lifecycle hooks#1601
cyberlife-coder merged 1 commit into
developfrom
feat/codex-lifecycle-hooks

Conversation

@cyberlife-coder

Copy link
Copy Markdown
Owner

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

Hook Event Output channel
session-start.sh SessionStart hookSpecificOutput.additionalContext
stop.sh Stop decision: "block" + reason

SessionStart asks 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/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" after a compaction.

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 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 an AGENTS.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.shhookSpecificOutput.additionalContext with the load_working_context instruction
  • stop.shdecision: "block" with the save_working_context reason

check-promise-contract.py and the 35 guard-contract tests stay green.

Coverage after this PR

Agent Hooks
Claude Code 4 — SessionStart, Stop, PreCompact, PostToolUse
Codex CLI 2 — SessionStart, Stop
Windsurf 1 — pre_user_prompt (advisory)
Devin CLI 0 — MCP server wiring only

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.

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.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@cyberlife-coder
cyberlife-coder merged commit 34dfd02 into develop Jul 25, 2026
39 checks passed
@cyberlife-coder
cyberlife-coder deleted the feat/codex-lifecycle-hooks branch July 25, 2026 22:56
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