Docs: hooks.json timeout key is documented but runtime requires timeout_sec
The official Hooks documentation documents timeout as the key for hook command configurations:
{
"type": "command",
"command": "python3 ~/.codex/hooks/session_end.py",
"timeout": 3
}
The docs also state:
timeoutis in seconds. Iftimeoutis omitted, Codex uses600seconds for most hooks.
However, in practice, the timeout key is not accepted by the runtime. The key that actually works is timeout_sec.
This is a documentation bug -- the runtime field name does not match what is published.
Affected surfaces
~/.codex/hooks.jsonhooks.jsonin any.codex/directory- Inline
[hooks]tables inconfig.toml
Expected fix
Either:
- Update the docs to document
timeout_secas the correct key, or - Add
timeout_secas an accepted alias if the runtime already supports both.
---
Source Code Evidence
The Codex Rust source confirms timeout is the only accepted JSON key.
File: codex-rs/config/src/hook_config.rs lines 147-150:
#[serde(default, rename = "timeout")]
timeout_sec: Option<u64>,
The rename = "timeout" serde attribute means the JSON field name is timeout. The Rust struct field is named timeout_sec — that's just an internal naming convention, not the JSON key.
This is the complete serde configuration for the timeout field: there is no alias attribute for timeout_sec, so timeout_sec as a JSON key is not accepted by the parser.
Test evidence: The same source includes a test hooks_file_deserializes_existing_json_shape that parses "timeout": 10 and asserts success — confirming this is the tested, supported shape.
Reference: https://learn.chatgpt.com/docs/hooks.md uses "timeout": 3 and "timeout": 30 in all examples, matching the runtime source.
1 Comment
The issue currently appears internally inconsistent.
The title and opening section say that
timeoutis rejected andtimeout_secworks, but the source analysis later in the report shows:That indicates
timeoutis the accepted serialized key, whiletimeout_secis only the internal Rust field name.Could you share the exact runtime reproduction that showed the opposite behavior, including:
hooks.jsonorconfig.toml)Without that reproduction, the current source and existing deserialization test suggest the documentation is already correct and the issue title/opening may need to be updated.
I can also add a focused local test covering both
"timeout"and"timeout_sec"if maintainers want additional confirmation.