mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Pin request reasoning effort while configuration overrides are active (#43795)
## Why Reasoning-effort changes should preserve the request baseline while trusted `configuration_update` items carry the selected effort. ## What changed - Pin request-level reasoning effort for the current model when reasoning-effort overrides are available, including during WebSocket prewarm. - Re-establish the selected effort after rollback, resume, or a model switch, refreshing the trusted override even when the selection is unchanged. - Continue using the selected request effort when overrides are unavailable. ## Testing Add regression coverage for WebSocket prewarm and reconnect, rollback, resume, and model switches. Update transition tests to assert that request-level effort stays pinned while configuration updates change. GitOrigin-RevId: 89cfee6289543230347b0488d1388190b4da7216
This commit is contained in:
1 parent
df522cae16
commit
31ccaf40c2
7 files changed
+504
-14
No files matched your search
@@ -9,6 +9,7 @@ pub(crate) use additional_context::AdditionalContextStore;
|
||||
pub(crate) use auto_compact_window::AutoCompactWindowIds;
|
||||
pub(crate) use auto_compact_window::AutoCompactWindowSnapshot;
|
||||
pub(crate) use service::SessionServices;
|
||||
pub(crate) use session::ReasoningEffortPin;
|
||||
pub(crate) use session::SessionState;
|
||||
pub(crate) use turn::AcceptedUserInputResponse;
|
||||
pub(crate) use turn::ActiveTurn;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
use codex_protocol::models::AdditionalPermissionProfile;
|
||||
use codex_protocol::models::BaseInstructionsProvenance;
|
||||
use codex_protocol::models::ResponseItem;
|
||||
use codex_protocol::openai_models::ReasoningEffort;
|
||||
use codex_sandboxing::policy_transforms::merge_permission_profiles;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::HashSet;
|
||||
@@ -29,6 +30,38 @@ use codex_protocol::protocol::TurnContextItem;
|
||||
use codex_utils_output_truncation::TruncationPolicy;
|
||||
use tokio_util::task::AbortOnDropHandle;
|
||||
|
||||
/// Runtime request effort; startup and replay must re-establish the selected effort.
|
||||
pub(crate) enum ReasoningEffortPin {
|
||||
Unset,
|
||||
Active {
|
||||
model: String,
|
||||
effort: ReasoningEffort,
|
||||
},
|
||||
}
|
||||
|
||||
impl ReasoningEffortPin {
|
||||
pub(crate) fn get(&self, model: &str) -> Option<ReasoningEffort> {
|
||||
match self {
|
||||
Self::Active {
|
||||
model: pinned_model,
|
||||
effort,
|
||||
} if pinned_model == model => Some(effort.clone()),
|
||||
Self::Unset | Self::Active { .. } => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn pin(&mut self, model: &str, effort: ReasoningEffort) -> ReasoningEffort {
|
||||
if let Some(pinned) = self.get(model) {
|
||||
return pinned;
|
||||
}
|
||||
*self = Self::Active {
|
||||
model: model.to_owned(),
|
||||
effort: effort.clone(),
|
||||
};
|
||||
effort
|
||||
}
|
||||
}
|
||||
|
||||
/// Persistent, session-scoped state previously stored directly on `Session`.
|
||||
pub(crate) struct SessionState {
|
||||
pub(crate) session_configuration: SessionConfiguration,
|
||||
@@ -46,6 +79,8 @@ pub(crate) struct SessionState {
|
||||
previous_turn_settings: Option<PreviousTurnSettings>,
|
||||
/// Runtime accounting state for the active auto-compaction window.
|
||||
auto_compact_window: AutoCompactWindow,
|
||||
/// Original request effort for the current model while configuration updates remain active.
|
||||
pub(crate) reasoning_effort_pin: ReasoningEffortPin,
|
||||
/// Startup prewarmed session prepared during session initialization.
|
||||
pub(crate) startup_prewarm: Option<SessionStartupPrewarmHandle>,
|
||||
/// Retained after completion so later turns do not repeat speculative captures.
|
||||
@@ -84,6 +119,7 @@ impl SessionState {
|
||||
additional_context: AdditionalContextStore::default(),
|
||||
previous_turn_settings: None,
|
||||
auto_compact_window: AutoCompactWindow::new_with_ids(auto_compact_window_ids),
|
||||
reasoning_effort_pin: ReasoningEffortPin::Unset,
|
||||
startup_prewarm: None,
|
||||
shell_snapshot_prewarm: None,
|
||||
current_time_reminder: CurrentTimeReminderState::default(),
|
||||
|
||||
Reference in new issue
Block a user