codex - ✅(Solved) Fix Support additionalContext in PreToolUse hooks or clarify Claude-style hook parity [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#19385Fetched 2026-04-25 06:10:14
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
labeled ×3unlabeled ×1

Error Message

That avoids the hard error, but it is not equivalent: 2. Update the hooks docs and relevant examples to explicitly warn that PreToolUse.additionalContext is unsupported despite Claude-style hook config compatibility, and recommend SessionStart, UserPromptSubmit, or PostToolUse depending on intent.

Root Cause

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 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:

  • SessionStart is cheap but too early and easy to stale/forget during long sessions.
  • UserPromptSubmit runs on every prompt even when no tool/search is about to happen.
  • PreToolUse is the natural low-token place to inject context specifically when a tool is about to run.

Fix Action

Fix / Workaround

The current workaround is to emit top-level systemMessage from PreToolUse instead:

PR fix notes

PR #19012: Mark codex_hooks stable

Description (problem / solution / changelog)

Why

Hooks are ready to graduate to GA in the next release!

What

  • Moves Feature::CodexHooks into the stable feature group.
  • Marks the codex_hooks feature spec as Stage::Stable and default-enabled.

Changed files

  • codex-rs/features/src/lib.rs (modified, +4/-4)

Code Example

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "echo '{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"additionalContext\":\"Before searching raw files, use the project knowledge graph.\"}}'"
          }
        ]
      }
    ]
  }
}

---

PreToolUse hook returned unsupported additionalContext

---

{"systemMessage":"graphify: Knowledge graph exists..."}

---

{
  "hookSpecificOutput": {
    "hookEventName": "PreToolUse",
    "additionalContext": "..."
  }
}
RAW_BUFFERClick to expand / collapse

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 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:

  • SessionStart is cheap but too early and easy to stale/forget during long sessions.
  • UserPromptSubmit runs on every prompt even when no tool/search is about to happen.
  • PreToolUse is 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.
  • PreToolUse is currently a guardrail/blocking hook, not a context-injection hook.

Suggested acceptance criteria

One of:

  1. Add PreToolUse.hookSpecificOutput.additionalContext support and inject it as extra developer context after the intercepted tool event, or
  2. Update the hooks docs and relevant examples to explicitly warn that PreToolUse.additionalContext is unsupported despite Claude-style hook config compatibility, and recommend SessionStart, UserPromptSubmit, or PostToolUse depending on intent.

Related context

extent analysis

TL;DR

Update the Codex hooks documentation to explicitly warn that PreToolUse.additionalContext is unsupported or add support for PreToolUse.hookSpecificOutput.additionalContext to inject extra developer context.

Guidance

  • Review the Codex hooks documentation to ensure it accurately reflects the supported features for each hook event, including PreToolUse.
  • Consider using alternative hook events like SessionStart, UserPromptSubmit, or PostToolUse for context injection, depending on the specific use case.
  • If supporting PreToolUse.additionalContext is desired, update the Codex code to parse and inject the additional context as extra developer context after the intercepted tool event.
  • Verify the behavior of PreToolUse hooks with and without additionalContext to ensure compatibility with existing tools and workflows.

Example

No code snippet is provided as the issue is more related to documentation and feature support rather than a specific code fix.

Notes

The current workaround of emitting a top-level systemMessage from PreToolUse is not equivalent to supporting additionalContext and may not be suitable for all use cases. The suggested acceptance criteria provide two possible paths forward: adding support for PreToolUse.hookSpecificOutput.additionalContext or updating the documentation to reflect the current limitations.

Recommendation

Apply workaround: Update the Codex hooks documentation to explicitly warn that PreToolUse.additionalContext is unsupported, and recommend alternative hook events for context injection. This approach ensures that developers are aware of the current limitations and can plan their workflows accordingly.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

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.
  • PreToolUse is currently a guardrail/blocking hook, not a context-injection hook.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

codex - ✅(Solved) Fix Support additionalContext in PreToolUse hooks or clarify Claude-style hook parity [1 pull requests, 1 participants]