mirror of
https://github.com/openai/codex.git
synced 2026-11-09 08:40:33 +00:00
Track root turns across delegated Codex requests (#38232)
## Why `parent_turn_id` identifies the immediate caller of a nested request, but not the top-level turn that initiated a multi-level chain of work. ## What changed - Add `root_turn_id` to turn state, submissions, and Responses API metadata. - Propagate the root through spawned agents, delegated work, review sessions, and turn-triggering inter-agent messages. - Omit the root when background work has no user turn or combined input makes the root ambiguous. ## Testing Added coverage for nested agent resumes, reviews, mailbox delivery, steered input, and reserved metadata handling. GitOrigin-RevId: 60057db2ee81f4efefa946a9f63c74ff98b93929
This commit is contained in:
1 parent
9df9ff6ad9
commit
1f4ea79853
38 files changed
+470
-65
No files matched your search
@@ -317,12 +317,23 @@ impl Session {
|
||||
.await
|
||||
.clear_turn(&turn_context.sub_id);
|
||||
|
||||
let (pending_items, parent_turn_id) =
|
||||
let (pending_items, parent_turn_id, root_turn_id) =
|
||||
self.input_queue.get_pending_input(&self.active_turn).await;
|
||||
if let (MailboxParentProvenance::Attribute, Some(id)) =
|
||||
(mailbox_parent_provenance, parent_turn_id)
|
||||
if let MailboxParentProvenance::Attribute = mailbox_parent_provenance {
|
||||
if let Some(id) = parent_turn_id {
|
||||
turn_context.turn_metadata_state.set_parent_turn_id(id);
|
||||
}
|
||||
if let Some(id) = root_turn_id {
|
||||
turn_context.turn_metadata_state.set_root_turn_id(id);
|
||||
}
|
||||
} else if pending_items.iter().any(|item| {
|
||||
matches!(
|
||||
item,
|
||||
TurnInput::InterAgentCommunication(communication) if communication.trigger_turn
|
||||
)
|
||||
}) && turn_context.turn_metadata_state.root_turn_id() != root_turn_id
|
||||
{
|
||||
turn_context.turn_metadata_state.set_parent_turn_id(id);
|
||||
turn_context.turn_metadata_state.mark_root_turn_ambiguous();
|
||||
}
|
||||
let turn_state = {
|
||||
let mut active = self.active_turn.lock().await;
|
||||
|
||||
Reference in new issue
Block a user