mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +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
@@ -108,7 +108,7 @@ async fn run_exec_like(args: RunExecLikeArgs) -> Result<FunctionToolOutput, Func
|
||||
|| {
|
||||
normalize_and_validate_additional_permissions(
|
||||
additional_permissions_allowed,
|
||||
turn.approval_policy.value(),
|
||||
turn.approval_policy(),
|
||||
effective_additional_permissions.sandbox_permissions,
|
||||
effective_additional_permissions.additional_permissions,
|
||||
effective_additional_permissions.permissions_preapproved,
|
||||
@@ -127,11 +127,11 @@ async fn run_exec_like(args: RunExecLikeArgs) -> Result<FunctionToolOutput, Func
|
||||
.requests_sandbox_override()
|
||||
&& !effective_additional_permissions.permissions_preapproved
|
||||
&& !matches!(
|
||||
turn.approval_policy.value(),
|
||||
turn.approval_policy(),
|
||||
codex_protocol::protocol::AskForApproval::OnRequest
|
||||
)
|
||||
{
|
||||
let approval_policy = turn.approval_policy.value();
|
||||
let approval_policy = turn.approval_policy();
|
||||
return Err(FunctionCallError::RespondToModel(format!(
|
||||
"approval policy is {approval_policy:?}; reject command — you should not ask for escalated permissions if the approval policy is {approval_policy:?}"
|
||||
)));
|
||||
@@ -177,7 +177,7 @@ async fn run_exec_like(args: RunExecLikeArgs) -> Result<FunctionToolOutput, Func
|
||||
.exec_policy
|
||||
.create_exec_approval_requirement_for_command(ExecApprovalRequest {
|
||||
command: &exec_params.command,
|
||||
approval_policy: turn.approval_policy.value(),
|
||||
approval_policy: turn.approval_policy(),
|
||||
permission_profile: turn.permission_profile(),
|
||||
windows_sandbox_level: turn.windows_sandbox_level,
|
||||
sandbox_permissions: if effective_additional_permissions.permissions_preapproved {
|
||||
@@ -217,13 +217,7 @@ async fn run_exec_like(args: RunExecLikeArgs) -> Result<FunctionToolOutput, Func
|
||||
tool_name,
|
||||
};
|
||||
let out = orchestrator
|
||||
.run(
|
||||
&mut runtime,
|
||||
&req,
|
||||
&tool_ctx,
|
||||
&turn,
|
||||
turn.approval_policy.value(),
|
||||
)
|
||||
.run(&mut runtime, &req, &tool_ctx, &turn, turn.approval_policy())
|
||||
.await
|
||||
.map(|result| result.output);
|
||||
let event_ctx = ToolEventCtx::new(
|
||||
|
||||
Reference in new issue
Block a user