mirror of
https://github.com/openai/codex.git
synced 2026-11-02 19:43:24 +00:00
Prevent V2 agent eviction from racing with queued messages (#47240)
## Why Accepted inter-agent messages can still be waiting in the submission queue when a worker appears idle. Evicting that worker can lose the queued work, while cancelling an eviction caller can leave shutdown unfinished and allow delivery to a closing runtime. ## What changed - Pin V2 recipients until queued submissions are handled or dropped, and verify that delivery targets the registered runtime. - Move `Submission` into core so it can carry the residency guard through queue handoffs. - Give eviction exclusive access to each runtime and keep it counted against capacity until removal. Run teardown in a separate task so it completes even if its caller is cancelled, and remove registry and residency entries together. ## Testing Add a regression test covering queued follow-up delivery, eviction refusal while mail is pending, cancelled eviction completing teardown, rejection of late delivery, and capacity reuse after removal. GitOrigin-RevId: d6de3d68cb6b911942e9ddfc05c65b3741b796b2
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::session::Submission;
|
||||
use async_channel::Receiver;
|
||||
use async_channel::Sender;
|
||||
use codex_async_utils::OrCancelExt;
|
||||
@@ -9,7 +10,6 @@ use codex_protocol::protocol::EventMsg;
|
||||
use codex_protocol::protocol::Op;
|
||||
use codex_protocol::protocol::SessionSource;
|
||||
use codex_protocol::protocol::SubAgentSource;
|
||||
use codex_protocol::protocol::Submission;
|
||||
use codex_protocol::protocol::ThreadSource;
|
||||
use codex_protocol::user_input::UserInput;
|
||||
use serde_json::Value;
|
||||
@@ -260,6 +260,7 @@ pub(crate) async fn run_codex_thread_one_shot(
|
||||
trace: None,
|
||||
parent_turn_id: None,
|
||||
root_turn_id: None,
|
||||
residency_guard: None,
|
||||
})
|
||||
.await;
|
||||
child_cancel.cancel();
|
||||
|
||||
Reference in New Issue
Block a user