Interrupt cyber model turns after one Guardian denial (#37190)

## What changed

- Add a Guardian circuit-breaker policy for models whose catalog specialty is
  `cyber`.
- Interrupt those models after the first Guardian denial while retaining the
  existing denial thresholds for other models.
- Centralize the `cyber` model-specialty identifier for use across core,
  protocol, app-server, and TUI code.

## Testing

- Cover the cyber-specific threshold in the circuit-breaker unit tests.
- Verify end to end that a denied command is not executed and the turn is
  interrupted after one denial.

GitOrigin-RevId: fad24c9e7aa280432580db1f0e39d13535779710
This commit is contained in:
andrewgu-oai authored and copyberry committed 2026-08-06 00:37:46 +00:00
1 parent 92b83e226d
commit f141dc77f0
9 files changed
+200 -23

No files matched your search

+5 -4
View File
@@ -106,6 +106,7 @@ use codex_protocol::models::ActivePermissionProfile;
use codex_protocol::models::FileSystemPermissions;
use codex_protocol::models::NetworkPermissions;
use codex_protocol::models::PermissionProfile;
use codex_protocol::openai_models::MODEL_SPECIALTY_CYBER;
use codex_protocol::protocol::EventMsg;
use codex_protocol::protocol::MAX_THREAD_GOAL_OBJECTIVE_CHARS;
use codex_protocol::protocol::MultiAgentVersion;
@@ -7248,7 +7249,7 @@ async fn selecting_cyber_model_defaults_active_thread_to_auto_review() {
.into_iter()
.find(|model| model.model == "gpt-5.4")
.expect("gpt-5.4 model");
model.model_specialty = Some("cyber".to_string());
model.model_specialty = Some(MODEL_SPECIALTY_CYBER.to_string());
app.model_catalog = Arc::new(ModelCatalog::new(vec![model]));
let mut app_server =
@@ -7311,7 +7312,7 @@ async fn changing_cyber_model_reasoning_preserves_selected_permissions() {
.into_iter()
.find(|model| model.model == model_name)
.expect("current model");
model.model_specialty = Some("cyber".to_string());
model.model_specialty = Some(MODEL_SPECIALTY_CYBER.to_string());
app.model_catalog = Arc::new(ModelCatalog::new(vec![model]));
assert!(
@@ -7414,7 +7415,7 @@ async fn selecting_cyber_model_falls_back_to_user_when_auto_review_is_unavailabl
.into_iter()
.find(|model| model.model == "gpt-5.4")
.expect("gpt-5.4 model");
model.model_specialty = Some("cyber".to_string());
model.model_specialty = Some(MODEL_SPECIALTY_CYBER.to_string());
app.model_catalog = Arc::new(ModelCatalog::new(vec![model]));
let _ = app.config.features.disable(Feature::GuardianApproval);
app.chat_widget
@@ -7469,7 +7470,7 @@ async fn selecting_cyber_model_respects_auto_review_requirements() {
.into_iter()
.find(|model| model.model == "gpt-5.4")
.expect("gpt-5.4 model");
model.model_specialty = Some("cyber".to_string());
model.model_specialty = Some(MODEL_SPECIALTY_CYBER.to_string());
app.model_catalog = Arc::new(ModelCatalog::new(vec![model]));
let mut app_server =
+3 -1
View File
@@ -15,6 +15,7 @@ use codex_protocol::ThreadId;
use codex_protocol::config_types::ModeKind;
use codex_protocol::models::BUILT_IN_PERMISSION_PROFILE_WORKSPACE;
use codex_protocol::models::PermissionProfile;
use codex_protocol::openai_models::MODEL_SPECIALTY_CYBER;
impl App {
pub(super) async fn sync_active_thread_model_setting(
@@ -50,7 +51,8 @@ impl App {
let thread_id = self.active_thread_id?;
let is_cyber_model = self.model_catalog.try_list_models().is_ok_and(|models| {
models.iter().any(|preset| {
preset.model == model && preset.model_specialty.as_deref() == Some("cyber")
preset.model == model
&& preset.model_specialty.as_deref() == Some(MODEL_SPECIALTY_CYBER)
})
});