mirror of
https://github.com/openai/codex.git
synced 2026-11-19 22:30:42 +00:00
Enable Guardian V2 scoring with an explicit Guardian provider (#62607)
## Why An explicit Guardian provider could handle approval reviews, but configuring it disabled Guardian V2 scoring. This prevented automatic reviews from using background scores from that provider. ## What changed Route classification through the configured Guardian provider and use its classifier catalog for instructions, reasoning effort, review thresholds, and input limits. Apply the Guardian provider's API-key access policy to classifier requests and ignore assessments from the actor's response stream when a Guardian provider is configured. Keep mandatory review requirements in force and skip background scoring in User approval mode and Full Access. ## Testing Extend coverage for separate actor and Guardian providers at startup and after cold resume, including when both use the same model name. Cover catalog settings, scoring restrictions, and provider-specific API-key policy. GitOrigin-RevId: 5f83d1704bacc63033e144bba0d78752283cb590
This commit is contained in:
@@ -39,12 +39,22 @@ pub enum ApiKeyCyberAccessPrograms {
|
||||
impl ApiKeyCyberAccessPrograms {
|
||||
/// Captures the same provider and feature policy used by ordinary model requests.
|
||||
pub fn from_config(config: &crate::config::Config) -> Self {
|
||||
if !config
|
||||
.model_provider
|
||||
.supports_cyber_access_programs(&config.model_provider_id)
|
||||
{
|
||||
Self::for_provider(
|
||||
&config.model_provider,
|
||||
&config.model_provider_id,
|
||||
&config.features,
|
||||
)
|
||||
}
|
||||
|
||||
/// Resolves API-key policy for the provider that will receive the request.
|
||||
pub fn for_provider(
|
||||
provider: &codex_model_provider_info::ModelProviderInfo,
|
||||
provider_id: &str,
|
||||
features: &codex_features::Features,
|
||||
) -> Self {
|
||||
if !provider.supports_cyber_access_programs(provider_id) {
|
||||
Self::UnsupportedProvider
|
||||
} else if config.features.enabled(Feature::ApiKeyCyberAccessPrograms) {
|
||||
} else if features.enabled(Feature::ApiKeyCyberAccessPrograms) {
|
||||
Self::Enabled
|
||||
} else {
|
||||
Self::Disabled
|
||||
|
||||
@@ -3159,6 +3159,7 @@ async fn try_run_sampling_request(
|
||||
let mut pending_assessment: Option<codex_api::GuardianAssessment> = None;
|
||||
let mut response_completed = false;
|
||||
let mut includes_reasoning = step_context.settings.model_info.use_responses_lite;
|
||||
let accept_actor_assessments = turn_context.config.guardian_model_provider.is_none();
|
||||
let mut resampling = crate::guardian::ResponseResampling::new(&sess);
|
||||
let prompt = Arc::new(prompt);
|
||||
let interrupt_at_boundary = SamplingInterrupt::enabled(&turn_context);
|
||||
@@ -3701,7 +3702,10 @@ async fn try_run_sampling_request(
|
||||
.await;
|
||||
}
|
||||
ResponseEvent::GuardianAssessment(assessment) => {
|
||||
if response_id_for_assessment.as_deref() == Some(assessment.response_id.as_str()) {
|
||||
if accept_actor_assessments
|
||||
&& response_id_for_assessment.as_deref()
|
||||
== Some(assessment.response_id.as_str())
|
||||
{
|
||||
pending_assessment = Some(assessment);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user