Track parent turns for nested Codex requests (#35835)

## What changed

- Propagate the initiating turn ID through agent spawns, follow-up tasks, reviews, and delegated Codex sessions.
- Add `parent_turn_id` to Responses client and turn metadata while keeping it out of external MCP metadata.
- Preserve parent-turn provenance across queued agent messages when their triggering parent is unambiguous.

## Testing

- Cover spawned, resumed, nested, reviewed, delegated, and WebSocket request metadata.
- Verify queued messages do not claim ambiguous or queue-only parent turns.

GitOrigin-RevId: 481fdebbe7df2031880fe259509273cce50b20a8
This commit is contained in:
Eddie Chen authored and copyberry committed 2026-07-28 21:58:33 +00:00
1 parent 12b3e88028
commit 1def0a8925
34 files changed
+635 -165

No files matched your search

+8 -2
View File
@@ -527,8 +527,13 @@ impl AgentControl {
match initial_input {
SpawnInitialInput::UserInput(input) => {
self.send_input_after_capacity_check(new_thread.thread_id, &state, input)
.await?;
self.send_input_after_capacity_check(
new_thread.thread_id,
&state,
input,
options.parent_turn_id,
)
.await?;
}
SpawnInitialInput::InterAgentCommunication(communication, context) => {
self.send_inter_agent_communication_after_capacity_check(
@@ -536,6 +541,7 @@ impl AgentControl {
&state,
communication,
context,
options.parent_turn_id,
)
.await?;
}