Lightweight coding agent that runs in your terminal
Rust
Add collaboration_mode to TurnContextItem (#9583)
charley-oaife641f759f17
diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rsindex a05521e804..a3b3aba9a6 100644--- a/codex-rs/core/src/codex.rs+++ b/codex-rs/core/src/codex.rs@@ -1061,6 +1061,11 @@ impl Session {.await}+ pub(crate) async fn current_collaboration_mode(&self) -> CollaborationMode {+ let state = self.state.lock().await;+ state.session_configuration.collaboration_mode.clone()+ }+fn build_environment_update_item(&self,previous: Option<&Arc<TurnContext>>,@@ -3096,11 +3101,17 @@ async fn try_run_sampling_request(prompt: &Prompt,cancellation_token: CancellationToken,) -> CodexResult<SamplingRequestResult> {+ // TODO: If we need to guarantee the persisted mode always matches the prompt used for this+ // turn, capture it in TurnContext at creation time. Using SessionConfiguration here avoids+ // duplicating model settings on TurnContext, but a later Op could update the session config+ // before this write occurs.+ let collaboration_mode = sess.current_collaboration_mode().await;let rollout_item = RolloutItem::TurnContext(TurnContextItem {cwd: turn_context.cwd.clone(),approval_policy: turn_context.approval_policy,sandbox_policy: turn_context.sandbox_policy.clone(),model: turn_context.client.get_model(),+ collaboration_mode: Some(collaboration_mode),effort: turn_context.client.get_reasoning_effort(),summary: turn_context.client.get_reasoning_summary(),user_instructions: turn_context.user_instructions.clone(),diff --git a/codex-rs/core/src/compact.rs b/codex-rs/core/src/compact.rsindex 970eb0054d..958686c149 100644--- a/codex-rs/core/src/compact.rs+++ b/codex-rs/core/src/compact.rs@@ -84,11 +84,17 @@ async fn run_compact_task_inner(let max_retries = turn_context.client.get_provider().stream_max_retries();let mut retries = 0;+ // TODO: If we need to guarantee the persisted mode always matches the prompt used for this+ // turn, capture it in TurnContext at creation time. Using SessionConfiguration here avoids+ // duplicating model settings on TurnContext, but an Op after turn start could update the+ // session config before this write occurs.+ let collaboration_mode = sess.current_collaboration_mode().await;let rollout_item = RolloutItem::TurnContext(TurnContextItem {cwd: turn_context.cwd.clone(),approval_policy: turn_context.approval_policy,sandbox_policy: turn_context.sandbox_policy.clone(),model: turn_context.client.get_model(),+ collaboration_mode: Some(collaboration_mode),effort: turn_context.client.get_reasoning_effort(),summary: turn_context.client.get_reasoning_summary(),user_instructions: turn_context.user_instructions.clone(),diff --git a/codex-rs/core/tests/suite/resume_warning.rs b/codex-rs/core/tests/suite/resume_warning.rsindex 8c3ecf7afe..162e0e26ed 100644--- a/codex-rs/core/tests/suite/resume_warning.rs+++ b/codex-rs/core/tests/suite/resume_warning.rs@@ -26,6 +26,7 @@ fn resume_history(approval_policy: config.approval_policy.value(),sandbox_policy: config.sandbox_policy.get().clone(),model: previous_model.to_string(),+ collaboration_mode: None,effort: config.model_reasoning_effort,summary: config.model_reasoning_summary,user_instructions: None,diff --git a/codex-rs/protocol/src/protocol.rs b/codex-rs/protocol/src/protocol.rsindex 533fe04d88..1a9029f274 100644--- a/codex-rs/protocol/src/protocol.rs+++ b/codex-rs/protocol/src/protocol.rs@@ -1602,6 +1602,8 @@ pub struct TurnContextItem {pub approval_policy: AskForApproval,pub sandbox_policy: SandboxPolicy,pub model: String,+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub collaboration_mode: Option<CollaborationMode>,#[serde(skip_serializing_if = "Option::is_none")]pub effort: Option<ReasoningEffortConfig>,pub summary: ReasoningSummaryConfig,