mirror of
https://github.com/openai/codex.git
synced 2026-11-13 14:46:14 +00:00
Read approval policy from the current turn configuration (#36912)
## Why Thread settings can update the approval policy after a turn context is created. Keeping a separate copy on `TurnContext` could leave tool approval checks using the previous policy. ## What changed - Remove the duplicated approval-policy field from `TurnContext`. - Resolve the policy through the turn's current configuration everywhere it is needed, including tool execution, Guardian routing, MCP handling, and permission requests. ## Testing - Update the shell escalation test to apply a thread-level policy override and verify that the next turn rejects an escalation using the updated policy. GitOrigin-RevId: e5966ba08f179d53fd76871ad904762958c0f5ea
This commit is contained in:
1 parent
ee46c5ba0e
commit
6a828ca26f
25 files changed
+119
-89
No files matched your search
@@ -136,7 +136,6 @@ pub struct TurnContext {
|
||||
pub(crate) collaboration_mode_developer_instructions: Option<String>,
|
||||
pub(crate) multi_agent_version: MultiAgentVersion,
|
||||
pub(crate) personality: Option<Personality>,
|
||||
pub(crate) approval_policy: Constrained<AskForApproval>,
|
||||
pub(crate) permission_profile: PermissionProfile,
|
||||
pub(crate) network: Option<NetworkProxy>,
|
||||
pub(crate) windows_sandbox_level: WindowsSandboxLevel,
|
||||
@@ -186,6 +185,10 @@ impl TurnContext {
|
||||
.resolve_attribution(command, cwd)
|
||||
}
|
||||
|
||||
pub(crate) fn approval_policy(&self) -> AskForApproval {
|
||||
self.config.permissions.approval_policy.value()
|
||||
}
|
||||
|
||||
pub(crate) fn permission_profile(&self) -> PermissionProfile {
|
||||
self.permission_profile.clone()
|
||||
}
|
||||
@@ -310,7 +313,6 @@ impl TurnContext {
|
||||
.clone(),
|
||||
multi_agent_version: self.multi_agent_version,
|
||||
personality: self.personality,
|
||||
approval_policy: self.approval_policy.clone(),
|
||||
permission_profile: self.permission_profile.clone(),
|
||||
network: self.network.clone(),
|
||||
windows_sandbox_level: self.windows_sandbox_level,
|
||||
@@ -380,7 +382,7 @@ impl TurnContext {
|
||||
workspace_roots: (!workspace_roots.is_empty()).then_some(workspace_roots),
|
||||
current_date: self.current_date.clone(),
|
||||
timezone: self.timezone.clone(),
|
||||
approval_policy: self.approval_policy.value(),
|
||||
approval_policy: self.approval_policy(),
|
||||
approvals_reviewer: Some(self.config.approvals_reviewer),
|
||||
sandbox_policy: self.sandbox_policy(),
|
||||
permission_profile: Some(self.permission_profile()),
|
||||
@@ -579,7 +581,6 @@ impl Session {
|
||||
.clone(),
|
||||
multi_agent_version,
|
||||
personality: session_configuration.personality,
|
||||
approval_policy: session_configuration.approval_policy.clone(),
|
||||
permission_profile,
|
||||
network,
|
||||
windows_sandbox_level: session_configuration.windows_sandbox_level,
|
||||
|
||||
Reference in new issue
Block a user