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
7 changes: 2 additions & 5 deletions codex-rs/core/src/agent/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,6 @@ impl AgentControl {
let parent_thread = state.get_thread(*parent_thread_id).await.ok()?;
Some(
parent_thread
.codex
.session
.services
.turn_environments
Expand All @@ -614,14 +613,12 @@ impl AgentControl {
};

let parent_thread = state.get_thread(*parent_thread_id).await.ok()?;
let parent_config = parent_thread.codex.session.get_config().await;
let parent_config = parent_thread.session.get_config().await;
if !crate::exec_policy::child_uses_parent_exec_policy(&parent_config, child_config) {
return None;
}

Some(Arc::clone(
&parent_thread.codex.session.services.exec_policy,
))
Some(Arc::clone(&parent_thread.session.services.exec_policy))
}

async fn open_thread_spawn_children(
Expand Down
4 changes: 2 additions & 2 deletions codex-rs/core/src/agent/control/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ impl AgentControl {
}
let state = self.upgrade()?;
let thread = state.get_thread(thread_id).await?;
if thread.codex.session.active_turn.lock().await.is_some() {
if thread.session.active_turn.lock().await.is_some() {
return Ok(());
}
let config = thread.codex.session.get_config().await;
let config = thread.session.get_config().await;
let multi_agent_version = thread
.multi_agent_version()
.unwrap_or_else(|| config.multi_agent_version_from_features());
Expand Down
4 changes: 2 additions & 2 deletions codex-rs/core/src/agent/control/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ impl AgentControl {
pub(crate) async fn shutdown_live_agent(&self, agent_id: ThreadId) -> CodexResult<String> {
let state = self.upgrade()?;
let result = if let Ok(thread) = state.get_thread(agent_id).await {
thread.codex.session.ensure_rollout_materialized().await;
thread.codex.session.flush_rollout().await?;
thread.session.ensure_rollout_materialized().await;
thread.session.flush_rollout().await?;
let result = if matches!(thread.agent_status().await, AgentStatus::Shutdown) {
Ok(String::new())
} else {
Expand Down
9 changes: 2 additions & 7 deletions codex-rs/core/src/agent/control/residency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,8 @@ async fn is_unloadable(thread: &CodexThread) -> bool {
matches!(
thread.agent_status().await,
AgentStatus::Completed(_) | AgentStatus::Errored(_) | AgentStatus::Interrupted
) && thread.codex.session.active_turn.lock().await.is_none()
&& !thread
.codex
.session
.input_queue
.has_pending_mailbox_items()
.await
) && thread.session.active_turn.lock().await.is_none()
&& !thread.session.input_queue.has_pending_mailbox_items().await
}

#[cfg(test)]
Expand Down
8 changes: 3 additions & 5 deletions codex-rs/core/src/agent/control/residency_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,8 @@ async fn spawn_v2_subagent(
}

async fn mark_thread_completed(thread: &CodexThread) {
let turn = thread.codex.session.new_default_turn().await;
let turn = thread.session.new_default_turn().await;
thread
.codex
.session
.send_event(
turn.as_ref(),
Expand All @@ -172,9 +171,8 @@ async fn mark_thread_completed(thread: &CodexThread) {
}

async fn mark_thread_interrupted(thread: &CodexThread) {
let turn = thread.codex.session.new_default_turn().await;
let turn = thread.session.new_default_turn().await;
thread
.codex
.session
.send_event(
turn.as_ref(),
Expand All @@ -192,5 +190,5 @@ async fn mark_thread_interrupted(thread: &CodexThread) {

async fn clear_active_turn(thread: &CodexThread) {
// The fixture has no task runner to clear the turn after the terminal event.
*thread.codex.session.active_turn.lock().await = None;
*thread.session.active_turn.lock().await = None;
}
21 changes: 5 additions & 16 deletions codex-rs/core/src/agent/control/spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,13 +411,7 @@ impl AgentControl {
)) = notification_source.as_ref()
{
let client_metadata = match state.get_thread(*parent_thread_id).await {
Ok(parent_thread) => {
parent_thread
.codex
.session
.app_server_client_metadata()
.await
}
Ok(parent_thread) => parent_thread.session.app_server_client_metadata().await,
Err(error) => {
tracing::warn!(
error = %error,
Expand All @@ -430,17 +424,12 @@ impl AgentControl {
}
}
};
let thread_config = new_thread.thread.codex.thread_config_snapshot().await;
let thread_config = new_thread.thread.config_snapshot().await;
let parent_thread_id = thread_config.parent_thread_id;
emit_subagent_session_started(
&new_thread
.thread
.codex
.session
.services
.analytics_events_client,
&new_thread.thread.session.services.analytics_events_client,
client_metadata,
new_thread.thread.codex.session.session_id(),
new_thread.thread.session.session_id(),
new_thread.thread_id,
parent_thread_id,
thread_config,
Expand Down Expand Up @@ -569,7 +558,7 @@ impl AgentControl {
let multi_agent_v2_usage_hint_texts_to_filter: Vec<String> =
if let Some(parent_thread) = parent_thread.as_ref() {
if multi_agent_version == MultiAgentVersion::V2 {
let parent_config = parent_thread.codex.session.get_config().await;
let parent_config = parent_thread.session.get_config().await;
[
parent_config
.multi_agent_v2
Expand Down
Loading
Loading