mirror of
https://github.com/openai/codex.git
synced 2026-11-25 23:30:49 +00:00
Expose and persist turn lineage across the app server (#51415)
## Why Clients starting delegated work need to attribute descendant turns to the original turn and retain that attribution through completion and history reads. ## What changed - Accept optional `parentTurnId` and `rootTurnId` in `turn/start`, and expose `rootTurnId` on returned turns and lifecycle notifications. - Default new turns to their own root when none is supplied. Preserve the active turn's root when steering, ignoring incoming lineage fields. - Carry root IDs through completion, interruption, recovery, and fork boundaries, and persist them for paginated history reads. Leave unknown roots null in older history. - Update protocol schemas and generated TypeScript and Python bindings. ## Testing Extend coverage for default and explicit roots, steering without changing lineage, interrupted and recovered turns, history reads after restart in both history modes, nested fork pagination, and compatibility with older database writers. GitOrigin-RevId: f1a570a12bd11742929fd2e8b017e5d35aa07dcb
This commit is contained in:
@@ -162,6 +162,7 @@ pub(crate) async fn apply_bespoke_event_handling(
|
||||
let state = thread_state.lock().await;
|
||||
let mut turn = state.active_turn_snapshot().unwrap_or_else(|| Turn {
|
||||
id: payload.turn_id.clone(),
|
||||
root_turn_id: payload.root_turn_id.clone(),
|
||||
items: Vec::new(),
|
||||
items_view: TurnItemsView::NotLoaded,
|
||||
error: None,
|
||||
@@ -1311,6 +1312,7 @@ async fn handle_turn_plan_update(
|
||||
|
||||
struct TurnCompletionMetadata {
|
||||
status: TurnStatus,
|
||||
root_turn_id: Option<String>,
|
||||
error: Option<TurnError>,
|
||||
last_agent_message: Option<ThreadItem>,
|
||||
started_at: Option<i64>,
|
||||
@@ -1332,6 +1334,7 @@ async fn emit_turn_completed_with_status(
|
||||
thread_id: conversation_id.to_string(),
|
||||
turn: Turn {
|
||||
id: event_turn_id,
|
||||
root_turn_id: turn_completion_metadata.root_turn_id,
|
||||
items,
|
||||
items_view,
|
||||
error: turn_completion_metadata.error,
|
||||
@@ -1519,6 +1522,7 @@ async fn handle_turn_complete(
|
||||
event_turn_id,
|
||||
TurnCompletionMetadata {
|
||||
status,
|
||||
root_turn_id: turn_complete_event.root_turn_id,
|
||||
error,
|
||||
last_agent_message,
|
||||
started_at: turn_summary.started_at,
|
||||
@@ -1544,6 +1548,7 @@ async fn handle_turn_interrupted(
|
||||
event_turn_id,
|
||||
TurnCompletionMetadata {
|
||||
status: TurnStatus::Interrupted,
|
||||
root_turn_id: turn_aborted_event.root_turn_id,
|
||||
error: turn_aborted_event.error.map(|error| TurnError {
|
||||
message: error.message,
|
||||
codex_error_info: error.codex_error_info.map(Into::into),
|
||||
@@ -2179,6 +2184,7 @@ mod tests {
|
||||
|
||||
fn turn_complete_event(turn_id: &str) -> TurnCompleteEvent {
|
||||
TurnCompleteEvent {
|
||||
root_turn_id: None,
|
||||
turn_id: turn_id.to_string(),
|
||||
started_at: None,
|
||||
last_agent_message: None,
|
||||
@@ -2191,6 +2197,7 @@ mod tests {
|
||||
|
||||
fn turn_aborted_event(turn_id: &str) -> TurnAbortedEvent {
|
||||
TurnAbortedEvent {
|
||||
root_turn_id: None,
|
||||
turn_id: Some(turn_id.to_string()),
|
||||
started_at: None,
|
||||
reason: codex_protocol::protocol::TurnAbortReason::Interrupted,
|
||||
@@ -3513,7 +3520,10 @@ mod tests {
|
||||
handle_turn_interrupted(
|
||||
conversation_id,
|
||||
event_turn_id.clone(),
|
||||
turn_aborted_event(&event_turn_id),
|
||||
TurnAbortedEvent {
|
||||
root_turn_id: Some("root-a".to_string()),
|
||||
..turn_aborted_event(&event_turn_id)
|
||||
},
|
||||
&outgoing,
|
||||
&thread_state,
|
||||
)
|
||||
@@ -3523,6 +3533,7 @@ mod tests {
|
||||
match msg {
|
||||
ServerNotification::TurnCompleted(n) => {
|
||||
assert_eq!(n.turn.id, event_turn_id);
|
||||
assert_eq!(n.turn.root_turn_id.as_deref(), Some("root-a"));
|
||||
assert_eq!(n.turn.status, TurnStatus::Interrupted);
|
||||
assert_eq!(n.turn.error, None);
|
||||
assert_eq!(n.turn.completed_at, Some(TEST_TURN_COMPLETED_AT));
|
||||
|
||||
@@ -1033,6 +1033,7 @@ mod tests {
|
||||
thread_id: "thread-1".to_string(),
|
||||
turn: Turn {
|
||||
id: "turn-1".to_string(),
|
||||
root_turn_id: None,
|
||||
items: Vec::new(),
|
||||
items_view: TurnItemsView::NotLoaded,
|
||||
status: TurnStatus::Completed,
|
||||
|
||||
@@ -684,6 +684,8 @@ async fn turn_start_jsonrpc_span_parents_core_turn_spans() -> Result<()> {
|
||||
text_elements: Vec::new(),
|
||||
}],
|
||||
turn_trigger: None,
|
||||
parent_turn_id: None,
|
||||
root_turn_id: None,
|
||||
tool_output: None,
|
||||
responsesapi_client_metadata: None,
|
||||
additional_context: None,
|
||||
|
||||
@@ -103,6 +103,7 @@ impl ThreadRequestProcessor {
|
||||
if let Err(err) = thread
|
||||
.append_rollout_items(&[RolloutItem::EventMsg(EventMsg::TurnAborted(
|
||||
TurnAbortedEvent {
|
||||
root_turn_id: None,
|
||||
turn_id: Some(saved.turn_id.clone()),
|
||||
reason: TurnAbortReason::Interrupted,
|
||||
error: None,
|
||||
|
||||
@@ -5901,6 +5901,7 @@ fn stored_turn_to_api_turn(
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
Ok(Turn {
|
||||
id: turn.turn_id,
|
||||
root_turn_id: turn.root_turn_id,
|
||||
items,
|
||||
items_view,
|
||||
status,
|
||||
|
||||
@@ -291,6 +291,7 @@ mod thread_processor_behavior_tests {
|
||||
))];
|
||||
let active_turn = Turn {
|
||||
id: "live-turn".to_string(),
|
||||
root_turn_id: None,
|
||||
items: vec![ThreadItem::UserMessage {
|
||||
id: "live-user-message".to_string(),
|
||||
client_id: None,
|
||||
|
||||
@@ -205,8 +205,11 @@ impl ThreadQueueRequestProcessor {
|
||||
)
|
||||
.await
|
||||
.map_err(queue_error)?;
|
||||
let turn_id = match submission {
|
||||
StartIfIdleSubmission::Started { turn_id } => turn_id,
|
||||
let (turn_id, root_turn_id) = match submission {
|
||||
StartIfIdleSubmission::Started {
|
||||
turn_id,
|
||||
root_turn_id,
|
||||
} => (turn_id, root_turn_id),
|
||||
StartIfIdleSubmission::NotSubmitted {
|
||||
reason: NotSubmittedReason::ServerDraining,
|
||||
} => return Err(crate::error_code::server_draining_error()),
|
||||
@@ -229,6 +232,7 @@ impl ThreadQueueRequestProcessor {
|
||||
Ok(ThreadQueueStartResponse {
|
||||
turn: Turn {
|
||||
id: turn_id,
|
||||
root_turn_id: Some(root_turn_id),
|
||||
items: vec![],
|
||||
items_view: TurnItemsView::NotLoaded,
|
||||
error: None,
|
||||
|
||||
@@ -236,6 +236,7 @@ mod tests {
|
||||
name: None,
|
||||
turns: vec![Turn {
|
||||
id: "turn-1".to_string(),
|
||||
root_turn_id: None,
|
||||
items,
|
||||
items_view: TurnItemsView::Full,
|
||||
status: TurnStatus::Completed,
|
||||
|
||||
@@ -654,10 +654,12 @@ impl TurnRequestProcessor {
|
||||
.with_thread_settings(thread_settings)
|
||||
.on_start(TurnStartOptions {
|
||||
turn_trigger: params.turn_trigger,
|
||||
parent_turn_id: params.parent_turn_id,
|
||||
initiating_agent_path: None,
|
||||
root_turn_id: params.root_turn_id,
|
||||
final_output_json_schema: params.output_schema,
|
||||
service_tier: params.service_tier_for_turn,
|
||||
cyber_access_program: params.cyber_access_program.map(Into::into),
|
||||
..Default::default()
|
||||
})
|
||||
.with_additional_context(additional_context)
|
||||
.with_responses_metadata(params.responsesapi_client_metadata)
|
||||
@@ -669,9 +671,15 @@ impl TurnRequestProcessor {
|
||||
self.track_error_response(&request_id, &error, /*error_type*/ None);
|
||||
error
|
||||
})?;
|
||||
let (turn_id, started) = match submission {
|
||||
TurnInputSubmission::Started { turn_id } => (turn_id, true),
|
||||
TurnInputSubmission::Steered { turn_id } => (turn_id, false),
|
||||
let (turn_id, root_turn_id, started) = match submission {
|
||||
TurnInputSubmission::Started {
|
||||
turn_id,
|
||||
root_turn_id,
|
||||
} => (turn_id, root_turn_id, true),
|
||||
TurnInputSubmission::Steered {
|
||||
turn_id,
|
||||
root_turn_id,
|
||||
} => (turn_id, root_turn_id, false),
|
||||
TurnInputSubmission::NotSubmitted { reason } => {
|
||||
let error = if reason == NotSubmittedReason::ServerDraining {
|
||||
crate::error_code::server_draining_error()
|
||||
@@ -703,6 +711,7 @@ impl TurnRequestProcessor {
|
||||
.await;
|
||||
let turn = Turn {
|
||||
id: turn_id,
|
||||
root_turn_id: Some(root_turn_id),
|
||||
items: vec![],
|
||||
items_view: TurnItemsView::NotLoaded,
|
||||
error: None,
|
||||
@@ -1409,6 +1418,7 @@ impl TurnRequestProcessor {
|
||||
|
||||
Turn {
|
||||
id: turn_id,
|
||||
root_turn_id: None,
|
||||
items,
|
||||
items_view: TurnItemsView::NotLoaded,
|
||||
error: None,
|
||||
|
||||
@@ -1534,6 +1534,7 @@ async fn thread_fork_creates_reference_backed_paginated_thread() -> Result<()> {
|
||||
collaboration_mode_kind: Default::default(),
|
||||
})),
|
||||
RolloutItem::EventMsg(EventMsg::TurnComplete(TurnCompleteEvent {
|
||||
root_turn_id: None,
|
||||
turn_id: "turn-1".to_string(),
|
||||
last_agent_message: None,
|
||||
error: None,
|
||||
@@ -1858,7 +1859,7 @@ async fn assert_thread_fork_freezes_active_paginated_turn_as_interrupted(
|
||||
&RolloutItem::EventMsg(EventMsg::TurnStarted(TurnStartedEvent {
|
||||
turn_attribution: None,
|
||||
turn_id: "active-turn".to_string(),
|
||||
root_turn_id: None,
|
||||
root_turn_id: Some("causal-root".to_string()),
|
||||
trace_id: None,
|
||||
started_at: Some(10),
|
||||
model_context_window: None,
|
||||
@@ -1967,6 +1968,7 @@ async fn assert_thread_fork_freezes_active_paginated_turn_as_interrupted(
|
||||
append_rollout_item_to_path(
|
||||
source_path.as_path(),
|
||||
&RolloutItem::EventMsg(EventMsg::TurnComplete(TurnCompleteEvent {
|
||||
root_turn_id: None,
|
||||
turn_id: "active-turn".to_string(),
|
||||
last_agent_message: None,
|
||||
error: None,
|
||||
@@ -2034,6 +2036,7 @@ async fn assert_thread_fork_freezes_active_paginated_turn_as_interrupted(
|
||||
.await?;
|
||||
assert_eq!(turns.len(), 1);
|
||||
assert_eq!(turns[0].id, "active-turn");
|
||||
assert_eq!(turns[0].root_turn_id.as_deref(), Some("causal-root"));
|
||||
assert_eq!(turns[0].status, TurnStatus::Interrupted);
|
||||
assert_eq!(turns[0].items.len(), 1);
|
||||
assert!(matches!(
|
||||
|
||||
@@ -815,6 +815,10 @@ async fn queue_start_without_id_starts_the_head_when_idle() -> Result<()> {
|
||||
.await?;
|
||||
let started: ThreadQueueStartResponse =
|
||||
timeout(READ_TIMEOUT, app.read_response(start_request_id)).await??;
|
||||
assert_eq!(
|
||||
started.turn.root_turn_id.as_deref(),
|
||||
Some(started.turn.id.as_str())
|
||||
);
|
||||
let started_item = loop {
|
||||
let started_item: ItemStartedNotification =
|
||||
timeout(READ_TIMEOUT, app.read_notification("item/started")).await??;
|
||||
|
||||
@@ -215,6 +215,7 @@ async fn thread_read_can_include_turns() -> Result<()> {
|
||||
assert_eq!(thread.turns.len(), 1);
|
||||
let turn = &thread.turns[0];
|
||||
assert_eq!(turn.status, TurnStatus::Completed);
|
||||
assert_eq!(turn.root_turn_id, None);
|
||||
assert_eq!(turn.items_view, TurnItemsView::Full);
|
||||
assert_eq!(turn.items.len(), 1, "expected user message item");
|
||||
match &turn.items[0] {
|
||||
@@ -238,9 +239,13 @@ async fn thread_read_can_include_turns() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Preserves a file-backed image across a completed turn, including a cold history read.
|
||||
/// Preserves a file-backed image and causal root across completion and a cold history read.
|
||||
#[test_case::test_case(ThreadHistoryMode::Legacy; "legacy")]
|
||||
#[test_case::test_case(ThreadHistoryMode::Paginated; "paginated")]
|
||||
#[tokio::test]
|
||||
async fn thread_read_preserves_file_id_from_completed_turn() -> Result<()> {
|
||||
async fn thread_read_preserves_file_id_and_root_from_completed_turn(
|
||||
history_mode: ThreadHistoryMode,
|
||||
) -> Result<()> {
|
||||
let server = create_mock_responses_server_repeating_assistant("Done").await;
|
||||
let codex_home = TempDir::new()?;
|
||||
MockResponsesConfig::new(&server.uri()).write(codex_home.path())?;
|
||||
@@ -252,6 +257,7 @@ async fn thread_read_preserves_file_id_from_completed_turn() -> Result<()> {
|
||||
let start_id = mcp
|
||||
.send_thread_start_request_with_auto_env(ThreadStartParams {
|
||||
model: Some("mock-model".to_string()),
|
||||
history_mode: Some(history_mode),
|
||||
..Default::default()
|
||||
})
|
||||
.await?;
|
||||
@@ -264,15 +270,18 @@ async fn thread_read_preserves_file_id_from_completed_turn() -> Result<()> {
|
||||
detail: None,
|
||||
};
|
||||
|
||||
timeout(
|
||||
let completed = timeout(
|
||||
DEFAULT_READ_TIMEOUT,
|
||||
mcp.start_turn_and_wait_for_completion(TurnStartParams {
|
||||
thread_id: thread.id.clone(),
|
||||
input: vec![image.clone()],
|
||||
root_turn_id: Some("causal-root".to_string()),
|
||||
..Default::default()
|
||||
}),
|
||||
)
|
||||
.await??;
|
||||
let expected_root = "causal-root";
|
||||
assert_eq!(completed.turn.root_turn_id.as_deref(), Some(expected_root));
|
||||
|
||||
let read_id = mcp
|
||||
.send_thread_read_request(ThreadReadParams {
|
||||
@@ -287,6 +296,10 @@ async fn thread_read_preserves_file_id_from_completed_turn() -> Result<()> {
|
||||
panic!("expected completed turn to start with a user message");
|
||||
};
|
||||
assert_eq!(content, &vec![image.clone()]);
|
||||
assert_eq!(
|
||||
loaded_thread.turns[0].root_turn_id.as_deref(),
|
||||
Some(expected_root)
|
||||
);
|
||||
|
||||
timeout(DEFAULT_READ_TIMEOUT, mcp.shutdown_gracefully()).await??;
|
||||
drop(mcp);
|
||||
@@ -297,7 +310,7 @@ async fn thread_read_preserves_file_id_from_completed_turn() -> Result<()> {
|
||||
.await?;
|
||||
let read_id = mcp
|
||||
.send_thread_read_request(ThreadReadParams {
|
||||
thread_id: thread.id,
|
||||
thread_id: thread.id.clone(),
|
||||
include_turns: true,
|
||||
})
|
||||
.await?;
|
||||
@@ -308,6 +321,24 @@ async fn thread_read_preserves_file_id_from_completed_turn() -> Result<()> {
|
||||
panic!("expected persisted turn to start with a user message");
|
||||
};
|
||||
assert_eq!(content, &vec![image]);
|
||||
assert_eq!(
|
||||
restarted_thread.turns[0].root_turn_id.as_deref(),
|
||||
Some(expected_root)
|
||||
);
|
||||
let page_id = mcp
|
||||
.send_thread_turns_list_request(ThreadTurnsListParams {
|
||||
thread_id: thread.id,
|
||||
cursor: None,
|
||||
limit: Some(1),
|
||||
sort_direction: Some(SortDirection::Asc),
|
||||
items_view: None,
|
||||
})
|
||||
.await?;
|
||||
let page: ThreadTurnsListResponse =
|
||||
timeout(DEFAULT_READ_TIMEOUT, mcp.read_response(page_id)).await??;
|
||||
assert_eq!(page.data.len(), 1);
|
||||
assert_eq!(page.data[0].id, completed.turn.id);
|
||||
assert_eq!(page.data[0].root_turn_id.as_deref(), Some(expected_root));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -1787,6 +1818,7 @@ async fn paginated_history_lists_and_legacy_reads_use_projected_turns_and_items(
|
||||
|
||||
let expected_turn_1_full = Turn {
|
||||
id: "turn-1".to_string(),
|
||||
root_turn_id: None,
|
||||
items: vec![
|
||||
ThreadItem::UserMessage {
|
||||
id: "user-1".to_string(),
|
||||
@@ -1816,6 +1848,7 @@ async fn paginated_history_lists_and_legacy_reads_use_projected_turns_and_items(
|
||||
};
|
||||
let expected_turn_2_full = Turn {
|
||||
id: "turn-2".to_string(),
|
||||
root_turn_id: None,
|
||||
items: vec![ThreadItem::UserMessage {
|
||||
id: "user-2".to_string(),
|
||||
client_id: None,
|
||||
@@ -1979,6 +2012,7 @@ async fn paginated_history_lists_and_legacy_reads_use_projected_turns_and_items(
|
||||
first_page.data,
|
||||
vec![Turn {
|
||||
id: "turn-1".to_string(),
|
||||
root_turn_id: None,
|
||||
items: vec![
|
||||
ThreadItem::UserMessage {
|
||||
id: "user-1".to_string(),
|
||||
@@ -2016,6 +2050,7 @@ async fn paginated_history_lists_and_legacy_reads_use_projected_turns_and_items(
|
||||
second_page.data,
|
||||
vec![Turn {
|
||||
id: "turn-2".to_string(),
|
||||
root_turn_id: None,
|
||||
items: Vec::new(),
|
||||
items_view: TurnItemsView::NotLoaded,
|
||||
status: TurnStatus::Interrupted,
|
||||
@@ -2438,6 +2473,7 @@ fn paginated_turn_started(turn_id: &str) -> RolloutItem {
|
||||
|
||||
fn paginated_turn_completed(turn_id: &str) -> RolloutItem {
|
||||
RolloutItem::EventMsg(EventMsg::TurnComplete(TurnCompleteEvent {
|
||||
root_turn_id: None,
|
||||
turn_id: turn_id.to_string(),
|
||||
last_agent_message: None,
|
||||
error: None,
|
||||
|
||||
@@ -4317,6 +4317,7 @@ async fn thread_resume_token_usage_replay_can_belong_to_interrupted_turn() -> Re
|
||||
"timestamp": meta_rfc3339,
|
||||
"type": "event_msg",
|
||||
"payload": serde_json::to_value(EventMsg::TurnAborted(TurnAbortedEvent {
|
||||
root_turn_id: None,
|
||||
turn_id: Some(interrupted_turn_id.to_string()),
|
||||
started_at: None,
|
||||
reason: TurnAbortReason::Interrupted,
|
||||
|
||||
@@ -129,6 +129,7 @@ async fn timeline_pages_mix_items_and_resolve_the_opening_realtime_session() ->
|
||||
},
|
||||
}),
|
||||
RolloutItem::EventMsg(EventMsg::TurnComplete(TurnCompleteEvent {
|
||||
root_turn_id: None,
|
||||
turn_id: "turn-1".to_string(),
|
||||
last_agent_message: None,
|
||||
error: None,
|
||||
|
||||
@@ -583,11 +583,13 @@ async fn turn_start_with_empty_input_runs_model_request() -> Result<()> {
|
||||
})
|
||||
.await?;
|
||||
assert!(!turn.id.is_empty());
|
||||
assert_eq!(turn.root_turn_id.as_deref(), Some(turn.id.as_str()));
|
||||
|
||||
let started: TurnStartedNotification =
|
||||
timeout(DEFAULT_READ_TIMEOUT, mcp.read_notification("turn/started")).await??;
|
||||
assert_eq!(started.thread_id, thread.id);
|
||||
assert_eq!(started.turn.id, turn.id);
|
||||
assert_eq!(started.turn.root_turn_id.as_deref(), Some(turn.id.as_str()));
|
||||
assert_eq!(started.turn.status, TurnStatus::InProgress);
|
||||
|
||||
let completed: TurnCompletedNotification = timeout(
|
||||
@@ -597,6 +599,10 @@ async fn turn_start_with_empty_input_runs_model_request() -> Result<()> {
|
||||
.await??;
|
||||
assert_eq!(completed.thread_id, thread.id);
|
||||
assert_eq!(completed.turn.id, turn.id);
|
||||
assert_eq!(
|
||||
completed.turn.root_turn_id.as_deref(),
|
||||
Some(turn.id.as_str())
|
||||
);
|
||||
assert_eq!(completed.turn.status, TurnStatus::Completed);
|
||||
assert_eq!(completed.turn.items_view, TurnItemsView::Summary);
|
||||
assert!(matches!(
|
||||
@@ -703,16 +709,17 @@ async fn turn_start_steers_active_turn_and_returns_active_turn_id() -> Result<()
|
||||
text_elements: Vec::new(),
|
||||
}],
|
||||
turn_trigger: Some("goal".to_string()),
|
||||
parent_turn_id: Some("initiating-turn".to_string()),
|
||||
root_turn_id: Some("causal-root".to_string()),
|
||||
cyber_access_program: Some(CyberAccessProgram::DaybreakBlue),
|
||||
..Default::default()
|
||||
},
|
||||
})
|
||||
.await?;
|
||||
timeout(
|
||||
DEFAULT_READ_TIMEOUT,
|
||||
mcp.read_stream_until_notification_message("turn/started"),
|
||||
)
|
||||
.await??;
|
||||
let started: TurnStartedNotification =
|
||||
timeout(DEFAULT_READ_TIMEOUT, mcp.read_notification("turn/started")).await??;
|
||||
assert_eq!(active_turn.root_turn_id.as_deref(), Some("causal-root"));
|
||||
assert_eq!(started.turn.root_turn_id.as_deref(), Some("causal-root"));
|
||||
timeout(
|
||||
DEFAULT_READ_TIMEOUT,
|
||||
server.wait_for_request_count(/*count*/ 1),
|
||||
@@ -746,21 +753,25 @@ async fn turn_start_steers_active_turn_and_returns_active_turn_id() -> Result<()
|
||||
text_elements: Vec::new(),
|
||||
}],
|
||||
turn_trigger: Some("user".to_string()),
|
||||
parent_turn_id: Some("steering-turn".to_string()),
|
||||
root_turn_id: Some("steering-root".to_string()),
|
||||
cyber_access_program: Some(CyberAccessProgram::Standard),
|
||||
..Default::default()
|
||||
},
|
||||
})
|
||||
.await?;
|
||||
assert_eq!(steered_turn.id, active_turn.id);
|
||||
assert_eq!(steered_turn.root_turn_id, active_turn.root_turn_id);
|
||||
|
||||
release_response
|
||||
.send(())
|
||||
.expect("active response gate should remain open");
|
||||
timeout(
|
||||
let completed: TurnCompletedNotification = timeout(
|
||||
DEFAULT_READ_TIMEOUT,
|
||||
mcp.read_stream_until_notification_message("turn/completed"),
|
||||
mcp.read_notification("turn/completed"),
|
||||
)
|
||||
.await??;
|
||||
assert_eq!(completed.turn.root_turn_id.as_deref(), Some("causal-root"));
|
||||
|
||||
let requests = server.requests().await;
|
||||
assert_eq!(requests.len(), 2);
|
||||
@@ -773,6 +784,8 @@ async fn turn_start_steers_active_turn_and_returns_active_turn_id() -> Result<()
|
||||
.context("expected x-codex-turn-metadata")?,
|
||||
)?;
|
||||
assert_eq!(turn_metadata["turn_trigger"].as_str(), Some("goal"));
|
||||
assert_eq!(turn_metadata["parent_turn_id"], "initiating-turn");
|
||||
assert_eq!(turn_metadata["root_turn_id"], "causal-root");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -3389,6 +3402,8 @@ async fn turn_start_explicit_local_environment_updates_legacy_cwd_between_turns(
|
||||
text_elements: Vec::new(),
|
||||
}],
|
||||
turn_trigger: None,
|
||||
parent_turn_id: None,
|
||||
root_turn_id: None,
|
||||
tool_output: None,
|
||||
responsesapi_client_metadata: None,
|
||||
additional_context: None,
|
||||
@@ -3442,6 +3457,8 @@ async fn turn_start_explicit_local_environment_updates_legacy_cwd_between_turns(
|
||||
text_elements: Vec::new(),
|
||||
}],
|
||||
turn_trigger: None,
|
||||
parent_turn_id: None,
|
||||
root_turn_id: None,
|
||||
tool_output: None,
|
||||
responsesapi_client_metadata: None,
|
||||
additional_context: None,
|
||||
|
||||
Reference in New Issue
Block a user