mirror of
https://github.com/openai/codex.git
synced 2026-11-16 06:54:36 +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
@@ -34,6 +34,7 @@ pub(crate) use approval_request::GuardianMcpAnnotations;
|
||||
pub(crate) use approval_request::GuardianNetworkAccessTrigger;
|
||||
#[cfg(test)]
|
||||
pub(crate) use approval_request::guardian_approval_request_to_json;
|
||||
pub(crate) use prompt::BUNDLED_GUARDIAN_POLICY;
|
||||
pub(crate) use prompt::guardian_truncate_text;
|
||||
pub(crate) use review::GuardianReviewOptions;
|
||||
pub(crate) use review::guardian_timeout_message;
|
||||
|
||||
@@ -816,7 +816,7 @@ For anything else, use this JSON schema:
|
||||
}"#
|
||||
}
|
||||
|
||||
pub(super) const BUNDLED_GUARDIAN_POLICY: &str = include_str!("policy.md");
|
||||
pub(crate) const BUNDLED_GUARDIAN_POLICY: &str = include_str!("policy.md");
|
||||
pub(super) const BUNDLED_GUARDIAN_POLICY_TEMPLATE: &str = include_str!("policy_template.md");
|
||||
const TENANT_POLICY_CONFIG_PLACEHOLDER: &str = "{{ tenant_policy_config }}";
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ use super::ApprovalRequestReasons;
|
||||
use super::GUARDIAN_REVIEWER_NAME;
|
||||
use super::GuardianApprovalRequest;
|
||||
use super::GuardianReviewContext;
|
||||
#[cfg(test)]
|
||||
use super::prompt::BUNDLED_GUARDIAN_POLICY;
|
||||
use super::prompt::BUNDLED_GUARDIAN_POLICY_TEMPLATE;
|
||||
use super::prompt::GuardianPromptMode;
|
||||
@@ -1290,11 +1291,7 @@ pub(crate) fn build_guardian_review_session_config(
|
||||
guardian_config.memories.use_memories = false;
|
||||
guardian_config.memories.dedicated_tools = false;
|
||||
let catalog_auto_review = model_messages.and_then(|messages| messages.auto_review.as_ref());
|
||||
let tenant_policy_config = parent_config
|
||||
.guardian_policy_config
|
||||
.as_deref()
|
||||
.or_else(|| catalog_auto_review.and_then(|messages| messages.policy.as_deref()))
|
||||
.unwrap_or(BUNDLED_GUARDIAN_POLICY);
|
||||
let tenant_policy_config = parent_config.resolve_guardian_policy(model_messages);
|
||||
let policy_template = catalog_auto_review
|
||||
.and_then(|messages| messages.policy_template.as_deref())
|
||||
.unwrap_or(BUNDLED_GUARDIAN_POLICY_TEMPLATE);
|
||||
|
||||
Reference in new issue
Block a user