Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions codex-rs/app-server/src/bespoke_event_handling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2663,7 +2663,9 @@ mod tests {
thread_id: conversation_id,
thread: conversation,
..
} = thread_manager.start_thread(config.clone()).await?;
} = thread_manager
.start_thread(codex_core::StartThreadOptions::new(config.clone()))
.await?;
let thread_state = new_thread_state();
let thread_watch_manager = ThreadWatchManager::new();
let (tx, mut rx) = mpsc::channel(CHANNEL_CAPACITY);
Expand Down Expand Up @@ -3241,7 +3243,9 @@ mod tests {
thread_id: conversation_id,
thread: conversation,
..
} = thread_manager.start_thread(config.clone()).await?;
} = thread_manager
.start_thread(codex_core::StartThreadOptions::new(config.clone()))
.await?;
let thread_state = new_thread_state();
{
let mut state = thread_state.lock().await;
Expand Down Expand Up @@ -3329,7 +3333,9 @@ mod tests {
thread_id: conversation_id,
thread: conversation,
..
} = thread_manager.start_thread(config).await?;
} = thread_manager
.start_thread(codex_core::StartThreadOptions::new(config))
.await?;
let child_thread_id = ThreadId::new();
let child_thread_id_string = child_thread_id.to_string();
let thread_watch_manager = ThreadWatchManager::new();
Expand Down Expand Up @@ -3419,7 +3425,9 @@ mod tests {
thread_id: conversation_id,
thread: conversation,
..
} = thread_manager.start_thread(config).await?;
} = thread_manager
.start_thread(codex_core::StartThreadOptions::new(config))
.await?;
let (tx, mut rx) = mpsc::channel(CHANNEL_CAPACITY);
let outgoing = Arc::new(OutgoingMessageSender::new(
tx,
Expand Down
13 changes: 10 additions & 3 deletions codex-rs/app-server/src/mcp_refresh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,10 @@ mod tests {
Some(temp_dir.path().join("good")),
)
.await?;
let thread = thread_manager.start_thread(thread_config).await?.thread;
let thread = thread_manager
.start_thread(codex_core::StartThreadOptions::new(thread_config))
.await?
.thread;
std::fs::write(
temp_dir.path().join(codex_config::CONFIG_TOML_FILE),
r#"
Expand Down Expand Up @@ -337,8 +340,12 @@ enabled = false
/*external_time_provider*/ None,
)
});
thread_manager.start_thread(good_config).await?;
thread_manager.start_thread(bad_config).await?;
thread_manager
.start_thread(codex_core::StartThreadOptions::new(good_config))
.await?;
thread_manager
.start_thread(codex_core::StartThreadOptions::new(bad_config))
.await?;

let loader = Arc::new(CountingThreadConfigLoader {
good_cwd: AbsolutePathBuf::try_from(good_cwd)?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1228,8 +1228,7 @@ impl ThreadRequestProcessor {
..
} = listener_task_context
.thread_manager
.start_thread_with_options(StartThreadOptions {
config,
.start_thread(StartThreadOptions {
allow_provider_model_fallback,
initial_history: match session_start_source
.unwrap_or(codex_app_server_protocol::ThreadStartSource::Startup)
Expand All @@ -1238,14 +1237,14 @@ impl ThreadRequestProcessor {
codex_app_server_protocol::ThreadStartSource::Clear => InitialHistory::Cleared,
},
history_mode,
session_source: None,
thread_source,
dynamic_tools,
metrics_service_name: service_name,
parent_trace: request_trace,
environments,
environments: Some(environments),
thread_extension_init,
supports_openai_form_elicitation,
..StartThreadOptions::new(config)
})
.instrument(tracing::info_span!(
"app_server.thread_start.create_thread",
Expand Down
5 changes: 3 additions & 2 deletions codex-rs/core/src/agent/control/residency_tests.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::StartThreadOptions;
use crate::ThreadManager;
use crate::agent::AgentControl;
use crate::codex_thread::CodexThread;
Expand Down Expand Up @@ -33,7 +34,7 @@ async fn residency_slot_reservation_unloads_oldest_idle_v2_agent() {
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
);
let root = manager
.start_thread(config.clone())
.start_thread(StartThreadOptions::new(config.clone()))
.await
.expect("start root thread");
let control = manager.agent_control();
Expand Down Expand Up @@ -79,7 +80,7 @@ async fn interrupted_v2_agent_is_lost_after_residency_eviction() {
Arc::new(codex_exec_server::EnvironmentManager::default_for_tests()),
);
let root = manager
.start_thread(config.clone())
.start_thread(StartThreadOptions::new(config.clone()))
.await
.expect("start root thread");
let control = manager.agent_control();
Expand Down
62 changes: 17 additions & 45 deletions codex-rs/core/src/agent/control_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ use codex_protocol::protocol::AskForApproval;
use codex_protocol::protocol::CompactedItem;
use codex_protocol::protocol::ErrorEvent;
use codex_protocol::protocol::EventMsg;
use codex_protocol::protocol::InitialHistory;
use codex_protocol::protocol::InterAgentCommunication;
use codex_protocol::protocol::ItemCompletedEvent;
use codex_protocol::protocol::RolloutItem;
Expand Down Expand Up @@ -160,7 +159,7 @@ impl AgentControlHarness {
async fn start_thread(&self) -> (ThreadId, Arc<CodexThread>) {
let new_thread = self
.manager
.start_thread(self.config.clone())
.start_thread(StartThreadOptions::new(self.config.clone()))
.await
.expect("start thread");
(new_thread.thread_id, new_thread.thread)
Expand All @@ -169,19 +168,10 @@ impl AgentControlHarness {
async fn start_paginated_thread(&self) -> (ThreadId, Arc<CodexThread>) {
let new_thread = self
.manager
.start_thread_with_options(StartThreadOptions {
config: self.config.clone(),
allow_provider_model_fallback: false,
initial_history: InitialHistory::New,
.start_thread(StartThreadOptions {
history_mode: Some(ThreadHistoryMode::Paginated),
session_source: None,
thread_source: None,
dynamic_tools: Vec::new(),
metrics_service_name: None,
parent_trace: None,
environments: Vec::new(),
thread_extension_init: ExtensionDataInit::default(),
supports_openai_form_elicitation: false,
environments: Some(Vec::new()),
..StartThreadOptions::new(self.config.clone())
})
.await
.expect("start paginated thread");
Expand Down Expand Up @@ -1219,7 +1209,7 @@ async fn spawn_agent_can_fork_parent_thread_history_with_sanitized_items() {
Some("Child subagent guidance.".to_string());
let new_thread = harness
.manager
.start_thread(parent_config.clone())
.start_thread(StartThreadOptions::new(parent_config.clone()))
.await
.expect("start parent thread");
let parent_thread_id = new_thread.thread_id;
Expand Down Expand Up @@ -1445,7 +1435,7 @@ async fn spawn_agent_fork_strips_parent_usage_hints_from_compacted_history() {
Some("Child subagent guidance.".to_string());
let new_thread = harness
.manager
.start_thread(parent_config)
.start_thread(StartThreadOptions::new(parent_config))
.await
.expect("start parent thread");
let parent_thread_id = new_thread.thread_id;
Expand Down Expand Up @@ -1750,19 +1740,10 @@ async fn spawn_agent_fork_last_n_turns_drops_parent_startup_prefix_when_under_li
thread_extension_init.insert(selected_capability_roots.clone());
let parent = harness
.manager
.start_thread_with_options(StartThreadOptions {
config: harness.config.clone(),
allow_provider_model_fallback: false,
initial_history: InitialHistory::New,
history_mode: None,
session_source: None,
thread_source: None,
dynamic_tools: Vec::new(),
metrics_service_name: None,
parent_trace: None,
environments: Vec::new(),
.start_thread(StartThreadOptions {
environments: Some(Vec::new()),
thread_extension_init,
supports_openai_form_elicitation: false,
..StartThreadOptions::new(harness.config.clone())
})
.await
.expect("start parent thread");
Expand Down Expand Up @@ -1876,7 +1857,7 @@ async fn spawn_agent_fork_last_n_turns_strips_parent_usage_hints() {
Some("Child subagent guidance.".to_string());
let new_thread = harness
.manager
.start_thread(parent_config)
.start_thread(StartThreadOptions::new(parent_config))
.await
.expect("start parent thread");
let parent_thread_id = new_thread.thread_id;
Expand Down Expand Up @@ -1976,7 +1957,7 @@ async fn spawn_agent_respects_legacy_max_threads_alias() {
let control = manager.agent_control();

let _ = manager
.start_thread(config.clone())
.start_thread(StartThreadOptions::new(config.clone()))
.await
.expect("start thread");

Expand Down Expand Up @@ -2227,7 +2208,7 @@ async fn multi_agent_v2_completion_ignores_dead_direct_parent() {
let _ = config.features.enable(Feature::MultiAgentV2);
let root = harness
.manager
.start_thread(config.clone())
.start_thread(StartThreadOptions::new(config.clone()))
.await
.expect("root thread should start");
let root_thread_id = root.thread_id;
Expand Down Expand Up @@ -2339,7 +2320,7 @@ async fn multi_agent_v2_completion_queues_message_for_direct_parent() {
let _ = tester_config.features.enable(Feature::MultiAgentV2);
let tester_thread_id = harness
.manager
.start_thread(tester_config.clone())
.start_thread(StartThreadOptions::new(tester_config.clone()))
.await
.expect("tester thread should start")
.thread_id;
Expand Down Expand Up @@ -2521,19 +2502,10 @@ async fn spawn_thread_subagents_persist_parent_originator_across_new_and_truncat
let harness = AgentControlHarness::new().await;
let parent = harness
.manager
.start_thread_with_options(StartThreadOptions {
config: harness.config.clone(),
allow_provider_model_fallback: false,
initial_history: InitialHistory::New,
history_mode: None,
session_source: None,
thread_source: None,
dynamic_tools: Vec::new(),
.start_thread(StartThreadOptions {
metrics_service_name: Some("codex_work_desktop".to_string()),
parent_trace: None,
environments: Vec::new(),
thread_extension_init: ExtensionDataInit::default(),
supports_openai_form_elicitation: false,
environments: Some(Vec::new()),
..StartThreadOptions::new(harness.config.clone())
})
.await
.expect("parent thread should start");
Expand Down Expand Up @@ -3044,7 +3016,7 @@ async fn list_agent_subtree_thread_ids_finds_live_descendants_of_unloaded_root()
);
let control = manager.agent_control();
let parent_thread_id = manager
.start_thread(config.clone())
.start_thread(StartThreadOptions::new(config.clone()))
.await
.expect("parent should start")
.thread_id;
Expand Down
5 changes: 4 additions & 1 deletion codex-rs/core/src/prompt_debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use crate::session::session::Session;
use crate::session::turn::build_prompt;
use crate::session::turn::built_tools;
use crate::state_db_bridge::StateDbHandle;
use crate::thread_manager::StartThreadOptions;
use crate::thread_manager::ThreadManager;
use crate::thread_manager::thread_store_from_config;
use codex_extension_api::empty_extension_registry;
Expand Down Expand Up @@ -64,7 +65,9 @@ pub async fn build_prompt_input(
/*attestation_provider*/ None,
/*external_time_provider*/ None,
);
let thread = thread_manager.start_thread(config).await?;
let thread = thread_manager
.start_thread(StartThreadOptions::new(config))
.await?;

let output = build_prompt_input_from_session(&thread.thread.session, input).await;
let shutdown = thread.thread.shutdown_and_wait().await;
Expand Down
Loading
Loading