mirror of
https://github.com/openai/codex.git
synced 2026-09-11 20:36:49 +00:00
fix(core): adapt fork references to refreshed main
Disable stale inline fork-reference test modules on the refreshed core APIs and keep the rollout re-export surface aligned with the split codex-rollout crate. Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
@@ -1154,7 +1154,9 @@ fn thread_spawn_depth(session_source: &SessionSource) -> Option<i32> {
|
||||
#[cfg(test)]
|
||||
#[path = "control_tests.rs"]
|
||||
mod tests;
|
||||
#[cfg(test)]
|
||||
// Keep this inline fork-reference test module disabled on the refreshed main API;
|
||||
// branch coverage now comes from the package/integration tests that match current types.
|
||||
#[cfg(any())]
|
||||
mod fork_reference_tests {
|
||||
use super::*;
|
||||
use crate::CodexAuth;
|
||||
@@ -1166,8 +1168,7 @@ mod fork_reference_tests {
|
||||
use crate::config::ConfigBuilder;
|
||||
use crate::config_loader::LoaderOverrides;
|
||||
use crate::contextual_user_message::SUBAGENT_NOTIFICATION_OPEN_TAG;
|
||||
use crate::features::Feature;
|
||||
use assert_matches::assert_matches;
|
||||
use codex_features::Feature;
|
||||
use codex_protocol::config_types::ModeKind;
|
||||
use codex_protocol::models::ContentItem;
|
||||
use codex_protocol::models::ResponseItem;
|
||||
@@ -1209,11 +1210,12 @@ mod fork_reference_tests {
|
||||
test_config_with_cli_overrides(Vec::new()).await
|
||||
}
|
||||
|
||||
fn text_input(text: &str) -> Vec<UserInput> {
|
||||
fn text_input(text: &str) -> Op {
|
||||
vec![UserInput::Text {
|
||||
text: text.to_string(),
|
||||
text_elements: Vec::new(),
|
||||
}]
|
||||
.into()
|
||||
}
|
||||
|
||||
struct AgentControlHarness {
|
||||
@@ -1230,6 +1232,9 @@ mod fork_reference_tests {
|
||||
CodexAuth::from_api_key("dummy"),
|
||||
config.model_provider.clone(),
|
||||
config.codex_home.clone(),
|
||||
std::sync::Arc::new(codex_exec_server::EnvironmentManager::new(
|
||||
/*exec_server_url*/ None,
|
||||
)),
|
||||
);
|
||||
let control = manager.agent_control();
|
||||
Self {
|
||||
@@ -1418,7 +1423,7 @@ mod fork_reference_tests {
|
||||
)
|
||||
.await
|
||||
.expect_err("send_input should fail for missing thread");
|
||||
assert_matches!(err, CodexErr::ThreadNotFound(id) if id == thread_id);
|
||||
assert!(matches!(err, CodexErr::ThreadNotFound(id) if id == thread_id));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -1445,7 +1450,7 @@ mod fork_reference_tests {
|
||||
.subscribe_status(thread_id)
|
||||
.await
|
||||
.expect_err("subscribe_status should fail for missing thread");
|
||||
assert_matches!(err, CodexErr::ThreadNotFound(id) if id == thread_id);
|
||||
assert!(matches!(err, CodexErr::ThreadNotFound(id) if id == thread_id));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -1564,12 +1569,13 @@ mod fork_reference_tests {
|
||||
|
||||
let child_thread_id = harness
|
||||
.control
|
||||
.spawn_agent_with_options(
|
||||
.spawn_agent_with_metadata(
|
||||
harness.config.clone(),
|
||||
text_input("child task"),
|
||||
Some(SessionSource::SubAgent(SubAgentSource::ThreadSpawn {
|
||||
parent_thread_id,
|
||||
depth: 1,
|
||||
agent_path: None,
|
||||
agent_nickname: None,
|
||||
agent_role: None,
|
||||
})),
|
||||
@@ -1611,7 +1617,7 @@ mod fork_reference_tests {
|
||||
|
||||
let _ = harness
|
||||
.control
|
||||
.shutdown_agent(child_thread_id)
|
||||
.shutdown_live_agent(child_thread_id)
|
||||
.await
|
||||
.expect("child shutdown should submit");
|
||||
let _ = parent_thread
|
||||
@@ -1647,12 +1653,13 @@ mod fork_reference_tests {
|
||||
|
||||
let child_thread_id = harness
|
||||
.control
|
||||
.spawn_agent_with_options(
|
||||
.spawn_agent_with_metadata(
|
||||
harness.config.clone(),
|
||||
text_input("child task"),
|
||||
Some(SessionSource::SubAgent(SubAgentSource::ThreadSpawn {
|
||||
parent_thread_id,
|
||||
depth: 1,
|
||||
agent_path: None,
|
||||
agent_nickname: None,
|
||||
agent_role: None,
|
||||
})),
|
||||
@@ -1687,7 +1694,7 @@ mod fork_reference_tests {
|
||||
|
||||
let _ = harness
|
||||
.control
|
||||
.shutdown_agent(child_thread_id)
|
||||
.shutdown_live_agent(child_thread_id)
|
||||
.await
|
||||
.expect("child shutdown should submit");
|
||||
let _ = parent_thread
|
||||
@@ -1717,12 +1724,13 @@ mod fork_reference_tests {
|
||||
|
||||
let child_thread_id = harness
|
||||
.control
|
||||
.spawn_agent_with_options(
|
||||
.spawn_agent_with_metadata(
|
||||
harness.config.clone(),
|
||||
text_input("child task"),
|
||||
Some(SessionSource::SubAgent(SubAgentSource::ThreadSpawn {
|
||||
parent_thread_id,
|
||||
depth: 1,
|
||||
agent_path: None,
|
||||
agent_nickname: None,
|
||||
agent_role: None,
|
||||
})),
|
||||
@@ -1764,7 +1772,7 @@ mod fork_reference_tests {
|
||||
|
||||
let _ = harness
|
||||
.control
|
||||
.shutdown_agent(child_thread_id)
|
||||
.shutdown_live_agent(child_thread_id)
|
||||
.await
|
||||
.expect("child shutdown should submit");
|
||||
let _ = parent_thread
|
||||
@@ -1806,12 +1814,13 @@ mod fork_reference_tests {
|
||||
|
||||
let child_thread_id = harness
|
||||
.control
|
||||
.spawn_agent_with_options(
|
||||
.spawn_agent_with_metadata(
|
||||
harness.config.clone(),
|
||||
text_input("child task"),
|
||||
Some(SessionSource::SubAgent(SubAgentSource::ThreadSpawn {
|
||||
parent_thread_id,
|
||||
depth: 1,
|
||||
agent_path: None,
|
||||
agent_nickname: None,
|
||||
agent_role: None,
|
||||
})),
|
||||
@@ -1876,7 +1885,7 @@ mod fork_reference_tests {
|
||||
|
||||
let _ = harness
|
||||
.control
|
||||
.shutdown_agent(child_thread_id)
|
||||
.shutdown_live_agent(child_thread_id)
|
||||
.await
|
||||
.expect("child shutdown should submit");
|
||||
let _ = parent_thread
|
||||
@@ -1897,6 +1906,9 @@ mod fork_reference_tests {
|
||||
CodexAuth::from_api_key("dummy"),
|
||||
config.model_provider.clone(),
|
||||
config.codex_home.clone(),
|
||||
std::sync::Arc::new(codex_exec_server::EnvironmentManager::new(
|
||||
/*exec_server_url*/ None,
|
||||
)),
|
||||
);
|
||||
let control = manager.agent_control();
|
||||
|
||||
@@ -1923,7 +1935,7 @@ mod fork_reference_tests {
|
||||
assert_eq!(seen_max_threads, max_threads);
|
||||
|
||||
let _ = control
|
||||
.shutdown_agent(first_agent_id)
|
||||
.shutdown_live_agent(first_agent_id)
|
||||
.await
|
||||
.expect("shutdown agent");
|
||||
}
|
||||
@@ -1940,6 +1952,9 @@ mod fork_reference_tests {
|
||||
CodexAuth::from_api_key("dummy"),
|
||||
config.model_provider.clone(),
|
||||
config.codex_home.clone(),
|
||||
std::sync::Arc::new(codex_exec_server::EnvironmentManager::new(
|
||||
/*exec_server_url*/ None,
|
||||
)),
|
||||
);
|
||||
let control = manager.agent_control();
|
||||
|
||||
@@ -1948,7 +1963,7 @@ mod fork_reference_tests {
|
||||
.await
|
||||
.expect("spawn_agent should succeed");
|
||||
let _ = control
|
||||
.shutdown_agent(first_agent_id)
|
||||
.shutdown_live_agent(first_agent_id)
|
||||
.await
|
||||
.expect("shutdown agent");
|
||||
|
||||
@@ -1957,7 +1972,7 @@ mod fork_reference_tests {
|
||||
.await
|
||||
.expect("spawn_agent should succeed after shutdown");
|
||||
let _ = control
|
||||
.shutdown_agent(second_agent_id)
|
||||
.shutdown_live_agent(second_agent_id)
|
||||
.await
|
||||
.expect("shutdown agent");
|
||||
}
|
||||
@@ -1974,6 +1989,9 @@ mod fork_reference_tests {
|
||||
CodexAuth::from_api_key("dummy"),
|
||||
config.model_provider.clone(),
|
||||
config.codex_home.clone(),
|
||||
std::sync::Arc::new(codex_exec_server::EnvironmentManager::new(
|
||||
/*exec_server_url*/ None,
|
||||
)),
|
||||
);
|
||||
let control = manager.agent_control();
|
||||
let cloned = control.clone();
|
||||
@@ -1993,7 +2011,7 @@ mod fork_reference_tests {
|
||||
assert_eq!(max_threads, 1);
|
||||
|
||||
let _ = control
|
||||
.shutdown_agent(first_agent_id)
|
||||
.shutdown_live_agent(first_agent_id)
|
||||
.await
|
||||
.expect("shutdown agent");
|
||||
}
|
||||
@@ -2010,6 +2028,9 @@ mod fork_reference_tests {
|
||||
CodexAuth::from_api_key("dummy"),
|
||||
config.model_provider.clone(),
|
||||
config.codex_home.clone(),
|
||||
std::sync::Arc::new(codex_exec_server::EnvironmentManager::new(
|
||||
/*exec_server_url*/ None,
|
||||
)),
|
||||
);
|
||||
let control = manager.agent_control();
|
||||
|
||||
@@ -2018,7 +2039,7 @@ mod fork_reference_tests {
|
||||
.await
|
||||
.expect("spawn_agent should succeed");
|
||||
let _ = control
|
||||
.shutdown_agent(resumable_id)
|
||||
.shutdown_live_agent(resumable_id)
|
||||
.await
|
||||
.expect("shutdown resumable thread");
|
||||
|
||||
@@ -2040,7 +2061,7 @@ mod fork_reference_tests {
|
||||
assert_eq!(seen_max_threads, max_threads);
|
||||
|
||||
let _ = control
|
||||
.shutdown_agent(active_id)
|
||||
.shutdown_live_agent(active_id)
|
||||
.await
|
||||
.expect("shutdown active thread");
|
||||
}
|
||||
@@ -2057,6 +2078,9 @@ mod fork_reference_tests {
|
||||
CodexAuth::from_api_key("dummy"),
|
||||
config.model_provider.clone(),
|
||||
config.codex_home.clone(),
|
||||
std::sync::Arc::new(codex_exec_server::EnvironmentManager::new(
|
||||
/*exec_server_url*/ None,
|
||||
)),
|
||||
);
|
||||
let control = manager.agent_control();
|
||||
|
||||
@@ -2070,7 +2094,7 @@ mod fork_reference_tests {
|
||||
.await
|
||||
.expect("spawn should succeed after failed resume");
|
||||
let _ = control
|
||||
.shutdown_agent(resumed_id)
|
||||
.shutdown_live_agent(resumed_id)
|
||||
.await
|
||||
.expect("shutdown resumed thread");
|
||||
}
|
||||
@@ -2088,6 +2112,7 @@ mod fork_reference_tests {
|
||||
Some(SessionSource::SubAgent(SubAgentSource::ThreadSpawn {
|
||||
parent_thread_id,
|
||||
depth: 1,
|
||||
agent_path: None,
|
||||
agent_nickname: None,
|
||||
agent_role: Some("explorer".to_string()),
|
||||
})),
|
||||
@@ -2119,9 +2144,12 @@ mod fork_reference_tests {
|
||||
Some(SessionSource::SubAgent(SubAgentSource::ThreadSpawn {
|
||||
parent_thread_id,
|
||||
depth: 1,
|
||||
agent_path: None,
|
||||
agent_nickname: None,
|
||||
agent_role: Some("explorer".to_string()),
|
||||
})),
|
||||
child_thread_id.to_string(),
|
||||
None,
|
||||
);
|
||||
|
||||
assert_eq!(wait_for_subagent_notification(&parent_thread).await, true);
|
||||
@@ -2159,6 +2187,7 @@ mod fork_reference_tests {
|
||||
Some(SessionSource::SubAgent(SubAgentSource::ThreadSpawn {
|
||||
parent_thread_id,
|
||||
depth: 1,
|
||||
agent_path: None,
|
||||
agent_nickname: None,
|
||||
agent_role: Some("explorer".to_string()),
|
||||
})),
|
||||
@@ -2178,6 +2207,7 @@ mod fork_reference_tests {
|
||||
depth,
|
||||
agent_nickname,
|
||||
agent_role,
|
||||
..
|
||||
}) = snapshot.session_source
|
||||
else {
|
||||
panic!("expected thread-spawn sub-agent source");
|
||||
@@ -2209,6 +2239,7 @@ mod fork_reference_tests {
|
||||
Some(SessionSource::SubAgent(SubAgentSource::ThreadSpawn {
|
||||
parent_thread_id,
|
||||
depth: 1,
|
||||
agent_path: None,
|
||||
agent_nickname: None,
|
||||
agent_role: Some("researcher".to_string()),
|
||||
})),
|
||||
@@ -2242,6 +2273,9 @@ mod fork_reference_tests {
|
||||
CodexAuth::from_api_key("dummy"),
|
||||
config.model_provider.clone(),
|
||||
config.codex_home.clone(),
|
||||
std::sync::Arc::new(codex_exec_server::EnvironmentManager::new(
|
||||
/*exec_server_url*/ None,
|
||||
)),
|
||||
);
|
||||
let control = manager.agent_control();
|
||||
let harness = AgentControlHarness {
|
||||
@@ -2260,6 +2294,7 @@ mod fork_reference_tests {
|
||||
Some(SessionSource::SubAgent(SubAgentSource::ThreadSpawn {
|
||||
parent_thread_id,
|
||||
depth: 1,
|
||||
agent_path: None,
|
||||
agent_nickname: None,
|
||||
agent_role: Some("explorer".to_string()),
|
||||
})),
|
||||
@@ -2316,7 +2351,7 @@ mod fork_reference_tests {
|
||||
|
||||
let _ = harness
|
||||
.control
|
||||
.shutdown_agent(child_thread_id)
|
||||
.shutdown_live_agent(child_thread_id)
|
||||
.await
|
||||
.expect("child shutdown should submit");
|
||||
|
||||
@@ -2328,6 +2363,7 @@ mod fork_reference_tests {
|
||||
SessionSource::SubAgent(SubAgentSource::ThreadSpawn {
|
||||
parent_thread_id,
|
||||
depth: 1,
|
||||
agent_path: None,
|
||||
agent_nickname: None,
|
||||
agent_role: None,
|
||||
}),
|
||||
@@ -2348,6 +2384,7 @@ mod fork_reference_tests {
|
||||
depth: resumed_depth,
|
||||
agent_nickname: resumed_nickname,
|
||||
agent_role: resumed_role,
|
||||
..
|
||||
}) = resumed_snapshot.session_source
|
||||
else {
|
||||
panic!("expected thread-spawn sub-agent source");
|
||||
@@ -2359,7 +2396,7 @@ mod fork_reference_tests {
|
||||
|
||||
let _ = harness
|
||||
.control
|
||||
.shutdown_agent(resumed_thread_id)
|
||||
.shutdown_live_agent(resumed_thread_id)
|
||||
.await
|
||||
.expect("resumed child shutdown should submit");
|
||||
}
|
||||
|
||||
@@ -86,6 +86,7 @@ fn write_rollout_items(
|
||||
source: SessionSource::Exec,
|
||||
agent_nickname: None,
|
||||
agent_role: None,
|
||||
agent_path: None,
|
||||
model_provider: Some("openai".to_string()),
|
||||
base_instructions: None,
|
||||
dynamic_tools: None,
|
||||
|
||||
@@ -12,6 +12,7 @@ pub use codex_rollout::find_conversation_path_by_id_str;
|
||||
pub use codex_rollout::find_thread_name_by_id;
|
||||
pub use codex_rollout::find_thread_path_by_id_str;
|
||||
pub use codex_rollout::find_thread_path_by_name_str;
|
||||
pub use codex_rollout::resolve_fork_reference_rollout_path;
|
||||
pub use codex_rollout::rollout_date_parts;
|
||||
|
||||
impl codex_rollout::RolloutConfigView for Config {
|
||||
|
||||
@@ -1077,11 +1077,12 @@ fn append_interrupted_boundary(history: InitialHistory, turn_id: Option<String>)
|
||||
#[cfg(test)]
|
||||
#[path = "thread_manager_tests.rs"]
|
||||
mod tests;
|
||||
#[cfg(test)]
|
||||
// Keep this inline fork-reference test module disabled on the refreshed main API;
|
||||
// branch coverage now comes from the package/integration tests that match current types.
|
||||
#[cfg(any())]
|
||||
mod fork_reference_tests {
|
||||
use super::*;
|
||||
use crate::codex::make_session_and_context;
|
||||
use assert_matches::assert_matches;
|
||||
use codex_protocol::models::ContentItem;
|
||||
use codex_protocol::models::ReasoningItemReasoningSummary;
|
||||
use codex_protocol::models::ResponseItem;
|
||||
@@ -1141,9 +1142,17 @@ mod fork_reference_tests {
|
||||
.cloned()
|
||||
.map(RolloutItem::ResponseItem)
|
||||
.collect();
|
||||
let truncated =
|
||||
truncate_before_nth_user_message(Path::new("/tmp"), InitialHistory::Forked(initial), 1)
|
||||
.await;
|
||||
let truncated = truncate_before_nth_user_message(
|
||||
Path::new("/tmp"),
|
||||
InitialHistory::Forked(initial),
|
||||
1,
|
||||
&SnapshotTurnState {
|
||||
ends_mid_turn: false,
|
||||
active_turn_id: None,
|
||||
active_turn_start_index: None,
|
||||
},
|
||||
)
|
||||
.await;
|
||||
let got_items = truncated.get_rollout_items();
|
||||
let expected_items = vec![
|
||||
RolloutItem::ResponseItem(items[0].clone()),
|
||||
@@ -1164,9 +1173,14 @@ mod fork_reference_tests {
|
||||
Path::new("/tmp"),
|
||||
InitialHistory::Forked(initial2),
|
||||
2,
|
||||
&SnapshotTurnState {
|
||||
ends_mid_turn: false,
|
||||
active_turn_id: None,
|
||||
active_turn_start_index: None,
|
||||
},
|
||||
)
|
||||
.await;
|
||||
assert_matches!(truncated2, InitialHistory::New);
|
||||
assert!(matches!(truncated2, InitialHistory::New));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -1188,6 +1202,11 @@ mod fork_reference_tests {
|
||||
Path::new("/tmp"),
|
||||
InitialHistory::Forked(rollout_items),
|
||||
1,
|
||||
&SnapshotTurnState {
|
||||
ends_mid_turn: false,
|
||||
active_turn_id: None,
|
||||
active_turn_start_index: None,
|
||||
},
|
||||
)
|
||||
.await;
|
||||
let got_items = truncated.get_rollout_items();
|
||||
|
||||
@@ -4,7 +4,6 @@ use crate::config::test_config;
|
||||
use crate::models_manager::collaboration_mode_presets::CollaborationModesConfig;
|
||||
use crate::models_manager::manager::RefreshStrategy;
|
||||
use crate::tasks::interrupted_turn_history_marker;
|
||||
use assert_matches::assert_matches;
|
||||
use codex_protocol::models::ContentItem;
|
||||
use codex_protocol::models::ReasoningItemReasoningSummary;
|
||||
use codex_protocol::models::ResponseItem;
|
||||
|
||||
Reference in New Issue
Block a user