mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Read turn permissions from the current configuration (#36930)
## What changed - Remove the cached permission profile from `TurnContext` and derive the effective profile, filesystem policy, network policy, and legacy sandbox policy from `config.permissions`. - Update sandbox consumers and tests to use the current turn configuration. - Verify that role-based agent spawning reapplies runtime permissions and that cold-resumed agents retain their disabled permission profile. GitOrigin-RevId: d67c5d2bcbe6dc76f15b56defb485b155fd1f138
This commit is contained in:
1 parent
7ada37a15e
commit
90314a9207
14 files changed
+67
-40
No files matched your search
@@ -2262,12 +2262,20 @@ async fn spawn_agent_reapplies_runtime_sandbox_after_role_config() {
|
||||
.expect("approval policy should be set");
|
||||
let mut config = (*turn.config).clone();
|
||||
config.approvals_reviewer = ApprovalsReviewer::AutoReview;
|
||||
config
|
||||
.permissions
|
||||
.set_permission_profile(expected_permission_profile.clone())
|
||||
.expect("test setup should allow updating permission profile");
|
||||
set_turn_config(&mut turn, config);
|
||||
turn.permission_profile = expected_permission_profile.clone();
|
||||
let role_name = install_role_with_model_override(&mut turn).await;
|
||||
let mut role_config = (*turn.config).clone();
|
||||
crate::agent::role::apply_role_to_config(&mut role_config, Some(role_name.as_str()))
|
||||
.await
|
||||
.expect("non-empty role config should apply");
|
||||
assert_ne!(
|
||||
role_config.permissions.effective_permission_profile(),
|
||||
expected_permission_profile,
|
||||
turn.config.permissions.effective_permission_profile(),
|
||||
"test requires a runtime profile override that differs from base config"
|
||||
"role config must discard the runtime permission override before it is reapplied"
|
||||
);
|
||||
|
||||
let invocation = invocation(
|
||||
@@ -2276,7 +2284,7 @@ async fn spawn_agent_reapplies_runtime_sandbox_after_role_config() {
|
||||
"spawn_agent",
|
||||
function_payload(json!({
|
||||
"message": "await this command",
|
||||
"agent_type": "explorer"
|
||||
"agent_type": role_name
|
||||
})),
|
||||
);
|
||||
let output = SpawnAgentHandler::default()
|
||||
@@ -4438,7 +4446,10 @@ async fn build_agent_spawn_config_uses_turn_context_values() {
|
||||
&file_system_sandbox_policy,
|
||||
network_sandbox_policy,
|
||||
);
|
||||
turn.permission_profile = permission_profile.clone();
|
||||
Arc::make_mut(&mut turn.config)
|
||||
.permissions
|
||||
.set_permission_profile(permission_profile)
|
||||
.expect("permission profile set");
|
||||
Arc::make_mut(&mut turn.config)
|
||||
.permissions
|
||||
.approval_policy
|
||||
@@ -4464,7 +4475,7 @@ async fn build_agent_spawn_config_uses_turn_context_values() {
|
||||
.expect("approval policy set");
|
||||
expected
|
||||
.permissions
|
||||
.set_permission_profile(permission_profile)
|
||||
.set_permission_profile(turn.permission_profile())
|
||||
.expect("permission profile set");
|
||||
assert_eq!(config, expected);
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ impl ExecCommandHandler {
|
||||
// permissions config below. Consult the configured platform-sandbox requirement before
|
||||
// deciding whether parsing may continue without that base path.
|
||||
let sandbox = SandboxManager::new().select_initial(
|
||||
&turn.permission_profile,
|
||||
&turn.permission_profile(),
|
||||
SandboxablePreference::Auto,
|
||||
turn.windows_sandbox_level,
|
||||
turn.network.is_some(),
|
||||
|
||||
@@ -316,7 +316,10 @@ mod tests {
|
||||
replace_primary_environment_cwd(&mut turn, image_cwd.clone());
|
||||
let image_path = image_cwd.join("image.png");
|
||||
std::fs::write(image_path.as_path(), b"not a real image").expect("write test image");
|
||||
turn.permission_profile = PermissionProfile::read_only();
|
||||
Arc::make_mut(&mut turn.config)
|
||||
.permissions
|
||||
.set_permission_profile(PermissionProfile::read_only())
|
||||
.expect("test setup should allow updating permission profile");
|
||||
let turn = Arc::new(turn);
|
||||
|
||||
let result = ViewImageHandler::default()
|
||||
|
||||
Reference in new issue
Block a user