What version of Codex is running?
Codex Desktop on Windows. Local CLI reports:
What platform is your computer?
Windows, PowerShell session.
What issue are you seeing?
PreToolUse hooks configured for built-in image generation matcher candidates did not fire before a real image_gen tool call. The same hook script blocks correctly when invoked with a simulated hook payload, so this looks like the built-in image generation call is not being emitted through the hook runtime.
I originally observed this on local CLI 0.124.0 and re-tested after updating the npm-installed CLI to 0.128.0. The behavior was unchanged in the tested Codex Desktop session.
Why this matters
Some projects need generated image assets to go through a wrapper that records provenance metadata, for example prompt/model metadata in EXIF, a manifest, or an asset ledger. If built-in image_gen cannot be observed or blocked by PreToolUse, that wrapper cannot be enforced before generation runs.
Steps to reproduce
- Enable Codex hooks in
config.toml:
[features]
codex_hooks = true
- Register
PreToolUse hooks for likely built-in image generation matcher names:
[[hooks.PreToolUse]]
matcher = "image_gen.imagegen"
[[hooks.PreToolUse.hooks]]
type = "command"
command = "python /path/to/check-image-generation-route.py"
[[hooks.PreToolUse]]
matcher = "imagegen"
[[hooks.PreToolUse.hooks]]
type = "command"
command = "python /path/to/check-image-generation-route.py"
[[hooks.PreToolUse]]
matcher = "image_generation"
[[hooks.PreToolUse.hooks]]
type = "command"
command = "python /path/to/check-image-generation-route.py"
- Use a hook script that exits non-zero for image generation events. I verified the script itself blocks when it receives a simulated image payload:
{"tool_name":"image_gen.imagegen","tool_input":{"prompt":"Project-bound website/app asset. Asset role: route validation."}}
The hook exited with code 2.
- Ask Codex Desktop to generate an image with the built-in image generation tool.
Actual behavior
The built-in image generation tool executed and saved an image under $CODEX_HOME/generated_images/.... The PreToolUse hook did not block the call and did not appear to receive the image tool event.
The generated file had no project provenance metadata when inspected with the local EXIF reader used by the provenance guard:
{
"prompt": "",
"model": ""
}
This does not prove whether image generation has no hook payload in all Codex builds, but in this tested Desktop session it shows the configured PreToolUse guard was not invoked before built-in image generation.
Expected behavior
Built-in image generation should emit a PreToolUse event before generation. The hook payload should include a stable hook-facing tool name, such as image_gen or image_gen.imagegen, and the prompt/options needed for policy decisions.
If the hook exits with the documented block/deny behavior, the image generation call should not execute.
Ideally, image generation should also emit PostToolUse with enough metadata to audit generated output paths, success status, and any generated file identifiers.
Additional context
Related issue/PR:
This issue is asking whether the built-in image generation handler needs the same kind of hook participation. From the outside, the symptom is the same class of problem: a built-in structured tool executes, but hook policy cannot observe or block it.
What version of Codex is running?
Codex Desktop on Windows. Local CLI reports:
What platform is your computer?
Windows, PowerShell session.
What issue are you seeing?
PreToolUsehooks configured for built-in image generation matcher candidates did not fire before a realimage_gentool call. The same hook script blocks correctly when invoked with a simulated hook payload, so this looks like the built-in image generation call is not being emitted through the hook runtime.I originally observed this on local CLI 0.124.0 and re-tested after updating the npm-installed CLI to 0.128.0. The behavior was unchanged in the tested Codex Desktop session.
Why this matters
Some projects need generated image assets to go through a wrapper that records provenance metadata, for example prompt/model metadata in EXIF, a manifest, or an asset ledger. If built-in
image_gencannot be observed or blocked byPreToolUse, that wrapper cannot be enforced before generation runs.Steps to reproduce
config.toml:PreToolUsehooks for likely built-in image generation matcher names:{"tool_name":"image_gen.imagegen","tool_input":{"prompt":"Project-bound website/app asset. Asset role: route validation."}}The hook exited with code
2.Actual behavior
The built-in image generation tool executed and saved an image under
$CODEX_HOME/generated_images/.... ThePreToolUsehook did not block the call and did not appear to receive the image tool event.The generated file had no project provenance metadata when inspected with the local EXIF reader used by the provenance guard:
{ "prompt": "", "model": "" }This does not prove whether image generation has no hook payload in all Codex builds, but in this tested Desktop session it shows the configured
PreToolUseguard was not invoked before built-in image generation.Expected behavior
Built-in image generation should emit a
PreToolUseevent before generation. The hook payload should include a stable hook-facing tool name, such asimage_genorimage_gen.imagegen, and the prompt/options needed for policy decisions.If the hook exits with the documented block/deny behavior, the image generation call should not execute.
Ideally, image generation should also emit
PostToolUsewith enough metadata to audit generated output paths, success status, and any generated file identifiers.Additional context
Related issue/PR:
apply_patch.apply_patchby addingPreToolUse/PostToolUsepayload support and removing hardcodedtool_name: "Bash"behavior.This issue is asking whether the built-in image generation handler needs the same kind of hook participation. From the outside, the symptom is the same class of problem: a built-in structured tool executes, but hook policy cannot observe or block it.