Preserve reasoning effort through compaction and reset it on success (#43796)

## Why

With reasoning effort overrides enabled, compaction used the selected effort even when sampling requests still used an earlier pinned effort. Successful compaction also left that old pin active in the new context window.

## What changed

- Use the pinned request effort for local and remote compaction when it matches the model.
- Resolve fallback models' effort without mutating the live pin, preserving it if compaction fails.
- Reset the pin after successful compaction so the next sampling request establishes the selected effort as its baseline without a redundant `configuration_update`.

## Testing

Add regression coverage for remote compaction success and failure, fallback model effort selection, pin preservation during fallback lookup, and compaction after resuming with overrides disabled.

GitOrigin-RevId: 35e666b0c8026553500715ddbe7bef02cd759f4a
This commit is contained in:
felixxia-oai authored and copyberry committed 2026-09-08 10:46:07 +00:00
1 parent 31ccaf40c2
commit 35d9e4bc4d
11 files changed
+598 -18

No files matched your search

+6 -1
View File
@@ -17,6 +17,7 @@ use crate::responses_metadata::CodexResponsesRequestKind;
use crate::responses_metadata::CompactionTurnMetadata;
#[cfg(test)]
use crate::session::PreviousTurnSettings;
use crate::session::RequestEffortUsage;
use crate::session::session::Session;
use crate::session::step_context::StepContext;
use crate::session::turn::get_last_assistant_message_from_turn;
@@ -771,7 +772,11 @@ async fn drain_to_completed(
prompt,
turn_context.model_info(),
&turn_context.session_telemetry,
turn_context.reasoning_effort().cloned(),
sess.reasoning_effort_for_request(
&turn_context.initial_settings,
RequestEffortUsage::Compaction,
)
.await,
turn_context.reasoning_summary(),
turn_context.config.service_tier.clone(),
responses_metadata,