Separate session state from session I/O (#33209)

## What changed

- Replace the combined `Codex` wrapper with an `Arc<Session>` and a dedicated
  `SessionIo` handle for submissions, events, status, and loop termination.
- Make `Session::spawn` return the session and I/O handle separately, and have
  `CodexThread` own both.
- Update thread management, delegated sessions, guardian reviews, and agent
  control to use the appropriate session or I/O interface.

GitOrigin-RevId: 8523bad7e7366e2969fd0cc3849b4247b141427a
This commit is contained in:
pakrym-oai authored and copyberry committed 2026-07-15 02:16:53 +00:00
1 parent 9cddda7556
commit e4711f2a3b
19 files changed
+360 -527

No files matched your search

+5 -16
View File
@@ -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,
@@ -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,
@@ -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