mirror of
https://github.com/openai/codex.git
synced 2026-06-01 19:02:59 +00:00
Make app tool hint defaults pessimistic for app policies (#17232)
## Summary - default missing app tool destructive/open-world hints to true for app policies - add regression tests for missing MCP annotations under restrictive app config
This commit is contained in:
@@ -680,10 +680,10 @@ fn app_tool_policy_from_apps_config(
|
||||
});
|
||||
let destructive_hint = annotations
|
||||
.and_then(|annotations| annotations.destructive_hint)
|
||||
.unwrap_or(false);
|
||||
.unwrap_or(true);
|
||||
let open_world_hint = annotations
|
||||
.and_then(|annotations| annotations.open_world_hint)
|
||||
.unwrap_or(false);
|
||||
.unwrap_or(true);
|
||||
let enabled =
|
||||
(destructive_enabled || !destructive_hint) && (open_world_enabled || !open_world_hint);
|
||||
|
||||
|
||||
@@ -390,6 +390,62 @@ fn app_tool_policy_uses_global_defaults_for_destructive_hints() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn app_tool_policy_defaults_missing_destructive_hint_to_true() {
|
||||
let apps_config = AppsConfigToml {
|
||||
default: Some(AppsDefaultConfig {
|
||||
enabled: true,
|
||||
destructive_enabled: false,
|
||||
open_world_enabled: true,
|
||||
}),
|
||||
apps: HashMap::new(),
|
||||
};
|
||||
|
||||
let policy = app_tool_policy_from_apps_config(
|
||||
Some(&apps_config),
|
||||
Some("calendar"),
|
||||
"events/create",
|
||||
/*tool_title*/ None,
|
||||
Some(&annotations(/*destructive_hint*/ None, Some(false))),
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
policy,
|
||||
AppToolPolicy {
|
||||
enabled: false,
|
||||
approval: AppToolApproval::Auto,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn app_tool_policy_defaults_missing_open_world_hint_to_true() {
|
||||
let apps_config = AppsConfigToml {
|
||||
default: Some(AppsDefaultConfig {
|
||||
enabled: true,
|
||||
destructive_enabled: true,
|
||||
open_world_enabled: false,
|
||||
}),
|
||||
apps: HashMap::new(),
|
||||
};
|
||||
|
||||
let policy = app_tool_policy_from_apps_config(
|
||||
Some(&apps_config),
|
||||
Some("calendar"),
|
||||
"events/create",
|
||||
/*tool_title*/ None,
|
||||
Some(&annotations(Some(false), /*open_world_hint*/ None)),
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
policy,
|
||||
AppToolPolicy {
|
||||
enabled: false,
|
||||
approval: AppToolApproval::Auto,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn app_is_enabled_uses_default_for_unconfigured_apps() {
|
||||
let apps_config = AppsConfigToml {
|
||||
|
||||
Reference in New Issue
Block a user