From 6a767b72308d2aa89ec7db47baf20ee0e6df2a27 Mon Sep 17 00:00:00 2001 From: jif-oai Date: Mon, 10 Nov 2025 15:55:42 +0000 Subject: [PATCH] V6 --- codex-rs/api-client/src/responses.rs | 30 +--------------------------- codex-rs/core/src/auth.rs | 10 ++++------ codex-rs/core/src/codex.rs | 3 ++- 3 files changed, 7 insertions(+), 36 deletions(-) diff --git a/codex-rs/api-client/src/responses.rs b/codex-rs/api-client/src/responses.rs index 333a3553e8..cfcf510f1a 100644 --- a/codex-rs/api-client/src/responses.rs +++ b/codex-rs/api-client/src/responses.rs @@ -551,10 +551,6 @@ async fn handle_sse_payload( tx_event.send(Ok(ev)).await.ok(); } - if let Some(_rate_limits) = payload.rate_limits { - // Rate limit snapshots are not emitted for this protocol shape in this build. - } - if let Some(_response_content) = payload.response_content { // Not used currently } @@ -725,10 +721,6 @@ fn try_parse_retry_after(err: &ErrorResponse) -> Option { None } -fn is_context_window_error(error: &ErrorResponse) -> bool { - error.error.code.as_deref() == Some("context_length_exceeded") -} - /// used in tests to stream from a text SSE file pub async fn stream_from_fixture( path: impl AsRef, @@ -761,7 +753,7 @@ pub async fn stream_from_fixture( Ok(ResponseStream { rx_event }) } -fn attach_item_ids_array(json_array: &mut Vec, prompt_input: &[ResponseItem]) { +fn attach_item_ids_array(json_array: &mut [Value], prompt_input: &[ResponseItem]) { for (json_item, item) in json_array.iter_mut().zip(prompt_input.iter()) { let Some(obj) = json_item.as_object_mut() else { continue; @@ -876,11 +868,6 @@ struct TokenUsageOutputDetails { reasoning_tokens: Option, } -#[derive(Debug, Deserialize)] -struct StreamResponsePayload { - event: StreamEvent, -} - async fn handle_stream_event( event: StreamEvent, tx_event: mpsc::Sender>, @@ -1040,7 +1027,6 @@ async fn handle_stream_event( #[derive(Debug, Deserialize)] struct TextDelta { - role: String, delta: String, } @@ -1060,7 +1046,6 @@ mod sse { pub response_output_item_done: Option, pub response_output_reasoning_delta: Option, pub response_output_reasoning_summary_delta: Option, - pub rate_limits: Option>, } #[derive(Debug, Deserialize)] @@ -1087,8 +1072,6 @@ mod sse { #[derive(Debug, Deserialize)] pub struct ResponseMessageDelta { pub text: String, - pub role: String, - pub appended_content: Vec, } #[derive(Debug, Deserialize)] @@ -1100,7 +1083,6 @@ mod sse { #[derive(Debug, Deserialize)] pub struct ResponseOutputItem { pub r#type: OutputItem, - pub item: Value, } #[derive(Debug, Deserialize)] @@ -1115,21 +1097,11 @@ mod sse { #[derive(Debug, Deserialize)] pub struct ResponseOutputReasoningDelta { - pub content: Vec, pub text: String, } #[derive(Debug, Deserialize)] pub struct ResponseOutputReasoningSummaryDelta { - pub summary: Vec, pub text: String, } - - #[derive(Debug, Deserialize)] - pub struct RateLimit { - pub window: String, - pub remaining_tokens: i64, - pub limit: i64, - pub reset_seconds: i64, - } } diff --git a/codex-rs/core/src/auth.rs b/codex-rs/core/src/auth.rs index a9d6406001..182b4a4667 100644 --- a/codex-rs/core/src/auth.rs +++ b/codex-rs/core/src/auth.rs @@ -219,12 +219,10 @@ impl CodexAuth { InternalKnownPlan::Edu => AccountPlanType::Edu, }; - self.get_current_token_data() - .and_then(|t| t.id_token.chatgpt_plan_type) - .map(|pt| match pt { - InternalPlanType::Known(k) => map_known(&k), - InternalPlanType::Unknown(_) => AccountPlanType::Unknown, - }) + self.get_plan_type().map(|pt| match pt { + InternalPlanType::Known(k) => map_known(&k), + InternalPlanType::Unknown(_) => AccountPlanType::Unknown, + }) } /// Raw internal plan value from the ID token. diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs index dc4a7ca046..b6e616ded6 100644 --- a/codex-rs/core/src/codex.rs +++ b/codex-rs/core/src/codex.rs @@ -4,7 +4,8 @@ use std::path::PathBuf; use std::sync::Arc; use std::sync::atomic::AtomicU64; -use crate::{AuthManager, ModelClient}; +use crate::AuthManager; +use crate::ModelClient; use crate::client_common::REVIEW_PROMPT; use crate::features::Feature; use crate::function_tool::FunctionCallError;