From 9e288db9bb0dfce4b107d04992d7a888f43c708c Mon Sep 17 00:00:00 2001 From: Rohit Arunachalam Date: Fri, 1 May 2026 16:29:39 -0700 Subject: [PATCH] Fix compact client clippy failure --- codex-rs/core/src/client.rs | 14 +++++++++----- codex-rs/core/src/compact_remote.rs | 13 +++++++++---- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/codex-rs/core/src/client.rs b/codex-rs/core/src/client.rs index 51d48db27d..921669773d 100644 --- a/codex-rs/core/src/client.rs +++ b/codex-rs/core/src/client.rs @@ -202,6 +202,11 @@ pub struct ModelClient { state: Arc, } +pub(crate) struct CompactConversationOptions<'a> { + pub(crate) mode: Option<&'static str>, + pub(crate) compaction_trace: &'a CompactionTraceContext, +} + /// A turn-scoped streaming session created from a [`ModelClient`]. /// /// The session establishes a Responses WebSocket connection lazily and reuses it across multiple @@ -409,15 +414,14 @@ impl ModelClient { /// /// The model selection and telemetry context are passed explicitly to keep `ModelClient` /// session-scoped. - pub async fn compact_conversation_history( + pub(crate) async fn compact_conversation_history( &self, prompt: &Prompt, model_info: &ModelInfo, effort: Option, summary: ReasoningSummaryConfig, session_telemetry: &SessionTelemetry, - mode: Option<&'static str>, - compaction_trace: &CompactionTraceContext, + options: CompactConversationOptions<'_>, ) -> Result> { if prompt.input.is_empty() { return Ok(Vec::new()); @@ -466,7 +470,7 @@ impl ModelClient { parallel_tool_calls: prompt.parallel_tool_calls, reasoning, text, - mode, + mode: options.mode, }; let mut extra_headers = ApiHeaderMap::new(); @@ -477,7 +481,7 @@ impl ModelClient { extra_headers.extend(build_conversation_headers(Some( self.state.conversation_id.to_string(), ))); - let trace_attempt = compaction_trace.start_attempt(&payload); + let trace_attempt = options.compaction_trace.start_attempt(&payload); let result = client .compact_input(&payload, extra_headers) .await diff --git a/codex-rs/core/src/compact_remote.rs b/codex-rs/core/src/compact_remote.rs index 5969a899a7..2eb8743b6a 100644 --- a/codex-rs/core/src/compact_remote.rs +++ b/codex-rs/core/src/compact_remote.rs @@ -2,6 +2,7 @@ use std::collections::HashSet; use std::sync::Arc; use crate::Prompt; +use crate::client::CompactConversationOptions; use crate::compact::CompactionAnalyticsAttempt; use crate::compact::InitialContextInjection; use crate::compact::compaction_status_from_result; @@ -118,8 +119,10 @@ pub(crate) async fn run_remote_prefix_compact_task( turn_context.reasoning_effort, turn_context.reasoning_summary, &turn_context.session_telemetry, - Some(PREFIX_COMPACTION_MODE), - &compaction_trace, + CompactConversationOptions { + mode: Some(PREFIX_COMPACTION_MODE), + compaction_trace: &compaction_trace, + }, ) .or_else(|err| async { let total_usage_breakdown = sess.get_total_token_usage_breakdown().await; @@ -232,8 +235,10 @@ async fn run_remote_compact_task_inner_impl( turn_context.reasoning_effort, turn_context.reasoning_summary, &turn_context.session_telemetry, - /*mode*/ None, - &compaction_trace, + CompactConversationOptions { + mode: None, + compaction_trace: &compaction_trace, + }, ) .or_else(|err| async { let total_usage_breakdown = sess.get_total_token_usage_breakdown().await;