openai/codex · error
failed to load required managed hooks
Error message
failed to load required managed hooks: {} What it means
Hooks::new binds a session's hook runtime and requires that all managed (requirement-imposed) hooks load successfully; at least one failed to load (missing hook file, bad MCP config, or unloadable hook definition) and managed hooks cannot be skipped, so session creation fails with the formatted load errors.
Solutions
- Inspect the formatted load errors to identify which managed hook failed
- Fix or restore the managed hooks configuration (requirements.toml / hooks files) so every required hook loads
- Check that any MCP server the hooks depend on is configured and reachable
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at codex-rs/hooks/src/registry.rs:81 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of openai/codex@339751715c (2026-08-25).
Data as JSON: /api/errors/97520363aeb342a6.
Report an issue: GitHub.
Appendix: source
Thrown at codex-rs/hooks/src/registry.rs:81
engine: ClaudeHooksEngine,
}
impl Hooks {
/// Bind this session's hook runtime and output files to its thread, rejecting unloadable
/// required managed hooks.
pub fn new(
config: HooksConfig,
thread_id: ThreadId,
mcp_executor: Arc<dyn HookMcpExecutor>,
) -> anyhow::Result<(Self, Receiver<codex_protocol::protocol::HookCompletedEvent>)> {
let (result_sender, result_receiver) = async_channel::unbounded();
let environment = Arc::new(std::env::vars_os().collect());
let hooks = Self::from_config(config, mcp_executor, Arc::clone(&environment), |shell| {
CommandHookRuntime::new(shell, environment, thread_id, result_sender)
});
let required_load_errors = hooks.engine.required_load_errors();
if !required_load_errors.is_empty() {
anyhow::bail!(
"failed to load required managed hooks: {}",
required_load_errors.join("; ")
);
}
Ok((hooks, result_receiver))
}
/// Preserve in-flight background hooks while applying a refreshed configuration.
pub fn reconfigured(&self, config: HooksConfig) -> Self {
Self::from_config(
config,
Arc::clone(&self.engine.mcp_executor),
Arc::clone(&self.environment),
|shell| self.engine.command_runtime.reconfigured(shell),
)
}
pub fn with_executor_hooks(&self, executor_hooks: Vec<ExecutorPluginHookSource>) -> Self {View on GitHub (pinned to 339751715c)