Allow UserPromptSubmit hooks to fail closed before model requests
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start with the UserPromptSubmit coverage in codex-hooks and the configRequirements/read path for Desktop and app-server consumers. Run the listed schema-generation and targeted package tests first. Done means the opt-in failure mode is represented in config and generated artifacts, trust hashing changes when it changes, and failed hooks prevent model requests without exposing sensitive prompt data.
Written by the indexing model from the issue text.
Description
What variant of Codex are you using?
Codex Desktop/App, app-server, and CLI. The motivating reproduction was on Windows with Codex 0.144.5; the proposed behavior was also implemented and validated against current main.
What feature would you like to see?
Add an opt-in fail-closed policy for UserPromptSubmit command hooks so a detector or policy hook can prevent prompt transmission when the hook itself fails.
Today, a UserPromptSubmit hook can reject a prompt through a valid blocking result, but Codex continues submission when the hook process crashes, times out, cannot be executed, or emits malformed output. That makes the hook unsuitable for local secret-paste prevention or similar pre-transmission policy checks: detector failure must not silently become permission to send the prompt.
A narrow configuration shape would be:
{
"hooks": {
"UserPromptSubmit": [
{
"matcher": "",
"failureMode": "block",
"hooks": [
{
"type": "command",
"command": "path/to/local-detector"
}
]
}
]
}
}
Proposed semantics:
failureModeacceptscontinueorblock.- Omitted or
continuepreserves the existing fail-open behavior. blockapplies only toUserPromptSubmit; other events warn and remain fail-open.- Nonzero exit, timeout, missing executable, malformed output, and event-serialization failure produce a redacted blocking diagnostic and no model request.
- The policy participates in hook trust hashing so changing it requires re-trust.
- Desktop/app-server config reads expose the effective value so UI and runtime state remain consistent.
This is the concrete blocking-policy part of the broader cross-surface hook goals tracked in #21753.
Additional information
I prepared a validated candidate implementation because external code contributions are invitation-only:
- Branch: https://github.com/AleZworks/codex/tree/codex/user-prompt-submit-fail-closed
- Compare: https://github.com/openai/codex/compare/main...AleZworks:codex/user-prompt-submit-fail-closed
- Commit: https://github.com/AleZworks/codex/commit/11c13c7
The candidate:
- implements the opt-in policy in config and the hook engine;
- carries it through
configRequirements/readfor Desktop/app-server consumers; - regenerates config, JSON Schema, and TypeScript artifacts;
- adds unit and RPC coverage;
- adds a Linux core integration test that asserts a failed fail-closed
UserPromptSubmithook results in zero model requests.
Local validation completed:
just write-config-schemajust write-app-server-schemajust test -p codex-app-server-protocol(262 passed)just test -p codex-config(205 passed)just test -p codex-hooks -E 'test(user_prompt_submit)'(8 passed)just test -p codex-hooks -E 'test(failure_mode_changes_hook_trust_hash)'(1 passed)just test -p codex-app-server -E 'test(config_requirements_read_includes_hook_failure_mode)'(1 passed)- targeted
just fixacross affected crates cargo fmt --all
The core hooks integration suite is cfg-disabled on Windows and is intended to run in Linux CI.
- Dominant language
- Rust
- Stars
- 125k
- Forks
- 19.5k
- Avg merge
- 1m
- Merged PRs (30d)
- 1k
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from openai/codex
-
enhancement remote
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
bug CLI windows-os
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
macOS sandbox blocks hw.optional.arm64 sysctl, causing Flutter to misdetect Apple Silicon as x64 Openbug CLI sandbox
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug CLI TUI
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
CLI config enhancement skills
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
bevyengine/bevy#25861 ·
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
A-linter
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
oxc-project/oxc#26863 ·