Reject sessions with unloadable required managed hooks (#38394)

## Why

Hooks supplied as managed requirements must not be silently skipped when their
handlers cannot be loaded.

## What changed

- Fail session and app-server thread startup when an enabled managed requirement
  contains an invalid matcher, an empty command, or an unsupported handler type.
- Keep load failures for ordinary managed configuration hooks as warnings, and do
  not enforce managed hook requirements while the hooks feature is disabled.

## Testing

Added hook-engine, core session, and app-server coverage for valid and invalid
managed hook requirements.

GitOrigin-RevId: 91a23b0c1d85e143aba6aabe874c5274e52fc6b2
This commit is contained in:
viyatb-oai
2026-08-13 15:23:09 +00:00
committed by copyberry
parent 683716cee9
commit ef596c68ca
9 changed files with 440 additions and 40 deletions
+1 -1
View File
@@ -1162,7 +1162,7 @@ impl Session {
resolved_environments.single_local_environment(),
)
.await;
let (hooks, async_hook_results) = Hooks::new(hooks_config, thread_id);
let (hooks, async_hook_results) = Hooks::new(hooks_config, thread_id)?;
for warning in hooks.startup_warnings() {
post_session_configured_events.push(Event {
id: INITIAL_SUBMIT_ID.to_owned(),
+6 -3
View File
@@ -782,7 +782,8 @@ async fn preview_session_start_hooks(
..HooksConfig::default()
},
thread_id,
);
)
.expect("initialize hooks for session-start preview");
Ok(
hooks.preview_session_start(&codex_hooks::SessionStartRequest {
@@ -5840,7 +5841,8 @@ pub(crate) async fn make_session_and_context() -> (Session, TurnContext) {
..HooksConfig::default()
},
thread_id,
);
)
.expect("initialize test hooks");
let services = SessionServices {
mcp_runtime,
mcp_handler_cache: Default::default(),
@@ -8023,7 +8025,8 @@ where
..HooksConfig::default()
},
thread_id,
);
)
.expect("initialize test hooks");
let services = SessionServices {
mcp_runtime,
mcp_handler_cache: Default::default(),