mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:50:52 +00:00
Avoid starting dormant REPL servers for cleanup hooks (#61437)
## Why Bundled `turn_ended` hooks can start an unused REPL server solely to clean it up, even though its deferred startup means there is no process to clean up. ## What changed Allow bundled cleanup calls for `node_repl` and `cua_repl` to return an empty successful result when startup has never been requested. Limit this behavior to configured, unshared local stdio connections using the legacy MCP protocol. Other calls continue to wait for server startup. ## Testing Add coverage for the connection eligibility checks and extend subagent hook tests to verify that bundled cleanup leaves unused REPL servers dormant while ordinary hooks can still start cached tools hidden from the model. GitOrigin-RevId: 0a07772fccd670c53348ff7a702b4bee353e263c
This commit is contained in:
@@ -6,6 +6,7 @@ use codex_hooks::HookMcpCall;
|
||||
use codex_hooks::HookMcpExecutor;
|
||||
use codex_hooks::HookMcpOutput;
|
||||
use codex_mcp::McpRuntime;
|
||||
use codex_mcp::McpToolStartup;
|
||||
use codex_protocol::ThreadId;
|
||||
use futures::FutureExt;
|
||||
use futures::future::BoxFuture;
|
||||
@@ -35,7 +36,11 @@ impl HookMcpExecutor for CoreHookMcpExecutor {
|
||||
Some(Value::Object(call.input)),
|
||||
Some(Value::Object(metadata)),
|
||||
Some(call.timeout),
|
||||
/*wait_for_server*/ true,
|
||||
if call.skip_dormant_repl_cleanup {
|
||||
McpToolStartup::SkipDormantReplCleanup
|
||||
} else {
|
||||
McpToolStartup::Wait
|
||||
},
|
||||
),
|
||||
)
|
||||
.await
|
||||
|
||||
@@ -98,6 +98,7 @@ use codex_mcp::McpResourceClient;
|
||||
use codex_mcp::McpRuntime;
|
||||
use codex_mcp::McpRuntimeContext;
|
||||
use codex_mcp::McpRuntimeInput;
|
||||
use codex_mcp::McpToolStartup;
|
||||
use codex_models_manager::manager::ModelsManager;
|
||||
use codex_models_manager::manager::RefreshStrategy;
|
||||
use codex_models_manager::manager::SharedModelsManager;
|
||||
@@ -5205,7 +5206,7 @@ impl Session {
|
||||
"threadId": self.thread_id().to_string(),
|
||||
})),
|
||||
/*requested_timeout*/ None,
|
||||
/*wait_for_server*/ true,
|
||||
McpToolStartup::Wait,
|
||||
)
|
||||
.await
|
||||
.ok()
|
||||
|
||||
Reference in New Issue
Block a user