mirror of
https://github.com/openai/codex.git
synced 2026-11-22 15:15:18 +00:00
Apply Guardian policies to v2 risk classification (#38618)
## What changed - Include the resolved Guardian security policy in the v2 classifier's developer instructions. - Prefer an explicit `guardian_policy_config`, then the reviewer model's catalog policy, and finally the bundled policy. - Limit the combined classifier instructions and policy to 10,000 tokens. ## Testing - Cover configured and catalog policies, policy truncation, and the bundled-policy fallback. GitOrigin-RevId: 1b84d70081dd924e214636b4b470d57a63d7cb88
This commit is contained in:
1 parent
086396f7f6
commit
14a6813fa8
6 files changed
+201
-30
No files matched your search
@@ -1,5 +1,6 @@
|
||||
use crate::config::edit::ConfigEdit;
|
||||
use crate::config::edit::ConfigEditsBuilder;
|
||||
use crate::guardian::BUNDLED_GUARDIAN_POLICY;
|
||||
use crate::path_utils::normalize_for_native_workdir;
|
||||
use crate::unified_exec::DEFAULT_MAX_BACKGROUND_TERMINAL_TIMEOUT_MS;
|
||||
use crate::unified_exec::MIN_EMPTY_YIELD_TIME_MS;
|
||||
@@ -106,6 +107,7 @@ use codex_protocol::models::ActivePermissionProfile;
|
||||
use codex_protocol::models::BaseInstructionsProvenance;
|
||||
use codex_protocol::models::PermissionProfile;
|
||||
use codex_protocol::models::SandboxEnforcement;
|
||||
use codex_protocol::openai_models::ModelMessages;
|
||||
use codex_protocol::openai_models::ModelsResponse;
|
||||
use codex_protocol::openai_models::ReasoningEffort;
|
||||
use codex_protocol::permissions::FileSystemSandboxPolicy;
|
||||
@@ -1520,6 +1522,21 @@ impl Config {
|
||||
&self.sqlite
|
||||
}
|
||||
|
||||
/// Resolves the configured, reviewer-catalog, or bundled Guardian policy.
|
||||
pub fn resolve_guardian_policy<'a>(
|
||||
&'a self,
|
||||
model_messages: Option<&'a ModelMessages>,
|
||||
) -> &'a str {
|
||||
self.guardian_policy_config
|
||||
.as_deref()
|
||||
.or_else(|| {
|
||||
model_messages
|
||||
.and_then(|messages| messages.auto_review.as_ref())
|
||||
.and_then(|messages| messages.policy.as_deref())
|
||||
})
|
||||
.unwrap_or(BUNDLED_GUARDIAN_POLICY)
|
||||
}
|
||||
|
||||
pub(crate) fn multi_agent_version_override(&self) -> Option<MultiAgentVersion> {
|
||||
if self.features.enabled(Feature::MultiAgentV2) {
|
||||
Some(MultiAgentVersion::V2)
|
||||
|
||||
Reference in new issue
Block a user