mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
Preserve requested approval reviewers across policy overrides (#59272)
## Why A model requirement can force `auto_review` even when the requested reviewer is `user`. Persisting or sending that effective value back as an explicit choice loses the original selection, so removing the requirement cannot restore it on resume. ## What changed - Retain `requested_approvals_reviewer` separately from the effective reviewer in configuration and thread settings, with a fallback for older histories. - Restore the requested reviewer on resume while applying current model requirements and reviewer allowlists. - Let ordinary TUI turns, continuations, retries, and forks inherit the server's reviewer instead of echoing its effective value as an explicit request. - Preserve a worker's requested reviewer when reloading it rather than inheriting the sender's selection. ## Testing Extend resume coverage for explicit `auto_review`, removal of a model requirement, and a tightened reviewer allowlist. Update TUI assertions for omitted reviewer overrides and verify worker reload preserves its reviewer. GitOrigin-RevId: d8c9c3a7b89e55e63f0e8ae210d6a87cb5547933
This commit is contained in:
@@ -798,6 +798,9 @@ impl Session {
|
||||
"No models are available. Set `model` explicitly or check your model catalog configuration.".to_string(),
|
||||
));
|
||||
}
|
||||
let requested_approvals_reviewer = config
|
||||
.requested_approvals_reviewer
|
||||
.unwrap_or(config.approvals_reviewer);
|
||||
let trusted_guardian_reviewer = crate::guardian::is_basic_session_source(&session_source)
|
||||
&& !matches!(conversation_history, InitialHistory::Resumed(_));
|
||||
if config
|
||||
@@ -824,13 +827,17 @@ impl Session {
|
||||
);
|
||||
}
|
||||
}
|
||||
config
|
||||
.config_layer_stack
|
||||
.requirements()
|
||||
.approvals_reviewer
|
||||
.can_set(&ApprovalsReviewer::AutoReview)
|
||||
.map_err(|err| CodexErr::InvalidRequest(err.to_string()))?;
|
||||
config.approvals_reviewer = ApprovalsReviewer::AutoReview;
|
||||
}
|
||||
let reviewer = crate::config::resolve_guardian_reviewer(
|
||||
requested_approvals_reviewer,
|
||||
(!trusted_guardian_reviewer).then_some(model.as_str()),
|
||||
config.config_layer_stack.requirements(),
|
||||
)
|
||||
.map_err(|err| CodexErr::InvalidRequest(err.to_string()))?;
|
||||
{
|
||||
let config = Arc::make_mut(&mut config);
|
||||
config.requested_approvals_reviewer = Some(requested_approvals_reviewer);
|
||||
config.approvals_reviewer = reviewer;
|
||||
}
|
||||
if allow_provider_model_fallback
|
||||
&& let Some(requested_model) = config.model.as_ref()
|
||||
|
||||
@@ -336,6 +336,9 @@ impl SessionConfiguration {
|
||||
service_tier: self.step_settings.service_tier.clone(),
|
||||
approval_policy: self.step_settings.approval_policy.value(),
|
||||
approvals_reviewer: self.step_settings.approvals_reviewer,
|
||||
requested_approvals_reviewer: self
|
||||
.original_config_do_not_use
|
||||
.requested_approvals_reviewer,
|
||||
permission_profile: self.materialized_permission_profile(environment_selections),
|
||||
active_permission_profile: self.active_permission_profile(),
|
||||
cwd: self.legacy_fallback_cwd.clone(),
|
||||
@@ -369,6 +372,9 @@ impl SessionConfiguration {
|
||||
),
|
||||
approval_policy: Some(self.step_settings.approval_policy.value()),
|
||||
approvals_reviewer: Some(self.step_settings.approvals_reviewer),
|
||||
requested_approvals_reviewer: self
|
||||
.original_config_do_not_use
|
||||
.requested_approvals_reviewer,
|
||||
permission_profile: Some(self.permission_profile()),
|
||||
active_permission_profile: self.active_permission_profile(),
|
||||
windows_sandbox_level: Some(self.windows_sandbox_level),
|
||||
@@ -575,6 +581,17 @@ impl SessionConfiguration {
|
||||
&updates.step_settings,
|
||||
&next_configuration.step_settings_constraints(next_environments),
|
||||
)?);
|
||||
if let Some(reviewer) = updates
|
||||
.requested_approvals_reviewer
|
||||
.or(updates.step_settings.approvals_reviewer)
|
||||
&& next_configuration
|
||||
.original_config_do_not_use
|
||||
.requested_approvals_reviewer
|
||||
!= Some(reviewer)
|
||||
{
|
||||
Arc::make_mut(&mut next_configuration.original_config_do_not_use)
|
||||
.requested_approvals_reviewer = Some(reviewer);
|
||||
}
|
||||
Ok(next_configuration)
|
||||
}
|
||||
|
||||
@@ -624,6 +641,7 @@ pub(crate) struct SessionSettingsCommit {
|
||||
#[derive(Default, Clone)]
|
||||
pub(crate) struct SessionSettingsUpdate {
|
||||
pub(crate) step_settings: StepSettingsUpdate,
|
||||
pub(crate) requested_approvals_reviewer: Option<ApprovalsReviewer>,
|
||||
/// Omission preserves the current data; an empty initializer clears it.
|
||||
pub(crate) turn_extension_init: Option<ExtensionDataInit>,
|
||||
pub(crate) environments: Option<TurnEnvironmentSelections>,
|
||||
|
||||
Reference in New Issue
Block a user