mirror of
https://github.com/openai/codex.git
synced 2026-11-24 23:20:47 +00:00
Gate reasoning effort updates on explicit model support (#46530)
## Why Using Responses Lite does not establish whether a model accepts reasoning-effort `configuration_update` items. Unsupported models need to use the selected request-level effort, including when resuming history containing saved updates. ## What changed - Add `supports_reasoning_effort_updates` model metadata, defaulting to `false`. - Require the override feature, an OpenAI provider, and explicit model support for reasoning effort updates, independently of `use_responses_lite`. - Filter saved configuration updates from unsupported requests without changing persisted history. - Clear the pinned effort baseline when sampling with an unsupported model so returning to a supported model establishes a fresh baseline. Compaction uses the selected effort without clearing the pin. ## Testing Add coverage for supported models with either Responses mode, unsupported-model history filtering over HTTP and WebSocket, switching to an unsupported model and back, and compaction versus sampling pin behavior. Verify missing capability metadata defaults to `false`. GitOrigin-RevId: 8a0fbc141964bd854dbcdd6f31e1c8e97697cf22
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
//! baseline while it is retained.
|
||||
//! Successful compaction retires the overrides and allows a fresh request baseline.
|
||||
//! Synchronous Guardian reviewers always use their selected request-level effort.
|
||||
//! Unsupported models use selected request effort without rewriting saved updates.
|
||||
|
||||
use super::session::Session;
|
||||
use super::step_context::StepContext;
|
||||
@@ -26,7 +27,7 @@ impl Session {
|
||||
/// Establishes the selected effort in surviving history, independent of replayed settings.
|
||||
pub(crate) async fn record_reasoning_effort_override(&self, step_context: &StepContext) {
|
||||
let settings = &step_context.settings;
|
||||
let Some(effort) = self.effort_for_configuration_update(settings).await else {
|
||||
let Some(effort) = self.effort_for_configuration_update(settings) else {
|
||||
return;
|
||||
};
|
||||
let should_skip = {
|
||||
@@ -99,8 +100,11 @@ impl Session {
|
||||
if !self
|
||||
.services
|
||||
.model_client
|
||||
.reasoning_effort_override_enabled()
|
||||
.reasoning_effort_override_enabled(&settings.model_info)
|
||||
{
|
||||
if usage == RequestEffortUsage::Sampling {
|
||||
self.state.lock().await.reasoning_effort_pin = ReasoningEffortPin::Unset;
|
||||
}
|
||||
return selected_effort;
|
||||
}
|
||||
if usage == RequestEffortUsage::Compaction
|
||||
@@ -113,7 +117,7 @@ impl Session {
|
||||
{
|
||||
return Some(pinned);
|
||||
}
|
||||
let effort = self.effort_for_configuration_update(settings).await;
|
||||
let effort = self.effort_for_configuration_update(settings);
|
||||
let mut state = self.state.lock().await;
|
||||
let Some(effort) = effort else {
|
||||
if usage == RequestEffortUsage::Sampling {
|
||||
@@ -130,16 +134,14 @@ impl Session {
|
||||
})
|
||||
}
|
||||
|
||||
async fn effort_for_configuration_update(
|
||||
fn effort_for_configuration_update(
|
||||
&self,
|
||||
settings: &ResolvedStepSettings,
|
||||
) -> Option<ReasoningEffort> {
|
||||
if !self
|
||||
.services
|
||||
.model_client
|
||||
.reasoning_effort_override_enabled()
|
||||
|| !settings.model_info.use_responses_lite
|
||||
|| !self.provider().await.is_openai()
|
||||
.reasoning_effort_override_enabled(&settings.model_info)
|
||||
{
|
||||
return None;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ async fn initial_replay_preserves_prewarmed_effort(history: InitialHistory) {
|
||||
)
|
||||
.await;
|
||||
let mut model_info = Arc::clone(&turn_context.initial_settings.model_info);
|
||||
Arc::make_mut(&mut model_info).use_responses_lite = true;
|
||||
Arc::make_mut(&mut model_info).supports_reasoning_effort_updates = true;
|
||||
let mut selected = turn_context.initial_settings.selected().clone();
|
||||
selected.collaboration_mode.settings.reasoning_effort = Some(ReasoningEffort::Medium);
|
||||
let prewarm_settings = ResolvedStepSettings::new(
|
||||
@@ -87,7 +87,7 @@ async fn compaction_effort_lookup_preserves_pin_for_fallback_models() {
|
||||
let effort = ReasoningEffort::Medium;
|
||||
let model = Arc::make_mut(&mut settings.model_info);
|
||||
model.slug = "fallback".to_string();
|
||||
model.use_responses_lite = true;
|
||||
model.supports_reasoning_effort_updates = true;
|
||||
model.default_reasoning_level = Some(effort.clone());
|
||||
|
||||
assert_eq!(
|
||||
@@ -106,3 +106,57 @@ async fn compaction_effort_lookup_preserves_pin_for_fallback_models() {
|
||||
Some(ReasoningEffort::Low)
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn unsupported_model_compaction_uses_selected_effort_without_mutating_pin() {
|
||||
let (session, turn_context, _events) = make_session_and_context_with_auth_and_config_and_rx(
|
||||
CodexAuth::from_api_key("Test API Key"),
|
||||
Vec::new(),
|
||||
|config| {
|
||||
config
|
||||
.features
|
||||
.enable(Feature::ReasoningEffortOverride)
|
||||
.unwrap();
|
||||
config.model_reasoning_effort = Some(ReasoningEffort::High);
|
||||
},
|
||||
)
|
||||
.await;
|
||||
let mut settings = (*turn_context.initial_settings).clone();
|
||||
Arc::make_mut(&mut settings.model_info).supports_reasoning_effort_updates = false;
|
||||
session
|
||||
.state
|
||||
.lock()
|
||||
.await
|
||||
.reasoning_effort_pin
|
||||
.pin(&settings.model_info.slug, ReasoningEffort::Low);
|
||||
|
||||
assert_eq!(
|
||||
session
|
||||
.reasoning_effort_for_request(&settings, RequestEffortUsage::Compaction)
|
||||
.await,
|
||||
Some(ReasoningEffort::High),
|
||||
);
|
||||
assert_eq!(
|
||||
session
|
||||
.state
|
||||
.lock()
|
||||
.await
|
||||
.reasoning_effort_pin
|
||||
.get(&settings.model_info.slug),
|
||||
Some(ReasoningEffort::Low),
|
||||
);
|
||||
// Sampling retires the old baseline, so a later supported request starts afresh.
|
||||
assert_eq!(
|
||||
session
|
||||
.reasoning_effort_for_request(&settings, RequestEffortUsage::Sampling)
|
||||
.await,
|
||||
Some(ReasoningEffort::High),
|
||||
);
|
||||
Arc::make_mut(&mut settings.model_info).supports_reasoning_effort_updates = true;
|
||||
assert_eq!(
|
||||
session
|
||||
.reasoning_effort_for_request(&settings, RequestEffortUsage::Sampling)
|
||||
.await,
|
||||
Some(ReasoningEffort::High),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user