mirror of
https://github.com/openai/codex.git
synced 2026-11-18 23:02:23 +00:00
Add hooks for interrupted turns (#40511)
## What changed - Add an `Interrupt` hook event that runs for an active top-level turn before its interrupted abort event is emitted. - Flush the turn transcript before invoking the hook and provide the session, turn, transcript, working directory, model, and permission mode in its input. - Support command and MCP handlers, including asynchronous commands, with a one-second default timeout and a three-second maximum. - Expose the event through hook configuration, managed requirements, app-server notifications, generated schemas, analytics, and the TUI hook views. ## Testing - Cover handler discovery, timeout normalization, output parsing, protocol compatibility, TUI rendering, and interrupt execution ordering. GitOrigin-RevId: 163fa7c098d94ac2775f6d137f8e916f8ea9b6eb
This commit is contained in:
1 parent
9b2ef38f54
commit
cbfd999db7
49 files changed
+1393
-48
No files matched your search
@@ -1670,6 +1670,16 @@ pub(super) async fn assert_hook_events_snapshot(
|
||||
"hook start should render in the live hook cell"
|
||||
);
|
||||
|
||||
let mut entries = vec![codex_app_server_protocol::HookOutputEntry {
|
||||
kind: codex_app_server_protocol::HookOutputEntryKind::Warning,
|
||||
text: "Heads up from the hook".to_string(),
|
||||
}];
|
||||
if event_name != codex_app_server_protocol::HookEventName::Interrupt {
|
||||
entries.push(codex_app_server_protocol::HookOutputEntry {
|
||||
kind: codex_app_server_protocol::HookOutputEntryKind::Context,
|
||||
text: "Remember the startup checklist.".to_string(),
|
||||
});
|
||||
}
|
||||
handle_hook_completed(
|
||||
&mut chat,
|
||||
hook_run(
|
||||
@@ -1677,16 +1687,7 @@ pub(super) async fn assert_hook_events_snapshot(
|
||||
event_name,
|
||||
codex_app_server_protocol::HookRunStatus::Completed,
|
||||
status_message,
|
||||
vec![
|
||||
codex_app_server_protocol::HookOutputEntry {
|
||||
kind: codex_app_server_protocol::HookOutputEntryKind::Warning,
|
||||
text: "Heads up from the hook".to_string(),
|
||||
},
|
||||
codex_app_server_protocol::HookOutputEntry {
|
||||
kind: codex_app_server_protocol::HookOutputEntryKind::Context,
|
||||
text: "Remember the startup checklist.".to_string(),
|
||||
},
|
||||
],
|
||||
entries,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1711,5 +1712,6 @@ fn hook_event_label(event_name: codex_app_server_protocol::HookEventName) -> &'s
|
||||
codex_app_server_protocol::HookEventName::SubagentStart => "SubagentStart",
|
||||
codex_app_server_protocol::HookEventName::SubagentStop => "SubagentStop",
|
||||
codex_app_server_protocol::HookEventName::Stop => "Stop",
|
||||
codex_app_server_protocol::HookEventName::Interrupt => "Interrupt",
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user