Format dangerous bypass SDK updates

This commit is contained in:
Ahmed Ibrahim
2026-05-15 19:48:25 -07:00
parent 2eb61fa741
commit 3cc8e7b30f
3 changed files with 7 additions and 21 deletions

View File

@@ -872,9 +872,7 @@ def _approval_mode_thread_sandbox_line(*, indent: str = " ") -> str:
return f"{indent}sandbox = _thread_sandbox_for_approval_mode(approval_mode, sandbox)"
def _approval_mode_turn_sandbox_policy_lines(
*, indent: str = " "
) -> list[str]:
def _approval_mode_turn_sandbox_policy_lines(*, indent: str = " ") -> list[str]:
"""Return the approval-mode sandbox preset for turn operations."""
return [
f"{indent}sandbox_policy = _turn_sandbox_policy_for_approval_mode(",

View File

@@ -69,9 +69,7 @@ def _thread_sandbox_for_approval_mode(
if approval_mode is not ApprovalMode.dangerously_bypass_approvals_and_sandbox:
return sandbox
if sandbox is not None:
raise ValueError(
"dangerous bypass approval_mode cannot be combined with sandbox"
)
raise ValueError("dangerous bypass approval_mode cannot be combined with sandbox")
return SandboxMode.danger_full_access
@@ -83,12 +81,8 @@ def _turn_sandbox_policy_for_approval_mode(
if approval_mode is not ApprovalMode.dangerously_bypass_approvals_and_sandbox:
return sandbox_policy
if sandbox_policy is not None:
raise ValueError(
"dangerous bypass approval_mode cannot be combined with sandbox_policy"
)
return SandboxPolicy(
root=DangerFullAccessSandboxPolicy(type="dangerFullAccess")
)
raise ValueError("dangerous bypass approval_mode cannot be combined with sandbox_policy")
return SandboxPolicy(root=DangerFullAccessSandboxPolicy(type="dangerFullAccess"))
class Codex:

View File

@@ -25,9 +25,7 @@ from openai_codex.generated.v2_all import (
ThreadResumeParams,
)
DANGER_FULL_ACCESS_SANDBOX_POLICY_TYPE = DangerFullAccessSandboxPolicy(
type="dangerFullAccess"
).type
DANGER_FULL_ACCESS_SANDBOX_POLICY_TYPE = DangerFullAccessSandboxPolicy(type="dangerFullAccess").type
def test_thread_resume_inherits_deny_all_approval_mode(tmp_path) -> None:
@@ -215,9 +213,7 @@ def test_async_turn_dangerous_bypass_persists_thread_settings(tmp_path) -> None:
)
async with AsyncCodex(config=harness.app_server_config()) as codex:
thread = await codex.thread_start(
approval_mode=ApprovalMode.auto_review
)
thread = await codex.thread_start(approval_mode=ApprovalMode.auto_review)
result = await thread.run(
"bypass this async turn",
approval_mode=ApprovalMode.dangerously_bypass_approvals_and_sandbox,
@@ -346,9 +342,7 @@ def test_dangerous_bypass_rejects_explicit_sandbox_conflicts_before_state_change
thread.run(
"this should never reach app-server",
approval_mode=ApprovalMode.dangerously_bypass_approvals_and_sandbox,
sandbox_policy=SandboxPolicy(
root=ReadOnlySandboxPolicy(type="readOnly")
),
sandbox_policy=SandboxPolicy(root=ReadOnlySandboxPolicy(type="readOnly")),
)
thread_state = thread.read(include_turns=True)