mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Preserve selected reasoning effort for synchronous Guardian reviews (#46292)
## Why Synchronous Guardian reviewers need to use their selected request-level reasoning effort even when managed requirements enable `reasoning_effort_override` and the parent history contains effort updates. ## What changed Disable reasoning-effort overrides for synchronous Guardian sessions and use the same decision for request filtering, effort pinning, and update injection. Reviewers omit inherited configuration updates from requests without changing saved history or appending new effort updates. ## Testing Add regression coverage for both current and legacy Guardian session sources with managed overrides enabled. Verify that the parent retains its pinned effort, reviewer requests follow selected `low` and `high` efforts, and inherited updates remain in saved history. GitOrigin-RevId: 3a635dbdc613ea72f7a96fc96bb386e4ac7994c3
This commit is contained in:
1 parent
47915cee7a
commit
93321c88d8
4 files changed
+168
-14
No files matched your search
@@ -494,6 +494,10 @@ impl ModelClient {
|
||||
let auth_env_telemetry =
|
||||
collect_auth_env_telemetry(model_provider.info(), codex_api_key_env_enabled);
|
||||
let include_attestation = model_provider.supports_attestation();
|
||||
// Reviewers use their own request-level effort even when managed requirements
|
||||
// pin the parent's feature on. Share this decision with update injection and pinning.
|
||||
let reasoning_effort_override_enabled = reasoning_effort_override_enabled
|
||||
&& !crate::guardian::is_basic_session_source(&session_source);
|
||||
Self {
|
||||
state: Arc::new(ModelClientState {
|
||||
thread_id,
|
||||
@@ -524,6 +528,10 @@ impl ModelClient {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn reasoning_effort_override_enabled(&self) -> bool {
|
||||
self.state.reasoning_effort_override_enabled
|
||||
}
|
||||
|
||||
pub(crate) fn with_restored_history(mut self, restored_history: bool) -> Self {
|
||||
self.restored_history = restored_history;
|
||||
self
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
//! Only trusted harness items establish overrides. Replay preserves startup prewarm's
|
||||
//! 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.
|
||||
|
||||
use super::session::Session;
|
||||
use super::step_context::StepContext;
|
||||
use super::step_settings::ResolvedStepSettings;
|
||||
use crate::state::ReasoningEffortPin;
|
||||
use codex_features::Feature;
|
||||
use codex_history::CodexHarnessMetadata;
|
||||
use codex_history::ResponseItemEnvelope;
|
||||
use codex_protocol::models::ConfigurationReasoning;
|
||||
@@ -96,7 +96,11 @@ impl Session {
|
||||
usage: RequestEffortUsage,
|
||||
) -> Option<ReasoningEffort> {
|
||||
let selected_effort = settings.reasoning_effort().cloned();
|
||||
if !self.enabled(Feature::ReasoningEffortOverride) {
|
||||
if !self
|
||||
.services
|
||||
.model_client
|
||||
.reasoning_effort_override_enabled()
|
||||
{
|
||||
return selected_effort;
|
||||
}
|
||||
if usage == RequestEffortUsage::Compaction
|
||||
@@ -130,7 +134,10 @@ impl Session {
|
||||
&self,
|
||||
settings: &ResolvedStepSettings,
|
||||
) -> Option<ReasoningEffort> {
|
||||
if !self.enabled(Feature::ReasoningEffortOverride)
|
||||
if !self
|
||||
.services
|
||||
.model_client
|
||||
.reasoning_effort_override_enabled()
|
||||
|| !settings.model_info.use_responses_lite
|
||||
|| !self.provider().await.is_openai()
|
||||
{
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
|
||||
use super::RequestEffortUsage;
|
||||
use crate::session::step_settings::ResolvedStepSettings;
|
||||
use crate::session::tests::make_session_and_context;
|
||||
use crate::session::tests::make_session_and_context_with_auth_and_config_and_rx;
|
||||
use codex_features::Feature;
|
||||
use codex_history::InitialHistory;
|
||||
use codex_history::ResumedHistory;
|
||||
use codex_login::CodexAuth;
|
||||
use codex_protocol::ThreadId;
|
||||
use codex_protocol::openai_models::ReasoningEffort;
|
||||
use pretty_assertions::assert_eq;
|
||||
@@ -20,11 +21,17 @@ use test_case::test_case;
|
||||
}); "resume")]
|
||||
#[tokio::test]
|
||||
async fn initial_replay_preserves_prewarmed_effort(history: InitialHistory) {
|
||||
let (mut session, turn_context) = make_session_and_context().await;
|
||||
session
|
||||
.features
|
||||
.enable(Feature::ReasoningEffortOverride)
|
||||
.unwrap();
|
||||
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();
|
||||
},
|
||||
)
|
||||
.await;
|
||||
let mut model_info = Arc::clone(&turn_context.initial_settings.model_info);
|
||||
Arc::make_mut(&mut model_info).use_responses_lite = true;
|
||||
let mut selected = turn_context.initial_settings.selected().clone();
|
||||
@@ -59,11 +66,17 @@ async fn initial_replay_preserves_prewarmed_effort(history: InitialHistory) {
|
||||
|
||||
#[tokio::test]
|
||||
async fn compaction_effort_lookup_preserves_pin_for_fallback_models() {
|
||||
let (mut session, turn_context) = make_session_and_context().await;
|
||||
session
|
||||
.features
|
||||
.enable(Feature::ReasoningEffortOverride)
|
||||
.unwrap();
|
||||
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();
|
||||
},
|
||||
)
|
||||
.await;
|
||||
session
|
||||
.state
|
||||
.lock()
|
||||
|
||||
Reference in new issue
Block a user