feat(core): allow guardian prompt overrides from model metadata#13915
feat(core): allow guardian prompt overrides from model metadata#13915charley-oai wants to merge 1 commit into
Conversation
|
@codex review this |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
05060d9 to
04f5f35
Compare
a759c69 to
7c09e3b
Compare
Co-authored-by: Codex <noreply@openai.com>
7c09e3b to
c5fdd79
Compare
|
Orb Code Review (powered by GLM-4.7 on Orb Cloud) SummaryThis PR introduces the ability to override guardian prompts from model metadata, allowing different models to have custom guardian instructions instead of using a single hardcoded prompt. The implementation adds a new ArchitectureNew Component:
pub struct ModelInfo {
// ... existing fields
#[serde(default, skip_serializing_if = "Option::is_none")]
pub guardian_developer_instructions: Option<String>,
// ... more fields
}
fn guardian_policy_prompt(prompt_override: Option<&str>) -> String {
let prompt = prompt_override
.unwrap_or(include_str!("guardian_prompt.md"))
.trim_end();
format!("{prompt}\n\n{}", guardian_output_contract_prompt())
}
let guardian_model_info = session
.services
.models_manager
.get_model_info(&guardian_model, turn.config.as_ref())
.await;
let guardian_config = build_guardian_subagent_config(
// ... other params
guardian_model_info
.guardian_developer_instructions
.as_deref(),
)?;AnalysisCorrectness ✓The feature implementation:
Override logic: let prompt = prompt_override
.unwrap_or(include_str!("guardian_prompt.md"))
.trim_end();This correctly implements preference for model-specific prompts while maintaining backward compatibility. Code Quality ✓Minimal and focused changes:
Good use of Rust idioms:
Testing ✓Comprehensive test coverage:
#[test]
fn guardian_subagent_config_prefers_model_prompt_override() {
let guardian_config = build_guardian_subagent_config(
&test_config(),
None,
"active-model",
None,
Some("override prompt"),
)
.expect("guardian config");
let instructions = guardian_config
.developer_instructions
.expect("guardian instructions");
assert!(instructions.starts_with("override prompt"));
assert!(instructions.contains("\"risk_level\": \"low\" | \"medium\" | \"high\""));
}
Backward Compatibility ✓Preserves existing behavior:
Why
Security
|
Summary
Testing