mirror of
https://github.com/openai/codex.git
synced 2026-11-17 22:10:37 +00:00
fix
This commit is contained in:
@@ -49,7 +49,7 @@ use crate::features::FEATURES;
|
||||
use crate::flags::CODEX_RS_SSE_FIXTURE;
|
||||
use crate::model_provider_info::ModelProviderInfo;
|
||||
use crate::model_provider_info::WireApi;
|
||||
use crate::models_manager::model_family::ModelFamily;
|
||||
use codex_protocol::openai_models::ModelFamily;
|
||||
use crate::tools::spec::create_tools_json_for_chat_completions_api;
|
||||
use crate::tools::spec::create_tools_json_for_responses_api;
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use crate::client_common::tools::ToolSpec;
|
||||
use crate::error::Result;
|
||||
use crate::models_manager::model_family::ModelFamily;
|
||||
pub use codex_api::common::ResponseEvent;
|
||||
use codex_apply_patch::APPLY_PATCH_TOOL_INSTRUCTIONS;
|
||||
use codex_protocol::models::ResponseItem;
|
||||
use codex_protocol::openai_models::ModelFamily;
|
||||
use futures::Stream;
|
||||
use serde::Deserialize;
|
||||
use serde_json::Value;
|
||||
|
||||
@@ -17,14 +17,12 @@ use crate::exec_policy::ExecPolicyManager;
|
||||
use crate::features::Feature;
|
||||
use crate::features::Features;
|
||||
use crate::models_manager::manager::ModelsManager;
|
||||
use crate::models_manager::model_family::ModelFamily;
|
||||
use crate::parse_command::parse_command;
|
||||
use crate::parse_turn_item;
|
||||
use crate::stream_events_utils::HandleOutputCtx;
|
||||
use crate::stream_events_utils::handle_non_tool_response_item;
|
||||
use crate::stream_events_utils::handle_output_item_done;
|
||||
use crate::terminal;
|
||||
use crate::truncate::TruncationPolicy;
|
||||
use crate::user_notification::UserNotifier;
|
||||
use crate::util::error_or_panic;
|
||||
use async_channel::Receiver;
|
||||
@@ -32,6 +30,8 @@ use async_channel::Sender;
|
||||
use codex_protocol::ConversationId;
|
||||
use codex_protocol::approvals::ExecPolicyAmendment;
|
||||
use codex_protocol::items::TurnItem;
|
||||
use codex_protocol::openai_models::ModelFamily;
|
||||
use codex_protocol::openai_models::TruncationPolicy;
|
||||
use codex_protocol::protocol::FileChange;
|
||||
use codex_protocol::protocol::HasLegacyEvent;
|
||||
use codex_protocol::protocol::ItemCompletedEvent;
|
||||
@@ -527,7 +527,7 @@ impl Session {
|
||||
final_output_json_schema: None,
|
||||
codex_linux_sandbox_exe: per_turn_config.codex_linux_sandbox_exe.clone(),
|
||||
tool_call_gate: Arc::new(ReadinessFlag::new()),
|
||||
truncation_policy: TruncationPolicy::new(
|
||||
truncation_policy: crate::truncate::new_truncation_policy(
|
||||
per_turn_config.as_ref(),
|
||||
model_family.truncation_policy,
|
||||
),
|
||||
@@ -681,11 +681,14 @@ impl Session {
|
||||
// Dispatch the SessionConfiguredEvent first and then report any errors.
|
||||
// If resuming, include converted initial messages in the payload so UIs can render them immediately.
|
||||
let initial_messages = initial_history.get_event_msgs();
|
||||
let session_model_family = models_manager
|
||||
.construct_model_family(session_configuration.model.as_str(), config.as_ref())
|
||||
.await;
|
||||
let events = std::iter::once(Event {
|
||||
id: INITIAL_SUBMIT_ID.to_owned(),
|
||||
msg: EventMsg::SessionConfigured(SessionConfiguredEvent {
|
||||
session_id: conversation_id,
|
||||
model: session_configuration.model.clone(),
|
||||
model_family: session_model_family,
|
||||
model_provider_id: config.model_provider_id.clone(),
|
||||
approval_policy: session_configuration.approval_policy.value(),
|
||||
sandbox_policy: session_configuration.sandbox_policy.get().clone(),
|
||||
@@ -2144,7 +2147,10 @@ async fn spawn_review_thread(
|
||||
final_output_json_schema: None,
|
||||
codex_linux_sandbox_exe: parent_turn_context.codex_linux_sandbox_exe.clone(),
|
||||
tool_call_gate: Arc::new(ReadinessFlag::new()),
|
||||
truncation_policy: TruncationPolicy::new(&per_turn_config, model_family.truncation_policy),
|
||||
truncation_policy: crate::truncate::new_truncation_policy(
|
||||
&per_turn_config,
|
||||
model_family.truncation_policy,
|
||||
),
|
||||
};
|
||||
|
||||
// Seed the child task with the review prompt as the initial user message.
|
||||
|
||||
@@ -15,7 +15,7 @@ use crate::protocol::EventMsg;
|
||||
use crate::protocol::TaskStartedEvent;
|
||||
use crate::protocol::TurnContextItem;
|
||||
use crate::protocol::WarningEvent;
|
||||
use crate::truncate::TruncationPolicy;
|
||||
use codex_protocol::openai_models::TruncationPolicy;
|
||||
use crate::truncate::approx_token_count;
|
||||
use crate::truncate::truncate_text;
|
||||
use crate::util::backoff;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::codex::TurnContext;
|
||||
use crate::context_manager::normalize;
|
||||
use crate::truncate::TruncationPolicy;
|
||||
use codex_protocol::openai_models::TruncationPolicy;
|
||||
use crate::truncate::approx_token_count;
|
||||
use crate::truncate::approx_tokens_from_byte_count;
|
||||
use crate::truncate::truncate_function_output_items_with_policy;
|
||||
@@ -225,7 +225,7 @@ impl ContextManager {
|
||||
}
|
||||
|
||||
fn process_item(&self, item: &ResponseItem, policy: TruncationPolicy) -> ResponseItem {
|
||||
let policy_with_serialization_budget = policy.mul(1.2);
|
||||
let policy_with_serialization_budget = policy * 1.2;
|
||||
match item {
|
||||
ResponseItem::FunctionCallOutput { call_id, output } => {
|
||||
let truncated =
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use super::*;
|
||||
use crate::truncate;
|
||||
use crate::truncate::TruncationPolicy;
|
||||
use codex_git::GhostCommit;
|
||||
use codex_protocol::models::ContentItem;
|
||||
use codex_protocol::models::FunctionCallOutputPayload;
|
||||
@@ -9,6 +8,7 @@ use codex_protocol::models::LocalShellExecAction;
|
||||
use codex_protocol::models::LocalShellStatus;
|
||||
use codex_protocol::models::ReasoningItemContent;
|
||||
use codex_protocol::models::ReasoningItemReasoningSummary;
|
||||
use codex_protocol::openai_models::TruncationPolicy;
|
||||
use pretty_assertions::assert_eq;
|
||||
use regex_lite::Regex;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::exec::ExecToolCallOutput;
|
||||
use crate::token_data::KnownPlan;
|
||||
use crate::token_data::PlanType;
|
||||
use crate::truncate::TruncationPolicy;
|
||||
use codex_protocol::openai_models::TruncationPolicy;
|
||||
use crate::truncate::truncate_text;
|
||||
use chrono::DateTime;
|
||||
use chrono::Datelike;
|
||||
|
||||
@@ -25,7 +25,7 @@ use crate::default_client::build_reqwest_client;
|
||||
use crate::error::Result as CoreResult;
|
||||
use crate::features::Feature;
|
||||
use crate::model_provider_info::ModelProviderInfo;
|
||||
use crate::models_manager::model_family::ModelFamily;
|
||||
use codex_protocol::openai_models::ModelFamily;
|
||||
use crate::models_manager::model_presets::builtin_model_presets;
|
||||
|
||||
const MODEL_CACHE_FILE: &str = "models_cache.json";
|
||||
@@ -149,9 +149,11 @@ impl ModelsManager {
|
||||
|
||||
/// Look up the requested model family while applying remote metadata overrides.
|
||||
pub async fn construct_model_family(&self, model: &str, config: &Config) -> ModelFamily {
|
||||
Self::find_family_for_model(model)
|
||||
.with_remote_overrides(self.remote_models(config).await)
|
||||
.with_config_overrides(config)
|
||||
crate::models_manager::model_family::with_config_overrides(
|
||||
Self::find_family_for_model(model)
|
||||
.with_remote_overrides(self.remote_models(config).await),
|
||||
config,
|
||||
)
|
||||
}
|
||||
|
||||
pub async fn get_model(&self, model: &Option<String>, config: &Config) -> String {
|
||||
@@ -185,7 +187,10 @@ impl ModelsManager {
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
/// Offline helper that builds a `ModelFamily` without consulting remote state.
|
||||
pub fn construct_model_family_offline(model: &str, config: &Config) -> ModelFamily {
|
||||
Self::find_family_for_model(model).with_config_overrides(config)
|
||||
crate::models_manager::model_family::with_config_overrides(
|
||||
Self::find_family_for_model(model),
|
||||
config,
|
||||
)
|
||||
}
|
||||
|
||||
/// Replace the cached remote models and rebuild the derived presets list.
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
use codex_protocol::config_types::Verbosity;
|
||||
use codex_protocol::openai_models::ApplyPatchToolType;
|
||||
use codex_protocol::openai_models::ConfigShellToolType;
|
||||
use codex_protocol::openai_models::ModelInfo;
|
||||
use codex_protocol::openai_models::ModelFamily;
|
||||
use codex_protocol::openai_models::ReasoningEffort;
|
||||
use codex_protocol::openai_models::ReasoningSummaryFormat;
|
||||
use codex_protocol::openai_models::TruncationPolicy;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::truncate::TruncationPolicy;
|
||||
|
||||
/// The `instructions` field in the payload sent to a model should always start
|
||||
/// with this content.
|
||||
@@ -19,174 +19,20 @@ const GPT_5_1_CODEX_MAX_INSTRUCTIONS: &str = include_str!("../../gpt-5.1-codex-m
|
||||
const GPT_5_2_CODEX_INSTRUCTIONS: &str = include_str!("../../gpt-5.2-codex_prompt.md");
|
||||
pub(crate) const CONTEXT_WINDOW_272K: i64 = 272_000;
|
||||
|
||||
/// A model family is a group of models that share certain characteristics.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct ModelFamily {
|
||||
/// The full model slug used to derive this model family, e.g.
|
||||
/// "gpt-4.1-2025-04-14".
|
||||
pub slug: String,
|
||||
|
||||
/// The model family name, e.g. "gpt-4.1". This string is used when deriving
|
||||
/// default metadata for the family, such as context windows.
|
||||
pub family: String,
|
||||
|
||||
/// True if the model needs additional instructions on how to use the
|
||||
/// "virtual" `apply_patch` CLI.
|
||||
pub needs_special_apply_patch_instructions: bool,
|
||||
|
||||
/// Maximum supported context window, if known.
|
||||
pub context_window: Option<i64>,
|
||||
|
||||
/// Token threshold for automatic compaction if config does not override it.
|
||||
auto_compact_token_limit: Option<i64>,
|
||||
|
||||
// Whether the `reasoning` field can be set when making a request to this
|
||||
// model family. Note it has `effort` and `summary` subfields (though
|
||||
// `summary` is optional).
|
||||
pub supports_reasoning_summaries: bool,
|
||||
|
||||
// The reasoning effort to use for this model family when none is explicitly chosen.
|
||||
pub default_reasoning_effort: Option<ReasoningEffort>,
|
||||
|
||||
// Define if we need a special handling of reasoning summary
|
||||
pub reasoning_summary_format: ReasoningSummaryFormat,
|
||||
|
||||
/// Whether this model supports parallel tool calls when using the
|
||||
/// Responses API.
|
||||
pub supports_parallel_tool_calls: bool,
|
||||
|
||||
/// Present if the model performs better when `apply_patch` is provided as
|
||||
/// a tool call instead of just a bash command
|
||||
pub apply_patch_tool_type: Option<ApplyPatchToolType>,
|
||||
|
||||
// Instructions to use for querying the model
|
||||
pub base_instructions: String,
|
||||
|
||||
/// Names of beta tools that should be exposed to this model family.
|
||||
pub experimental_supported_tools: Vec<String>,
|
||||
|
||||
/// Percentage of the context window considered usable for inputs, after
|
||||
/// reserving headroom for system prompts, tool overhead, and model output.
|
||||
/// This is applied when computing the effective context window seen by
|
||||
/// consumers.
|
||||
pub effective_context_window_percent: i64,
|
||||
|
||||
/// If the model family supports setting the verbosity level when using Responses API.
|
||||
pub support_verbosity: bool,
|
||||
|
||||
// The default verbosity level for this model family when using Responses API.
|
||||
pub default_verbosity: Option<Verbosity>,
|
||||
|
||||
/// Preferred shell tool type for this model family when features do not override it.
|
||||
pub shell_type: ConfigShellToolType,
|
||||
|
||||
pub truncation_policy: TruncationPolicy,
|
||||
}
|
||||
|
||||
impl ModelFamily {
|
||||
/// Placeholder model family for UI startup before Codex has selected the real model.
|
||||
///
|
||||
/// This must not be treated as an actual model slug; it only exists to allow
|
||||
/// consumers (e.g. the TUI) to render while the session is still starting.
|
||||
pub fn placeholder(config: &Config) -> Self {
|
||||
let mf = Self {
|
||||
slug: String::new(),
|
||||
family: "unknown".to_string(),
|
||||
needs_special_apply_patch_instructions: false,
|
||||
context_window: None,
|
||||
auto_compact_token_limit: None,
|
||||
supports_reasoning_summaries: false,
|
||||
default_reasoning_effort: None,
|
||||
reasoning_summary_format: ReasoningSummaryFormat::None,
|
||||
supports_parallel_tool_calls: false,
|
||||
apply_patch_tool_type: None,
|
||||
base_instructions: BASE_INSTRUCTIONS.to_string(),
|
||||
experimental_supported_tools: Vec::new(),
|
||||
effective_context_window_percent: 95,
|
||||
support_verbosity: false,
|
||||
default_verbosity: None,
|
||||
shell_type: ConfigShellToolType::Default,
|
||||
truncation_policy: TruncationPolicy::Bytes(10_000),
|
||||
};
|
||||
mf.with_config_overrides(config)
|
||||
pub fn with_config_overrides(mut mf: ModelFamily, config: &Config) -> ModelFamily {
|
||||
if let Some(supports_reasoning_summaries) = config.model_supports_reasoning_summaries {
|
||||
mf.supports_reasoning_summaries = supports_reasoning_summaries;
|
||||
}
|
||||
|
||||
pub(super) fn with_config_overrides(mut self, config: &Config) -> Self {
|
||||
if let Some(supports_reasoning_summaries) = config.model_supports_reasoning_summaries {
|
||||
self.supports_reasoning_summaries = supports_reasoning_summaries;
|
||||
}
|
||||
if let Some(reasoning_summary_format) = config.model_reasoning_summary_format.as_ref() {
|
||||
self.reasoning_summary_format = reasoning_summary_format.clone();
|
||||
}
|
||||
if let Some(context_window) = config.model_context_window {
|
||||
self.context_window = Some(context_window);
|
||||
}
|
||||
if let Some(auto_compact_token_limit) = config.model_auto_compact_token_limit {
|
||||
self.auto_compact_token_limit = Some(auto_compact_token_limit);
|
||||
}
|
||||
self
|
||||
if let Some(reasoning_summary_format) = config.model_reasoning_summary_format.as_ref() {
|
||||
mf.reasoning_summary_format = reasoning_summary_format.clone();
|
||||
}
|
||||
pub(super) fn with_remote_overrides(mut self, remote_models: Vec<ModelInfo>) -> Self {
|
||||
for model in remote_models {
|
||||
if model.slug == self.slug {
|
||||
self.apply_remote_overrides(model);
|
||||
}
|
||||
}
|
||||
self
|
||||
if let Some(context_window) = config.model_context_window {
|
||||
mf.context_window = Some(context_window);
|
||||
}
|
||||
|
||||
fn apply_remote_overrides(&mut self, model: ModelInfo) {
|
||||
let ModelInfo {
|
||||
slug: _,
|
||||
display_name: _,
|
||||
description: _,
|
||||
default_reasoning_level,
|
||||
supported_reasoning_levels: _,
|
||||
shell_type,
|
||||
visibility: _,
|
||||
supported_in_api: _,
|
||||
priority: _,
|
||||
upgrade: _,
|
||||
base_instructions,
|
||||
supports_reasoning_summaries,
|
||||
support_verbosity,
|
||||
default_verbosity,
|
||||
apply_patch_tool_type,
|
||||
truncation_policy,
|
||||
supports_parallel_tool_calls,
|
||||
context_window,
|
||||
reasoning_summary_format,
|
||||
experimental_supported_tools,
|
||||
} = model;
|
||||
|
||||
self.default_reasoning_effort = Some(default_reasoning_level);
|
||||
self.shell_type = shell_type;
|
||||
if let Some(base) = base_instructions {
|
||||
self.base_instructions = base;
|
||||
}
|
||||
self.supports_reasoning_summaries = supports_reasoning_summaries;
|
||||
self.support_verbosity = support_verbosity;
|
||||
self.default_verbosity = default_verbosity;
|
||||
self.apply_patch_tool_type = apply_patch_tool_type;
|
||||
self.truncation_policy = truncation_policy.into();
|
||||
self.supports_parallel_tool_calls = supports_parallel_tool_calls;
|
||||
self.context_window = context_window;
|
||||
self.reasoning_summary_format = reasoning_summary_format;
|
||||
self.experimental_supported_tools = experimental_supported_tools;
|
||||
}
|
||||
|
||||
pub fn auto_compact_token_limit(&self) -> Option<i64> {
|
||||
self.auto_compact_token_limit
|
||||
.or(self.context_window.map(Self::default_auto_compact_limit))
|
||||
}
|
||||
|
||||
const fn default_auto_compact_limit(context_window: i64) -> i64 {
|
||||
(context_window * 9) / 10
|
||||
}
|
||||
|
||||
pub fn get_model_slug(&self) -> &str {
|
||||
&self.slug
|
||||
if let Some(auto_compact_token_limit) = config.model_auto_compact_token_limit {
|
||||
mf.auto_compact_token_limit = Some(auto_compact_token_limit);
|
||||
}
|
||||
mf
|
||||
}
|
||||
|
||||
macro_rules! model_family {
|
||||
@@ -460,6 +306,7 @@ fn derive_default_model_family(model: &str) -> ModelFamily {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use codex_protocol::openai_models::ModelInfo;
|
||||
use codex_protocol::openai_models::ModelVisibility;
|
||||
use codex_protocol::openai_models::ReasoningEffortPreset;
|
||||
use codex_protocol::openai_models::TruncationPolicyConfig;
|
||||
|
||||
@@ -7,7 +7,7 @@ use crate::context_manager::ContextManager;
|
||||
use crate::protocol::RateLimitSnapshot;
|
||||
use crate::protocol::TokenUsage;
|
||||
use crate::protocol::TokenUsageInfo;
|
||||
use crate::truncate::TruncationPolicy;
|
||||
use codex_protocol::openai_models::TruncationPolicy;
|
||||
|
||||
/// Persistent, session-scoped state previously stored directly on `Session`.
|
||||
pub(crate) struct SessionState {
|
||||
|
||||
@@ -10,7 +10,7 @@ pub mod sandboxing;
|
||||
pub mod spec;
|
||||
|
||||
use crate::exec::ExecToolCallOutput;
|
||||
use crate::truncate::TruncationPolicy;
|
||||
use codex_protocol::openai_models::TruncationPolicy;
|
||||
use crate::truncate::formatted_truncate_text;
|
||||
use crate::truncate::truncate_text;
|
||||
pub use router::ToolRouter;
|
||||
|
||||
@@ -2,7 +2,7 @@ use crate::client_common::tools::ResponsesApiTool;
|
||||
use crate::client_common::tools::ToolSpec;
|
||||
use crate::features::Feature;
|
||||
use crate::features::Features;
|
||||
use crate::models_manager::model_family::ModelFamily;
|
||||
use codex_protocol::openai_models::ModelFamily;
|
||||
use crate::tools::handlers::PLAN_TOOL;
|
||||
use crate::tools::handlers::apply_patch::create_apply_patch_freeform_tool;
|
||||
use crate::tools::handlers::apply_patch::create_apply_patch_json_tool;
|
||||
|
||||
@@ -4,89 +4,60 @@
|
||||
|
||||
use crate::config::Config;
|
||||
use codex_protocol::models::FunctionCallOutputContentItem;
|
||||
use codex_protocol::openai_models::TruncationMode;
|
||||
use codex_protocol::openai_models::TruncationPolicyConfig;
|
||||
use codex_protocol::openai_models::TruncationPolicy;
|
||||
|
||||
const APPROX_BYTES_PER_TOKEN: usize = 4;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub enum TruncationPolicy {
|
||||
Bytes(usize),
|
||||
Tokens(usize),
|
||||
}
|
||||
/// Create a new `TruncationPolicy` with config overrides applied.
|
||||
pub fn new_truncation_policy(config: &Config, truncation_policy: TruncationPolicy) -> TruncationPolicy {
|
||||
let config_token_limit = config.tool_output_token_limit;
|
||||
|
||||
impl From<TruncationPolicyConfig> for TruncationPolicy {
|
||||
fn from(config: TruncationPolicyConfig) -> Self {
|
||||
match config.mode {
|
||||
TruncationMode::Bytes => Self::Bytes(config.limit as usize),
|
||||
TruncationMode::Tokens => Self::Tokens(config.limit as usize),
|
||||
match truncation_policy {
|
||||
TruncationPolicy::Bytes(family_bytes) => {
|
||||
if let Some(token_limit) = config_token_limit {
|
||||
TruncationPolicy::Bytes(approx_bytes_for_tokens(token_limit))
|
||||
} else {
|
||||
TruncationPolicy::Bytes(family_bytes)
|
||||
}
|
||||
}
|
||||
TruncationPolicy::Tokens(family_tokens) => {
|
||||
if let Some(token_limit) = config_token_limit {
|
||||
TruncationPolicy::Tokens(token_limit)
|
||||
} else {
|
||||
TruncationPolicy::Tokens(family_tokens)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TruncationPolicy {
|
||||
/// Scale the underlying budget by `multiplier`, rounding up to avoid under-budgeting.
|
||||
pub fn mul(self, multiplier: f64) -> Self {
|
||||
match self {
|
||||
TruncationPolicy::Bytes(bytes) => {
|
||||
TruncationPolicy::Bytes((bytes as f64 * multiplier).ceil() as usize)
|
||||
}
|
||||
TruncationPolicy::Tokens(tokens) => {
|
||||
TruncationPolicy::Tokens((tokens as f64 * multiplier).ceil() as usize)
|
||||
}
|
||||
/// Returns a token budget derived from this policy.
|
||||
///
|
||||
/// - For `Tokens`, this is the explicit token limit.
|
||||
/// - For `Bytes`, this is an approximate token budget using the global
|
||||
/// bytes-per-token heuristic.
|
||||
pub fn token_budget(policy: &TruncationPolicy) -> usize {
|
||||
match policy {
|
||||
TruncationPolicy::Bytes(bytes) => {
|
||||
usize::try_from(approx_tokens_from_byte_count(*bytes)).unwrap_or(usize::MAX)
|
||||
}
|
||||
TruncationPolicy::Tokens(tokens) => *tokens,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(config: &Config, truncation_policy: TruncationPolicy) -> Self {
|
||||
let config_token_limit = config.tool_output_token_limit;
|
||||
|
||||
match truncation_policy {
|
||||
TruncationPolicy::Bytes(family_bytes) => {
|
||||
if let Some(token_limit) = config_token_limit {
|
||||
Self::Bytes(approx_bytes_for_tokens(token_limit))
|
||||
} else {
|
||||
Self::Bytes(family_bytes)
|
||||
}
|
||||
}
|
||||
TruncationPolicy::Tokens(family_tokens) => {
|
||||
if let Some(token_limit) = config_token_limit {
|
||||
Self::Tokens(token_limit)
|
||||
} else {
|
||||
Self::Tokens(family_tokens)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a token budget derived from this policy.
|
||||
///
|
||||
/// - For `Tokens`, this is the explicit token limit.
|
||||
/// - For `Bytes`, this is an approximate token budget using the global
|
||||
/// bytes-per-token heuristic.
|
||||
pub fn token_budget(&self) -> usize {
|
||||
match self {
|
||||
TruncationPolicy::Bytes(bytes) => {
|
||||
usize::try_from(approx_tokens_from_byte_count(*bytes)).unwrap_or(usize::MAX)
|
||||
}
|
||||
TruncationPolicy::Tokens(tokens) => *tokens,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a byte budget derived from this policy.
|
||||
///
|
||||
/// - For `Bytes`, this is the explicit byte limit.
|
||||
/// - For `Tokens`, this is an approximate byte budget using the global
|
||||
/// bytes-per-token heuristic.
|
||||
pub fn byte_budget(&self) -> usize {
|
||||
match self {
|
||||
TruncationPolicy::Bytes(bytes) => *bytes,
|
||||
TruncationPolicy::Tokens(tokens) => approx_bytes_for_tokens(*tokens),
|
||||
}
|
||||
/// Returns a byte budget derived from this policy.
|
||||
///
|
||||
/// - For `Bytes`, this is the explicit byte limit.
|
||||
/// - For `Tokens`, this is an approximate byte budget using the global
|
||||
/// bytes-per-token heuristic.
|
||||
pub fn byte_budget(policy: &TruncationPolicy) -> usize {
|
||||
match policy {
|
||||
TruncationPolicy::Bytes(bytes) => *bytes,
|
||||
TruncationPolicy::Tokens(tokens) => approx_bytes_for_tokens(*tokens),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn formatted_truncate_text(content: &str, policy: TruncationPolicy) -> String {
|
||||
if content.len() <= policy.byte_budget() {
|
||||
if content.len() <= byte_budget(&policy) {
|
||||
return content.to_string();
|
||||
}
|
||||
let total_lines = content.lines().count();
|
||||
@@ -112,8 +83,8 @@ pub(crate) fn truncate_function_output_items_with_policy(
|
||||
) -> Vec<FunctionCallOutputContentItem> {
|
||||
let mut out: Vec<FunctionCallOutputContentItem> = Vec::with_capacity(items.len());
|
||||
let mut remaining_budget = match policy {
|
||||
TruncationPolicy::Bytes(_) => policy.byte_budget(),
|
||||
TruncationPolicy::Tokens(_) => policy.token_budget(),
|
||||
TruncationPolicy::Bytes(_) => byte_budget(&policy),
|
||||
TruncationPolicy::Tokens(_) => token_budget(&policy),
|
||||
};
|
||||
let mut omitted_text_items = 0usize;
|
||||
|
||||
@@ -172,7 +143,7 @@ fn truncate_with_token_budget(s: &str, policy: TruncationPolicy) -> (String, Opt
|
||||
if s.is_empty() {
|
||||
return (String::new(), None);
|
||||
}
|
||||
let max_tokens = policy.token_budget();
|
||||
let max_tokens = token_budget(&policy);
|
||||
|
||||
let byte_len = s.len();
|
||||
if max_tokens > 0 && byte_len <= approx_bytes_for_tokens(max_tokens) {
|
||||
@@ -198,7 +169,7 @@ fn truncate_with_byte_estimate(s: &str, policy: TruncationPolicy) -> String {
|
||||
}
|
||||
|
||||
let total_chars = s.chars().count();
|
||||
let max_bytes = policy.byte_budget();
|
||||
let max_bytes = byte_budget(&policy);
|
||||
|
||||
if max_bytes == 0 {
|
||||
// No budget to show content; just report that everything was truncated.
|
||||
|
||||
@@ -14,7 +14,7 @@ use crate::exec::ExecToolCallOutput;
|
||||
use crate::exec::SandboxType;
|
||||
use crate::exec::StreamOutput;
|
||||
use crate::exec::is_likely_sandbox_denied;
|
||||
use crate::truncate::TruncationPolicy;
|
||||
use codex_protocol::openai_models::TruncationPolicy;
|
||||
use crate::truncate::formatted_truncate_text;
|
||||
use codex_utils_pty::ExecCommandSession;
|
||||
use codex_utils_pty::SpawnedPty;
|
||||
|
||||
@@ -22,7 +22,7 @@ use crate::tools::orchestrator::ToolOrchestrator;
|
||||
use crate::tools::runtimes::unified_exec::UnifiedExecRequest as UnifiedExecToolRequest;
|
||||
use crate::tools::runtimes::unified_exec::UnifiedExecRuntime;
|
||||
use crate::tools::sandboxing::ToolCtx;
|
||||
use crate::truncate::TruncationPolicy;
|
||||
use codex_protocol::openai_models::TruncationPolicy;
|
||||
use crate::truncate::approx_token_count;
|
||||
use crate::truncate::formatted_truncate_text;
|
||||
|
||||
|
||||
@@ -250,7 +250,7 @@ impl TestCodex {
|
||||
approval_policy: AskForApproval,
|
||||
sandbox_policy: SandboxPolicy,
|
||||
) -> Result<()> {
|
||||
let session_model = self.session_configured.model.clone();
|
||||
let session_model = self.session_configured.model_family.slug.clone();
|
||||
self.codex
|
||||
.submit(Op::UserTurn {
|
||||
items: vec![UserInput::Text {
|
||||
|
||||
@@ -297,7 +297,7 @@ async fn apply_patch_cli_move_without_content_change_has_no_turn_diff(
|
||||
let call_id = "apply-move-no-change";
|
||||
mount_apply_patch(&harness, call_id, patch, "ok", model_output).await;
|
||||
|
||||
let model = test.session_configured.model.clone();
|
||||
let model = test.session_configured.model_family.slug.clone();
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
items: vec![UserInput::Text {
|
||||
@@ -883,7 +883,7 @@ async fn apply_patch_shell_command_heredoc_with_cd_emits_turn_diff() -> Result<(
|
||||
];
|
||||
mount_sse_sequence(harness.server(), bodies).await;
|
||||
|
||||
let model = test.session_configured.model.clone();
|
||||
let model = test.session_configured.model_family.slug.clone();
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
items: vec![UserInput::Text {
|
||||
@@ -960,7 +960,7 @@ async fn apply_patch_shell_command_failure_propagates_error_and_skips_diff() ->
|
||||
];
|
||||
mount_sse_sequence(harness.server(), bodies).await;
|
||||
|
||||
let model = test.session_configured.model.clone();
|
||||
let model = test.session_configured.model_family.slug.clone();
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
items: vec![UserInput::Text {
|
||||
@@ -1107,7 +1107,7 @@ async fn apply_patch_emits_turn_diff_event_with_unified_diff(
|
||||
let patch = format!("*** Begin Patch\n*** Add File: {file}\n+hello\n*** End Patch\n");
|
||||
mount_apply_patch(&harness, call_id, patch.as_str(), "ok", model_output).await;
|
||||
|
||||
let model = test.session_configured.model.clone();
|
||||
let model = test.session_configured.model_family.slug.clone();
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
items: vec![UserInput::Text {
|
||||
@@ -1167,7 +1167,7 @@ async fn apply_patch_turn_diff_for_rename_with_content_change(
|
||||
let patch = "*** Begin Patch\n*** Update File: old.txt\n*** Move to: new.txt\n@@\n-old\n+new\n*** End Patch";
|
||||
mount_apply_patch(&harness, call_id, patch, "ok", model_output).await;
|
||||
|
||||
let model = test.session_configured.model.clone();
|
||||
let model = test.session_configured.model_family.slug.clone();
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
items: vec![UserInput::Text {
|
||||
@@ -1235,7 +1235,7 @@ async fn apply_patch_aggregates_diff_across_multiple_tool_calls() -> Result<()>
|
||||
]);
|
||||
mount_sse_sequence(harness.server(), vec![s1, s2, s3]).await;
|
||||
|
||||
let model = test.session_configured.model.clone();
|
||||
let model = test.session_configured.model_family.slug.clone();
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
items: vec![UserInput::Text {
|
||||
@@ -1303,7 +1303,7 @@ async fn apply_patch_aggregates_diff_preserves_success_after_failure() -> Result
|
||||
];
|
||||
mount_sse_sequence(harness.server(), responses).await;
|
||||
|
||||
let model = test.session_configured.model.clone();
|
||||
let model = test.session_configured.model_family.slug.clone();
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
items: vec![UserInput::Text {
|
||||
|
||||
@@ -486,7 +486,7 @@ async fn submit_turn(
|
||||
approval_policy: AskForApproval,
|
||||
sandbox_policy: SandboxPolicy,
|
||||
) -> Result<()> {
|
||||
let session_model = test.session_configured.model.clone();
|
||||
let session_model = test.session_configured.model_family.slug.clone();
|
||||
|
||||
test.codex
|
||||
.submit(Op::UserTurn {
|
||||
|
||||
@@ -103,7 +103,7 @@ async fn remote_compact_replaces_history_for_followups() -> Result<()> {
|
||||
let compact_body = compact_request.body_json();
|
||||
assert_eq!(
|
||||
compact_body.get("model").and_then(|v| v.as_str()),
|
||||
Some(harness.test().session_configured.model.as_str())
|
||||
Some(harness.test().session_configured.model_family.slug.as_str())
|
||||
);
|
||||
let compact_body_text = compact_body.to_string();
|
||||
assert!(
|
||||
|
||||
@@ -67,7 +67,7 @@ async fn execpolicy_blocks_shell_invocation() -> Result<()> {
|
||||
)
|
||||
.await;
|
||||
|
||||
let session_model = test.session_configured.model.clone();
|
||||
let session_model = test.session_configured.model_family.slug.clone();
|
||||
test.codex
|
||||
.submit(Op::UserTurn {
|
||||
items: vec![UserInput::Text {
|
||||
|
||||
@@ -606,7 +606,7 @@ async fn send_user_turn_with_no_changes_does_not_send_environment_context() -> a
|
||||
let default_cwd = config.cwd.clone();
|
||||
let default_approval_policy = config.approval_policy.value();
|
||||
let default_sandbox_policy = config.sandbox_policy.get();
|
||||
let default_model = session_configured.model;
|
||||
let default_model = session_configured.model_family.slug;
|
||||
let default_effort = config.model_reasoning_effort;
|
||||
let default_summary = config.model_reasoning_summary;
|
||||
|
||||
@@ -696,7 +696,7 @@ async fn send_user_turn_with_changes_sends_environment_context() -> anyhow::Resu
|
||||
let default_cwd = config.cwd.clone();
|
||||
let default_approval_policy = config.approval_policy.value();
|
||||
let default_sandbox_policy = config.sandbox_policy.get();
|
||||
let default_model = session_configured.model;
|
||||
let default_model = session_configured.model_family.slug;
|
||||
let default_effort = config.model_reasoning_effort;
|
||||
let default_summary = config.model_reasoning_summary;
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ async fn stdio_server_round_trip() -> anyhow::Result<()> {
|
||||
})
|
||||
.build(&server)
|
||||
.await?;
|
||||
let session_model = fixture.session_configured.model.clone();
|
||||
let session_model = fixture.session_configured.model_family.slug.clone();
|
||||
|
||||
fixture
|
||||
.codex
|
||||
@@ -238,7 +238,7 @@ async fn stdio_image_responses_round_trip() -> anyhow::Result<()> {
|
||||
})
|
||||
.build(&server)
|
||||
.await?;
|
||||
let session_model = fixture.session_configured.model.clone();
|
||||
let session_model = fixture.session_configured.model_family.slug.clone();
|
||||
|
||||
fixture
|
||||
.codex
|
||||
@@ -433,7 +433,7 @@ async fn stdio_image_completions_round_trip() -> anyhow::Result<()> {
|
||||
})
|
||||
.build(&server)
|
||||
.await?;
|
||||
let session_model = fixture.session_configured.model.clone();
|
||||
let session_model = fixture.session_configured.model_family.slug.clone();
|
||||
|
||||
fixture
|
||||
.codex
|
||||
@@ -576,7 +576,7 @@ async fn stdio_server_propagates_whitelisted_env_vars() -> anyhow::Result<()> {
|
||||
})
|
||||
.build(&server)
|
||||
.await?;
|
||||
let session_model = fixture.session_configured.model.clone();
|
||||
let session_model = fixture.session_configured.model_family.slug.clone();
|
||||
|
||||
fixture
|
||||
.codex
|
||||
@@ -724,7 +724,7 @@ async fn streamable_http_tool_call_round_trip() -> anyhow::Result<()> {
|
||||
})
|
||||
.build(&server)
|
||||
.await?;
|
||||
let session_model = fixture.session_configured.model.clone();
|
||||
let session_model = fixture.session_configured.model_family.slug.clone();
|
||||
|
||||
fixture
|
||||
.codex
|
||||
@@ -904,7 +904,7 @@ async fn streamable_http_with_oauth_round_trip() -> anyhow::Result<()> {
|
||||
})
|
||||
.build(&server)
|
||||
.await?;
|
||||
let session_model = fixture.session_configured.model.clone();
|
||||
let session_model = fixture.session_configured.model_family.slug.clone();
|
||||
|
||||
fixture
|
||||
.codex
|
||||
|
||||
@@ -64,7 +64,7 @@ async fn run_snapshot_command(command: &str) -> Result<SnapshotRun> {
|
||||
let test = harness.test();
|
||||
let codex = test.codex.clone();
|
||||
let codex_home = test.home.path().to_path_buf();
|
||||
let session_model = test.session_configured.model.clone();
|
||||
let session_model = test.session_configured.model_family.slug.clone();
|
||||
let cwd = test.cwd_path().to_path_buf();
|
||||
|
||||
codex
|
||||
@@ -140,7 +140,7 @@ async fn run_shell_command_snapshot(command: &str) -> Result<SnapshotRun> {
|
||||
let test = harness.test();
|
||||
let codex = test.codex.clone();
|
||||
let codex_home = test.home.path().to_path_buf();
|
||||
let session_model = test.session_configured.model.clone();
|
||||
let session_model = test.session_configured.model_family.slug.clone();
|
||||
let cwd = test.cwd_path().to_path_buf();
|
||||
|
||||
codex
|
||||
@@ -279,7 +279,7 @@ async fn shell_command_snapshot_still_intercepts_apply_patch() -> Result<()> {
|
||||
];
|
||||
mount_sse_sequence(harness.server(), responses).await;
|
||||
|
||||
let model = test.session_configured.model.clone();
|
||||
let model = test.session_configured.model_family.slug.clone();
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
items: vec![UserInput::Text {
|
||||
|
||||
@@ -63,7 +63,7 @@ async fn user_turn_includes_skill_instructions() -> Result<()> {
|
||||
)
|
||||
.await;
|
||||
|
||||
let session_model = test.session_configured.model.clone();
|
||||
let session_model = test.session_configured.model_family.slug.clone();
|
||||
test.codex
|
||||
.submit(Op::UserTurn {
|
||||
items: vec![
|
||||
|
||||
@@ -76,7 +76,7 @@ async fn shell_tool_executes_command_and_streams_output() -> anyhow::Result<()>
|
||||
]);
|
||||
let second_mock = responses::mount_sse_once(&server, second_response).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -142,7 +142,7 @@ async fn update_plan_tool_emits_plan_update_event() -> anyhow::Result<()> {
|
||||
]);
|
||||
let second_mock = responses::mount_sse_once(&server, second_response).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -218,7 +218,7 @@ async fn update_plan_tool_rejects_malformed_payload() -> anyhow::Result<()> {
|
||||
]);
|
||||
let second_mock = responses::mount_sse_once(&server, second_response).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -306,7 +306,7 @@ async fn apply_patch_tool_executes_and_emits_patch_events() -> anyhow::Result<()
|
||||
]);
|
||||
let second_mock = responses::mount_sse_once(&server, second_response).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -402,7 +402,7 @@ async fn apply_patch_reports_parse_diagnostics() -> anyhow::Result<()> {
|
||||
]);
|
||||
let second_mock = responses::mount_sse_once(&server, second_response).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
|
||||
@@ -32,7 +32,7 @@ use serde_json::json;
|
||||
use tokio::sync::oneshot;
|
||||
|
||||
async fn run_turn(test: &TestCodex, prompt: &str) -> anyhow::Result<()> {
|
||||
let session_model = test.session_configured.model.clone();
|
||||
let session_model = test.session_configured.model_family.slug.clone();
|
||||
|
||||
test.codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -345,7 +345,7 @@ async fn shell_tools_start_before_response_completed_when_stream_delayed() -> an
|
||||
.build_with_streaming_server(&streaming_server)
|
||||
.await?;
|
||||
|
||||
let session_model = test.session_configured.model.clone();
|
||||
let session_model = test.session_configured.model_family.slug.clone();
|
||||
test.codex
|
||||
.submit(Op::UserTurn {
|
||||
items: vec![UserInput::Text {
|
||||
|
||||
@@ -531,7 +531,7 @@ async fn mcp_image_output_preserves_image_and_no_text_summary() -> Result<()> {
|
||||
);
|
||||
});
|
||||
let fixture = builder.build(&server).await?;
|
||||
let session_model = fixture.session_configured.model.clone();
|
||||
let session_model = fixture.session_configured.model_family.slug.clone();
|
||||
|
||||
fixture
|
||||
.codex
|
||||
|
||||
@@ -194,7 +194,7 @@ async fn unified_exec_intercepts_apply_patch_exec_command() -> Result<()> {
|
||||
let test = harness.test();
|
||||
let codex = test.codex.clone();
|
||||
let cwd = test.cwd_path().to_path_buf();
|
||||
let session_model = test.session_configured.model.clone();
|
||||
let session_model = test.session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -320,7 +320,7 @@ async fn unified_exec_emits_exec_command_begin_event() -> Result<()> {
|
||||
];
|
||||
mount_sse_sequence(&server, responses).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -395,7 +395,7 @@ async fn unified_exec_resolves_relative_workdir() -> Result<()> {
|
||||
];
|
||||
mount_sse_sequence(&server, responses).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -473,7 +473,7 @@ async fn unified_exec_respects_workdir_override() -> Result<()> {
|
||||
];
|
||||
mount_sse_sequence(&server, responses).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -563,7 +563,7 @@ async fn unified_exec_emits_exec_command_end_event() -> Result<()> {
|
||||
];
|
||||
mount_sse_sequence(&server, responses).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -635,7 +635,7 @@ async fn unified_exec_emits_output_delta_for_exec_command() -> Result<()> {
|
||||
];
|
||||
mount_sse_sequence(&server, responses).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -708,7 +708,7 @@ async fn unified_exec_full_lifecycle_with_background_end_event() -> Result<()> {
|
||||
];
|
||||
mount_sse_sequence(&server, responses).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -834,7 +834,7 @@ async fn unified_exec_emits_terminal_interaction_for_write_stdin() -> Result<()>
|
||||
];
|
||||
mount_sse_sequence(&server, responses).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -967,7 +967,7 @@ async fn unified_exec_terminal_interaction_captures_delayed_output() -> Result<(
|
||||
];
|
||||
mount_sse_sequence(&server, responses).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -1124,7 +1124,7 @@ async fn unified_exec_emits_one_begin_and_one_end_event() -> Result<()> {
|
||||
];
|
||||
mount_sse_sequence(&server, responses).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -1219,7 +1219,7 @@ async fn exec_command_reports_chunk_and_exit_metadata() -> Result<()> {
|
||||
];
|
||||
mount_sse_sequence(&server, responses).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -1323,7 +1323,7 @@ async fn unified_exec_respects_early_exit_notifications() -> Result<()> {
|
||||
];
|
||||
mount_sse_sequence(&server, responses).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -1448,7 +1448,7 @@ async fn write_stdin_returns_exit_metadata_and_clears_session() -> Result<()> {
|
||||
];
|
||||
mount_sse_sequence(&server, responses).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -1610,7 +1610,7 @@ async fn unified_exec_emits_end_event_when_session_dies_via_stdin() -> Result<()
|
||||
];
|
||||
mount_sse_sequence(&server, responses).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -1684,7 +1684,7 @@ async fn unified_exec_closes_long_running_session_at_turn_end() -> Result<()> {
|
||||
];
|
||||
mount_sse_sequence(&server, responses).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -1802,7 +1802,7 @@ async fn unified_exec_reuses_session_via_stdin() -> Result<()> {
|
||||
];
|
||||
mount_sse_sequence(&server, responses).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -1931,7 +1931,7 @@ PY
|
||||
];
|
||||
mount_sse_sequence(&server, responses).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -2040,7 +2040,7 @@ async fn unified_exec_timeout_and_followup_poll() -> Result<()> {
|
||||
];
|
||||
mount_sse_sequence(&server, responses).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -2131,7 +2131,7 @@ PY
|
||||
];
|
||||
mount_sse_sequence(&server, responses).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -2207,7 +2207,7 @@ async fn unified_exec_runs_under_sandbox() -> Result<()> {
|
||||
];
|
||||
mount_sse_sequence(&server, responses).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -2306,7 +2306,7 @@ async fn unified_exec_python_prompt_under_seatbelt() -> Result<()> {
|
||||
];
|
||||
mount_sse_sequence(&server, responses).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -2396,7 +2396,7 @@ async fn unified_exec_runs_on_all_platforms() -> Result<()> {
|
||||
];
|
||||
mount_sse_sequence(&server, responses).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -2524,7 +2524,7 @@ async fn unified_exec_prunes_exited_sessions_first() -> Result<()> {
|
||||
let response_mock =
|
||||
mount_sse_sequence(&server, vec![first_response, completion_response]).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
|
||||
@@ -72,7 +72,7 @@ async fn user_turn_with_local_image_attaches_image() -> anyhow::Result<()> {
|
||||
]);
|
||||
let mock = responses::mount_sse_once(&server, response).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -163,7 +163,7 @@ async fn view_image_tool_attaches_local_image() -> anyhow::Result<()> {
|
||||
]);
|
||||
let mock = responses::mount_sse_once(&server, second_response).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -273,7 +273,7 @@ async fn view_image_tool_errors_when_path_is_directory() -> anyhow::Result<()> {
|
||||
]);
|
||||
let mock = responses::mount_sse_once(&server, second_response).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -345,7 +345,7 @@ async fn view_image_tool_placeholder_for_non_image_files() -> anyhow::Result<()>
|
||||
]);
|
||||
let mock = responses::mount_sse_once(&server, second_response).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -436,7 +436,7 @@ async fn view_image_tool_errors_when_file_missing() -> anyhow::Result<()> {
|
||||
]);
|
||||
let mock = responses::mount_sse_once(&server, second_response).await;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
@@ -517,7 +517,7 @@ async fn replaces_invalid_local_image_after_bad_request() -> anyhow::Result<()>
|
||||
let image = ImageBuffer::from_pixel(1024, 512, Rgba([10u8, 20, 30, 255]));
|
||||
image.save(&abs_path)?;
|
||||
|
||||
let session_model = session_configured.model.clone();
|
||||
let session_model = session_configured.model_family.slug.clone();
|
||||
|
||||
codex
|
||||
.submit(Op::UserTurn {
|
||||
|
||||
Reference in New Issue
Block a user