From 9f436b1a266669fe976f8bad8ced85a41f057218 Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Tue, 23 Dec 2025 10:58:32 -0800 Subject: [PATCH] progress --- codex-rs/core/src/context_manager/history.rs | 2 +- codex-rs/docs/protocol_v1.md | 14 -------------- codex-rs/protocol/src/protocol.rs | 11 +++++++++++ 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/codex-rs/core/src/context_manager/history.rs b/codex-rs/core/src/context_manager/history.rs index 5ad389f6c5..d92d5b9a0d 100644 --- a/codex-rs/core/src/context_manager/history.rs +++ b/codex-rs/core/src/context_manager/history.rs @@ -225,7 +225,7 @@ impl ContextManager { } fn process_item(&self, item: &ResponseItem, policy: TruncationPolicy) -> ResponseItem { - let policy_with_serialization_budget = policy * 1.2; + let policy_with_serialization_budget = policy.mul(1.2); match item { ResponseItem::FunctionCallOutput { call_id, output } => { let truncated = diff --git a/codex-rs/docs/protocol_v1.md b/codex-rs/docs/protocol_v1.md index 7b373a34fc..805abb0ea8 100644 --- a/codex-rs/docs/protocol_v1.md +++ b/codex-rs/docs/protocol_v1.md @@ -173,17 +173,3 @@ sequenceDiagram task2->>user: Event::TurnCompleted task2->>-user: Event::TaskCompleted ``` - -## Key Events - -### SessionConfigured - -`Event::SessionConfigured` is emitted once after `Op::ConfigureSession`. - -Notable fields: -- `session_id`: the backend-assigned session identifier (historically named `session_id` for - backwards compatibility). -- `model_family`: model metadata for the model family selected for the session. This matches the - `/models` payload shape; the selected model slug is `model_family.slug`. -- `approval_policy`, `sandbox_policy`, `cwd`: the effective execution and sandbox settings for the - session. diff --git a/codex-rs/protocol/src/protocol.rs b/codex-rs/protocol/src/protocol.rs index aed21a709d..ec55a7cd2a 100644 --- a/codex-rs/protocol/src/protocol.rs +++ b/codex-rs/protocol/src/protocol.rs @@ -1344,6 +1344,17 @@ pub enum TruncationPolicy { Tokens(usize), } +// Allow core to pass model-family truncation policies (defined in openai_models) +// into the TurnContext payload (defined in protocol) via `.into()`. +impl From for TruncationPolicy { + fn from(value: crate::openai_models::TruncationPolicy) -> Self { + match value { + crate::openai_models::TruncationPolicy::Bytes(bytes) => Self::Bytes(bytes), + crate::openai_models::TruncationPolicy::Tokens(tokens) => Self::Tokens(tokens), + } + } +} + #[derive(Serialize, Deserialize, Clone, JsonSchema)] pub struct RolloutLine { pub timestamp: String,