mirror of
https://github.com/openai/codex.git
synced 2026-11-20 22:40:37 +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:
@@ -294,7 +294,9 @@ impl CodexThread {
|
||||
trace: Option<W3cTraceContext>,
|
||||
) -> CodexResult<String> {
|
||||
self.io
|
||||
.submit_with_trace(op, trace, /*parent_turn_id*/ None)
|
||||
.submit_with_trace(
|
||||
op, trace, /*parent_turn_id*/ None, /*root_turn_id*/ None,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
@@ -343,6 +345,7 @@ impl CodexThread {
|
||||
client_user_message_id,
|
||||
trace,
|
||||
parent_turn_id: None,
|
||||
root_turn_id: None,
|
||||
})
|
||||
.await?;
|
||||
tokio::select! {
|
||||
@@ -374,6 +377,7 @@ impl CodexThread {
|
||||
expected_turn_id,
|
||||
client_user_message_id,
|
||||
responsesapi_client_metadata,
|
||||
/*incoming_turn_metadata*/ None,
|
||||
)
|
||||
.await
|
||||
}
|
||||
@@ -483,6 +487,7 @@ impl CodexThread {
|
||||
/// Use sparingly: this is intended to be removed soon.
|
||||
pub async fn submit_with_id(&self, mut sub: Submission) -> CodexResult<()> {
|
||||
sub.parent_turn_id = None;
|
||||
sub.root_turn_id = None;
|
||||
self.io.submit_with_id(sub).await
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user