Repository navigation
Support additionalContext in PreToolUse hooks or clarify Claude-style hook parity #19385
Description
What variant of Codex are you using?
CLI
What version of Codex are you using?
codex-cli 0.124.0
What happened?
Codex hooks are now stable/default-enabled, and the code/release language describes them as "Claude-style lifecycle hooks" loaded from hooks.json / config layers. However, PreToolUse currently rejects hookSpecificOutput.additionalContext even though that is a common Claude-style context-injection pattern.
A minimal PreToolUse hook like this:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "echo '{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"additionalContext\":\"Before searching raw files, use the project knowledge graph.\"}}'"
}
]
}
]
}
}produces:
PreToolUse hook returned unsupported additionalContext
The official hooks docs also state that for PreToolUse, additionalContext is parsed but not supported yet.
Why this matters
This creates a sharp compatibility trap for tools that install Claude-style hooks and expect context injection before tool use. One concrete example is Graphify:
- Graphify issue: codex not support additionalContext on PreToolUse Graphify-Labs/graphify#533
- Graphify compatibility PR: fix hook context output - Fixes #533 Graphify-Labs/graphify#534
Graphify originally installed a PreToolUse hook that injected context reminding the agent to consult graphify-out/GRAPH_REPORT.md before raw file search. That pattern works in Claude-style hook environments, but Codex rejects it.
The current workaround is to emit top-level systemMessage from PreToolUse instead:
{"systemMessage":"graphify: Knowledge graph exists..."}That avoids the hard error, but it is not equivalent:
- It surfaces as repeated warning-style UI noise before every intercepted tool call.
- It is not the same documented developer-context path as
additionalContext. - It still leaves third-party hook installers needing Codex-specific branching.
SessionStart.additionalContext and UserPromptSubmit.additionalContext are valid alternatives for some tools, but they are not equivalent to PreToolUse:
SessionStartis cheap but too early and easy to stale/forget during long sessions.UserPromptSubmitruns on every prompt even when no tool/search is about to happen.PreToolUseis the natural low-token place to inject context specifically when a tool is about to run.
Expected behavior
Ideally, PreToolUse should support:
{
"hookSpecificOutput": {
"hookEventName": "PreToolUse",
"additionalContext": "..."
}
}and add that text as extra developer context for the next model continuation, matching the behavior already available on SessionStart, UserPromptSubmit, and PostToolUse.
If supporting this on PreToolUse is intentionally out of scope because the model has already decided to call a tool, then the docs and release wording should clarify the distinction:
- Codex supports Claude-style hook discovery/config shape.
- Codex does not provide full Claude Code output-field parity for every hook event.
PreToolUseis currently a guardrail/blocking hook, not a context-injection hook.
Suggested acceptance criteria
One of:
- Add
PreToolUse.hookSpecificOutput.additionalContextsupport and inject it as extra developer context after the intercepted tool event, or - Update the hooks docs and relevant examples to explicitly warn that
PreToolUse.additionalContextis unsupported despite Claude-style hook config compatibility, and recommendSessionStart,UserPromptSubmit, orPostToolUsedepending on intent.
Related context
- Codex hooks docs: https://developers.openai.com/codex/hooks
- Codex PR marking hooks stable: Mark codex_hooks stable #19012
- Codex 0.124.0 release notes mention stable hooks and expanded hook support: https://github.com/openai/codex/releases/tag/rust-v0.124.0
Activity
oxysoft commentedon May 8, 2026
Indexed this hook ticket in the umbrella tracker: #21753
Goal: collect the scattered Codex hook requests and bugs into one parity matrix for Full Claude Code Hook Parity (29+), while preserving this issue as the detailed thread for its specific behavior.
fix(guards): read APEX evidence from the Codex rollout tree in code_mode
fix(guards): make check-skill gates code_mode-proof and close shell w…
fix(guards): give require-apex-agents a rollout ground-truth fallback
Necmttn commentedon Jun 21, 2026
Small current-main check at
aaf737fa: this looks implemented now, so the remaining closeout may just be identifying the fixing release/version.Evidence I found:
PreToolUseOutcomenow carriesadditional_contexts, andrun()flattens parsed hook contexts into the returned outcome.parse_completed()appends parsedadditionalContextinto model-visible context.parse_pre_tool_use()readshookSpecificOutput.additionalContext; the unsupported-field checks reject invalidupdatedInput/permissionDecisionshapes, not context-only output.pre-tool-use.command.output.schema.jsonincludeshookSpecificOutput.additionalContext.pre_tool_use_records_additional_context_for_shell_commandasserts the follow-up model request contains the PreToolUse context as developer text.PreToolUseadditionalContextas supported: https://developers.openai.com/codex/hooksCloseout suggestion: link the commit/release where this shipped, then close as fixed. If
0.124.0still rejects the exact payload from the issue, keeping a regression with that JSON shape would cover the compatibility case directly.Generated with ax.
feat(steering): codex queue steering via harness-side lifecycle hooks (…
etraut-openai commentedon Aug 4, 2026
PreToolUse.additionalContextis implemented across schema, parsing, context, tests, and docs.feat(hooks): Codex UserPromptSubmit collision-awareness hook (#116)
feat(memory): pre-tool inject (host-probed) + subagent task-text reca…
feat(memory): pre-tool inject (host-probed) + subagent task-text reca…
feat(memory): pre-tool inject (host-probed) + subagent task-text reca…
feat(memory): pre-tool inject (host-probed) + subagent task-text reca…
feat(memory): pre-tool inject (host-probed) + subagent task-text reca…
fix(memory): retire stale Codex host-capability claims — pre-tool gap…
test(memory): widen the Codex-parity SKILL.md pin to the full claim s…
plan(SL-263): scope the pi and codex memory-surfacing ports