Update guardian output schema (#17061)

## Summary
- Update guardian output schema to separate risk, authorization,
outcome, and rationale.
- Feed guardian rationale into rejection messages.
- Split the guardian policy into template and tenant-config sections.

## Validation
- `cargo test -p codex-core mcp_tool_call`
- `env -u CODEX_SANDBOX_NETWORK_DISABLED INSTA_UPDATE=always cargo test
-p codex-core guardian::`

---------

Co-authored-by: Owen Lin <owen@openai.com>
This commit is contained in:
maja-openai
2026-04-08 15:47:29 -07:00
committed by GitHub
co-authored by Owen Lin
parent 49677ec71f
commit dcbc91fd39
45 changed files with 673 additions and 312 deletions
+10 -8
View File
@@ -254,8 +254,11 @@ pub struct Config {
/// Developer instructions override injected as a separate message.
pub developer_instructions: Option<String>,
/// Guardian-specific developer instructions override from requirements.toml.
pub guardian_developer_instructions: Option<String>,
/// Guardian-specific tenant policy config override from requirements.toml.
/// This is inserted into the fixed guardian prompt template under the
/// `# Policy Configuration` section rather than replacing the whole
/// guardian developer prompt.
pub guardian_policy_config: Option<String>,
/// Whether to inject the `<permissions instructions>` developer block.
pub include_permissions_instructions: bool,
@@ -1840,9 +1843,8 @@ impl Config {
.include_environment_context
.or(cfg.include_environment_context)
.unwrap_or(true);
let guardian_developer_instructions = guardian_developer_instructions_from_requirements(
config_layer_stack.requirements_toml(),
);
let guardian_policy_config =
guardian_policy_config_from_requirements(config_layer_stack.requirements_toml());
let personality = personality
.or(config_profile.personality)
.or(cfg.personality)
@@ -2065,7 +2067,7 @@ impl Config {
.show_raw_agent_reasoning
.or(show_raw_agent_reasoning)
.unwrap_or(false),
guardian_developer_instructions,
guardian_policy_config,
model_reasoning_effort: config_profile
.model_reasoning_effort
.or(cfg.model_reasoning_effort),
@@ -2273,11 +2275,11 @@ pub(crate) fn uses_deprecated_instructions_file(config_layer_stack: &ConfigLayer
.any(|layer| toml_uses_deprecated_instructions_file(&layer.config))
}
fn guardian_developer_instructions_from_requirements(
fn guardian_policy_config_from_requirements(
requirements_toml: &ConfigRequirementsToml,
) -> Option<String> {
requirements_toml
.guardian_developer_instructions
.guardian_policy_config
.as_deref()
.and_then(|value| {
let trimmed = value.trim();