mirror of
https://github.com/openai/codex.git
synced 2026-11-20 22:40:37 +00:00
Run allowlisted executor plugin stop hooks (#40009)
## What changed - Discover inline hooks from executor-provided plugin manifests and accept only the bundled Computer Use `Stop` hook for `node_repl.turn_ended`. - Add the accepted hook to the current step's hook engine with executor-scoped provenance. - Run executor-scoped hooks in the background after regular stop-hook decisions, without delaying turn completion, applying control effects, or exposing them in hook summaries. Skip them when regular hooks only block continuation. ## Testing - Added coverage for manifest filtering and option preservation. - Added coverage for background execution, interaction with regular stop hooks, and non-blocking turn completion. GitOrigin-RevId: c0f75f83a23ba8a83bb3a5d5997c4882aacc32d6
This commit is contained in:
committed by
copyberry
parent
e77c2a90af
commit
8b61c50ebe
@@ -2,6 +2,7 @@ use std::collections::HashMap;
|
||||
#[cfg(not(windows))]
|
||||
use std::ffi::OsStr;
|
||||
use std::ffi::OsString;
|
||||
use std::future::Future;
|
||||
use std::io::ErrorKind;
|
||||
use std::path::Path;
|
||||
use std::process::Stdio;
|
||||
@@ -111,19 +112,13 @@ impl CommandHookRuntime {
|
||||
turn_id: Option<String>,
|
||||
parse: fn(&ConfiguredHandler, HandlerRunResult, Option<String>) -> ParsedHandler<T>,
|
||||
) {
|
||||
let mut state = self.lock_state();
|
||||
if self.result_sender.is_closed() || state.concurrency_limit.is_closed() {
|
||||
if self.result_sender.is_closed() {
|
||||
return;
|
||||
}
|
||||
|
||||
while state.tasks.try_join_next().is_some() {}
|
||||
let result_sender = self.result_sender.clone();
|
||||
let concurrency_limit = Arc::clone(&state.concurrency_limit);
|
||||
let runtime = self.clone();
|
||||
state.tasks.spawn(async move {
|
||||
let Ok(_permit) = concurrency_limit.acquire_owned().await else {
|
||||
return;
|
||||
};
|
||||
self.schedule_async_task(async move {
|
||||
let result = match &handler.kind {
|
||||
ConfiguredHandlerKind::Command { command, env, .. } => {
|
||||
run_command(&runtime, &handler, command, env, &input_json, &cwd).await
|
||||
@@ -165,6 +160,22 @@ impl CommandHookRuntime {
|
||||
});
|
||||
}
|
||||
|
||||
pub(crate) fn schedule_async_task(&self, task: impl Future<Output = ()> + Send + 'static) {
|
||||
let mut state = self.lock_state();
|
||||
if state.concurrency_limit.is_closed() {
|
||||
return;
|
||||
}
|
||||
|
||||
while state.tasks.try_join_next().is_some() {}
|
||||
let concurrency_limit = Arc::clone(&state.concurrency_limit);
|
||||
state.tasks.spawn(async move {
|
||||
let Ok(_permit) = concurrency_limit.acquire_owned().await else {
|
||||
return;
|
||||
};
|
||||
task.await;
|
||||
});
|
||||
}
|
||||
|
||||
pub(crate) async fn shutdown(&self) {
|
||||
let mut tasks = {
|
||||
let mut state = self.lock_state();
|
||||
|
||||
Reference in New Issue
Block a user