From c339b8970c0f1f5f360c423407dc52d2958c9539 Mon Sep 17 00:00:00 2001 From: Dylan Hurd Date: Mon, 15 Jun 2026 17:37:42 -0700 Subject: [PATCH 1/6] chore(core) rm AskForApproval::OnFailure --- .../analytics/src/analytics_client_tests.rs | 4 +- codex-rs/analytics/src/client_tests.rs | 6 +- .../schema/json/ClientRequest.json | 1 - .../schema/json/ServerNotification.json | 1 - .../codex_app_server_protocol.schemas.json | 1 - .../codex_app_server_protocol.v2.schemas.json | 1 - .../schema/json/v2/ConfigReadResponse.json | 1 - .../v2/ConfigRequirementsReadResponse.json | 1 - .../schema/json/v2/ThreadForkParams.json | 1 - .../schema/json/v2/ThreadForkResponse.json | 1 - .../schema/json/v2/ThreadResumeParams.json | 1 - .../schema/json/v2/ThreadResumeResponse.json | 1 - .../v2/ThreadSettingsUpdatedNotification.json | 1 - .../schema/json/v2/ThreadStartParams.json | 1 - .../schema/json/v2/ThreadStartResponse.json | 1 - .../schema/json/v2/TurnStartParams.json | 1 - .../schema/typescript/v2/AskForApproval.ts | 2 +- .../src/protocol/common.rs | 4 +- .../src/protocol/v2/shared.rs | 3 - .../src/protocol/v2/tests.rs | 4 +- .../codex-mcp/src/connection_manager_tests.rs | 23 ++-- codex-rs/codex-mcp/src/elicitation.rs | 1 - codex-rs/codex-mcp/src/mcp/mod_tests.rs | 3 +- codex-rs/config/src/config_requirements.rs | 11 -- codex-rs/config/src/state_tests.rs | 8 +- codex-rs/core/config.schema.json | 7 -- codex-rs/core/gpt_5_1_prompt.md | 2 +- codex-rs/core/gpt_5_2_prompt.md | 2 +- .../prompt_with_apply_patch_instructions.md | 2 +- .../core/src/config/config_loader_tests.rs | 10 +- codex-rs/core/src/config/config_tests.rs | 4 +- codex-rs/core/src/exec_policy.rs | 6 +- codex-rs/core/src/hook_runtime.rs | 7 +- codex-rs/core/src/mcp_tool_call.rs | 6 +- codex-rs/core/src/mcp_tool_call_tests.rs | 1 - codex-rs/core/src/safety.rs | 9 +- codex-rs/core/src/session/mod.rs | 3 +- codex-rs/core/src/session/session.rs | 9 -- codex-rs/core/src/session/tests.rs | 6 +- .../core/src/session/tests/guardian_tests.rs | 4 +- .../core/src/tools/network_approval_tests.rs | 1 - .../core/src/tools/runtimes/apply_patch.rs | 1 - codex-rs/core/src/tools/sandboxing.rs | 5 +- codex-rs/core/tests/suite/approvals.rs | 101 +----------------- codex-rs/core/tests/suite/hooks.rs | 67 +----------- codex-rs/mcp-server/src/codex_tool_config.rs | 7 +- codex-rs/models-manager/models.json | 2 +- codex-rs/models-manager/prompt.md | 2 +- .../prompts/src/permissions_instructions.rs | 3 - .../src/permissions_instructions_tests.rs | 20 ---- .../permissions/approval_policy/on_failure.md | 1 - .../src/prompts/base_instructions/default.md | 2 +- codex-rs/protocol/src/protocol.rs | 8 -- .../utils/cli/src/approval_mode_cli_arg.rs | 7 -- 54 files changed, 57 insertions(+), 331 deletions(-) delete mode 100644 codex-rs/prompts/templates/permissions/approval_policy/on_failure.md diff --git a/codex-rs/analytics/src/analytics_client_tests.rs b/codex-rs/analytics/src/analytics_client_tests.rs index 091a85e11fdb..bf11cba1e977 100644 --- a/codex-rs/analytics/src/analytics_client_tests.rs +++ b/codex-rs/analytics/src/analytics_client_tests.rs @@ -219,7 +219,7 @@ fn sample_thread_start_response( cwd: test_path_buf("/tmp").abs(), runtime_workspace_roots: Vec::new(), instruction_sources: Vec::new(), - approval_policy: AppServerAskForApproval::OnFailure, + approval_policy: AppServerAskForApproval::OnRequest, approvals_reviewer: AppServerApprovalsReviewer::User, sandbox: AppServerSandboxPolicy::DangerFullAccess, active_permission_profile: None, @@ -284,7 +284,7 @@ fn sample_thread_resume_response_with_source( cwd: test_path_buf("/tmp").abs(), runtime_workspace_roots: Vec::new(), instruction_sources: Vec::new(), - approval_policy: AppServerAskForApproval::OnFailure, + approval_policy: AppServerAskForApproval::OnRequest, approvals_reviewer: AppServerApprovalsReviewer::User, sandbox: AppServerSandboxPolicy::DangerFullAccess, active_permission_profile: None, diff --git a/codex-rs/analytics/src/client_tests.rs b/codex-rs/analytics/src/client_tests.rs index a14fe7bf2d50..ce455ce5bb79 100644 --- a/codex-rs/analytics/src/client_tests.rs +++ b/codex-rs/analytics/src/client_tests.rs @@ -309,7 +309,7 @@ fn sample_thread_start_response() -> ClientResponsePayload { cwd: test_path_buf("/tmp").abs(), runtime_workspace_roots: Vec::new(), instruction_sources: Vec::new(), - approval_policy: AppServerAskForApproval::OnFailure, + approval_policy: AppServerAskForApproval::OnRequest, approvals_reviewer: AppServerApprovalsReviewer::User, sandbox: AppServerSandboxPolicy::DangerFullAccess, active_permission_profile: None, @@ -327,7 +327,7 @@ fn sample_thread_resume_response() -> ClientResponsePayload { cwd: test_path_buf("/tmp").abs(), runtime_workspace_roots: Vec::new(), instruction_sources: Vec::new(), - approval_policy: AppServerAskForApproval::OnFailure, + approval_policy: AppServerAskForApproval::OnRequest, approvals_reviewer: AppServerApprovalsReviewer::User, sandbox: AppServerSandboxPolicy::DangerFullAccess, active_permission_profile: None, @@ -346,7 +346,7 @@ fn sample_thread_fork_response() -> ClientResponsePayload { cwd: test_path_buf("/tmp").abs(), runtime_workspace_roots: Vec::new(), instruction_sources: Vec::new(), - approval_policy: AppServerAskForApproval::OnFailure, + approval_policy: AppServerAskForApproval::OnRequest, approvals_reviewer: AppServerApprovalsReviewer::User, sandbox: AppServerSandboxPolicy::DangerFullAccess, active_permission_profile: None, diff --git a/codex-rs/app-server-protocol/schema/json/ClientRequest.json b/codex-rs/app-server-protocol/schema/json/ClientRequest.json index 28597eff6254..490161486a0c 100644 --- a/codex-rs/app-server-protocol/schema/json/ClientRequest.json +++ b/codex-rs/app-server-protocol/schema/json/ClientRequest.json @@ -125,7 +125,6 @@ { "enum": [ "untrusted", - "on-failure", "on-request", "never" ], diff --git a/codex-rs/app-server-protocol/schema/json/ServerNotification.json b/codex-rs/app-server-protocol/schema/json/ServerNotification.json index b79e3cb13fac..5bd0794c5e0d 100644 --- a/codex-rs/app-server-protocol/schema/json/ServerNotification.json +++ b/codex-rs/app-server-protocol/schema/json/ServerNotification.json @@ -450,7 +450,6 @@ { "enum": [ "untrusted", - "on-failure", "on-request", "never" ], diff --git a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json index 597fd5a1b820..4c52bb8d84cf 100644 --- a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json +++ b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json @@ -6864,7 +6864,6 @@ { "enum": [ "untrusted", - "on-failure", "on-request", "never" ], diff --git a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json index 3af48cc6c075..e5d938bc953c 100644 --- a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json +++ b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json @@ -990,7 +990,6 @@ { "enum": [ "untrusted", - "on-failure", "on-request", "never" ], diff --git a/codex-rs/app-server-protocol/schema/json/v2/ConfigReadResponse.json b/codex-rs/app-server-protocol/schema/json/v2/ConfigReadResponse.json index ef2411534ddf..16f836341656 100644 --- a/codex-rs/app-server-protocol/schema/json/v2/ConfigReadResponse.json +++ b/codex-rs/app-server-protocol/schema/json/v2/ConfigReadResponse.json @@ -173,7 +173,6 @@ { "enum": [ "untrusted", - "on-failure", "on-request", "never" ], diff --git a/codex-rs/app-server-protocol/schema/json/v2/ConfigRequirementsReadResponse.json b/codex-rs/app-server-protocol/schema/json/v2/ConfigRequirementsReadResponse.json index edbb7f0bcda5..3fe6a8978762 100644 --- a/codex-rs/app-server-protocol/schema/json/v2/ConfigRequirementsReadResponse.json +++ b/codex-rs/app-server-protocol/schema/json/v2/ConfigRequirementsReadResponse.json @@ -15,7 +15,6 @@ { "enum": [ "untrusted", - "on-failure", "on-request", "never" ], diff --git a/codex-rs/app-server-protocol/schema/json/v2/ThreadForkParams.json b/codex-rs/app-server-protocol/schema/json/v2/ThreadForkParams.json index e72522a26a94..ad0174cfe084 100644 --- a/codex-rs/app-server-protocol/schema/json/v2/ThreadForkParams.json +++ b/codex-rs/app-server-protocol/schema/json/v2/ThreadForkParams.json @@ -19,7 +19,6 @@ { "enum": [ "untrusted", - "on-failure", "on-request", "never" ], diff --git a/codex-rs/app-server-protocol/schema/json/v2/ThreadForkResponse.json b/codex-rs/app-server-protocol/schema/json/v2/ThreadForkResponse.json index c19251667a38..da82e79307d4 100644 --- a/codex-rs/app-server-protocol/schema/json/v2/ThreadForkResponse.json +++ b/codex-rs/app-server-protocol/schema/json/v2/ThreadForkResponse.json @@ -42,7 +42,6 @@ { "enum": [ "untrusted", - "on-failure", "on-request", "never" ], diff --git a/codex-rs/app-server-protocol/schema/json/v2/ThreadResumeParams.json b/codex-rs/app-server-protocol/schema/json/v2/ThreadResumeParams.json index bc9cb524d686..af078af68ef2 100644 --- a/codex-rs/app-server-protocol/schema/json/v2/ThreadResumeParams.json +++ b/codex-rs/app-server-protocol/schema/json/v2/ThreadResumeParams.json @@ -63,7 +63,6 @@ { "enum": [ "untrusted", - "on-failure", "on-request", "never" ], diff --git a/codex-rs/app-server-protocol/schema/json/v2/ThreadResumeResponse.json b/codex-rs/app-server-protocol/schema/json/v2/ThreadResumeResponse.json index 1a3b22f12cbf..10881b9e1dc1 100644 --- a/codex-rs/app-server-protocol/schema/json/v2/ThreadResumeResponse.json +++ b/codex-rs/app-server-protocol/schema/json/v2/ThreadResumeResponse.json @@ -42,7 +42,6 @@ { "enum": [ "untrusted", - "on-failure", "on-request", "never" ], diff --git a/codex-rs/app-server-protocol/schema/json/v2/ThreadSettingsUpdatedNotification.json b/codex-rs/app-server-protocol/schema/json/v2/ThreadSettingsUpdatedNotification.json index ca2b63634aa4..8d528246b524 100644 --- a/codex-rs/app-server-protocol/schema/json/v2/ThreadSettingsUpdatedNotification.json +++ b/codex-rs/app-server-protocol/schema/json/v2/ThreadSettingsUpdatedNotification.json @@ -39,7 +39,6 @@ { "enum": [ "untrusted", - "on-failure", "on-request", "never" ], diff --git a/codex-rs/app-server-protocol/schema/json/v2/ThreadStartParams.json b/codex-rs/app-server-protocol/schema/json/v2/ThreadStartParams.json index 9932456f1b55..70a87727517b 100644 --- a/codex-rs/app-server-protocol/schema/json/v2/ThreadStartParams.json +++ b/codex-rs/app-server-protocol/schema/json/v2/ThreadStartParams.json @@ -19,7 +19,6 @@ { "enum": [ "untrusted", - "on-failure", "on-request", "never" ], diff --git a/codex-rs/app-server-protocol/schema/json/v2/ThreadStartResponse.json b/codex-rs/app-server-protocol/schema/json/v2/ThreadStartResponse.json index a754c6bc0f3c..7bc3c9fa9d82 100644 --- a/codex-rs/app-server-protocol/schema/json/v2/ThreadStartResponse.json +++ b/codex-rs/app-server-protocol/schema/json/v2/ThreadStartResponse.json @@ -42,7 +42,6 @@ { "enum": [ "untrusted", - "on-failure", "on-request", "never" ], diff --git a/codex-rs/app-server-protocol/schema/json/v2/TurnStartParams.json b/codex-rs/app-server-protocol/schema/json/v2/TurnStartParams.json index bec8b7d89a0d..36b4d2a15d82 100644 --- a/codex-rs/app-server-protocol/schema/json/v2/TurnStartParams.json +++ b/codex-rs/app-server-protocol/schema/json/v2/TurnStartParams.json @@ -41,7 +41,6 @@ { "enum": [ "untrusted", - "on-failure", "on-request", "never" ], diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/AskForApproval.ts b/codex-rs/app-server-protocol/schema/typescript/v2/AskForApproval.ts index 8d41214e013b..1d605501b2a3 100644 --- a/codex-rs/app-server-protocol/schema/typescript/v2/AskForApproval.ts +++ b/codex-rs/app-server-protocol/schema/typescript/v2/AskForApproval.ts @@ -2,4 +2,4 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export type AskForApproval = "untrusted" | "on-failure" | "on-request" | { "granular": { sandbox_approval: boolean, rules: boolean, skill_approval: boolean, request_permissions: boolean, mcp_elicitations: boolean, } } | "never"; +export type AskForApproval = "untrusted" | "on-request" | { "granular": { sandbox_approval: boolean, rules: boolean, skill_approval: boolean, request_permissions: boolean, mcp_elicitations: boolean, } } | "never"; diff --git a/codex-rs/app-server-protocol/src/protocol/common.rs b/codex-rs/app-server-protocol/src/protocol/common.rs index ba63f59e9a53..5ee6ec25a4c4 100644 --- a/codex-rs/app-server-protocol/src/protocol/common.rs +++ b/codex-rs/app-server-protocol/src/protocol/common.rs @@ -2604,7 +2604,7 @@ mod tests { "/tmp/AGENTS.md", )), ], - approval_policy: v2::AskForApproval::OnFailure, + approval_policy: v2::AskForApproval::OnRequest, approvals_reviewer: v2::ApprovalsReviewer::User, sandbox: v2::SandboxPolicy::DangerFullAccess, active_permission_profile: None, @@ -2651,7 +2651,7 @@ mod tests { "cwd": absolute_path_string("tmp"), "runtimeWorkspaceRoots": [], "instructionSources": [absolute_path_string("tmp/AGENTS.md")], - "approvalPolicy": "on-failure", + "approvalPolicy": "on-request", "approvalsReviewer": "user", "sandbox": { "type": "dangerFullAccess" diff --git a/codex-rs/app-server-protocol/src/protocol/v2/shared.rs b/codex-rs/app-server-protocol/src/protocol/v2/shared.rs index cb881d626726..94e650d923f9 100644 --- a/codex-rs/app-server-protocol/src/protocol/v2/shared.rs +++ b/codex-rs/app-server-protocol/src/protocol/v2/shared.rs @@ -163,7 +163,6 @@ pub enum AskForApproval { #[serde(rename = "untrusted")] #[ts(rename = "untrusted")] UnlessTrusted, - OnFailure, OnRequest, #[experimental("askForApproval.granular")] Granular { @@ -182,7 +181,6 @@ impl AskForApproval { pub fn to_core(self) -> CoreAskForApproval { match self { AskForApproval::UnlessTrusted => CoreAskForApproval::UnlessTrusted, - AskForApproval::OnFailure => CoreAskForApproval::OnFailure, AskForApproval::OnRequest => CoreAskForApproval::OnRequest, AskForApproval::Granular { sandbox_approval, @@ -206,7 +204,6 @@ impl From for AskForApproval { fn from(value: CoreAskForApproval) -> Self { match value { CoreAskForApproval::UnlessTrusted => AskForApproval::UnlessTrusted, - CoreAskForApproval::OnFailure => AskForApproval::OnFailure, CoreAskForApproval::OnRequest => AskForApproval::OnRequest, CoreAskForApproval::Granular(granular_config) => AskForApproval::Granular { sandbox_approval: granular_config.sandbox_approval, diff --git a/codex-rs/app-server-protocol/src/protocol/v2/tests.rs b/codex-rs/app-server-protocol/src/protocol/v2/tests.rs index ba69b6d6e2fb..533e775e6ea9 100644 --- a/codex-rs/app-server-protocol/src/protocol/v2/tests.rs +++ b/codex-rs/app-server-protocol/src/protocol/v2/tests.rs @@ -195,7 +195,7 @@ fn thread_resume_response_round_trips_initial_turns_page() { cwd: absolute_path("tmp"), runtime_workspace_roots: Vec::new(), instruction_sources: Vec::new(), - approval_policy: AskForApproval::OnFailure, + approval_policy: AskForApproval::OnRequest, approvals_reviewer: ApprovalsReviewer::User, sandbox: SandboxPolicy::DangerFullAccess, active_permission_profile: None, @@ -3689,7 +3689,7 @@ fn thread_lifecycle_responses_default_missing_optional_fields() { "modelProvider": "openai", "serviceTier": null, "cwd": absolute_path_string("tmp"), - "approvalPolicy": "on-failure", + "approvalPolicy": "on-request", "approvalsReviewer": "user", "sandbox": { "type": "dangerFullAccess" }, "reasoningEffort": null diff --git a/codex-rs/codex-mcp/src/connection_manager_tests.rs b/codex-rs/codex-mcp/src/connection_manager_tests.rs index 887a9b3d4674..47e8cbdd058a 100644 --- a/codex-rs/codex-mcp/src/connection_manager_tests.rs +++ b/codex-rs/codex-mcp/src/connection_manager_tests.rs @@ -205,9 +205,6 @@ fn tool_with_model_visible_input_schema_leaves_tools_without_file_params_unchang #[test] fn elicitation_granular_policy_defaults_to_prompting() { - assert!(!elicitation_is_rejected_by_policy( - AskForApproval::OnFailure - )); assert!(!elicitation_is_rejected_by_policy( AskForApproval::OnRequest )); @@ -789,7 +786,7 @@ async fn list_all_tools_uses_cached_tool_info_snapshot_while_client_is_pending() let pending_client = futures::future::pending::>() .boxed() .shared(); - let approval_policy = Constrained::allow_any(AskForApproval::OnFailure); + let approval_policy = Constrained::allow_any(AskForApproval::OnRequest); let permission_profile = Constrained::allow_any(PermissionProfile::default()); let mut manager = McpConnectionManager::new_uninitialized( &approval_policy, @@ -826,7 +823,7 @@ async fn list_available_server_infos_uses_cache_while_client_is_pending() { let pending_client = futures::future::pending::>() .boxed() .shared(); - let approval_policy = Constrained::allow_any(AskForApproval::OnFailure); + let approval_policy = Constrained::allow_any(AskForApproval::OnRequest); let permission_profile = Constrained::allow_any(PermissionProfile::default()); let mut manager = McpConnectionManager::new_uninitialized( &approval_policy, @@ -865,7 +862,7 @@ async fn list_all_tools_accepts_canonical_namespaced_tool_names() { let pending_client = futures::future::pending::>() .boxed() .shared(); - let approval_policy = Constrained::allow_any(AskForApproval::OnFailure); + let approval_policy = Constrained::allow_any(AskForApproval::OnRequest); let permission_profile = Constrained::allow_any(PermissionProfile::default()); let mut manager = McpConnectionManager::new_uninitialized( &approval_policy, @@ -909,7 +906,7 @@ async fn list_all_tools_applies_legacy_mcp_prefix_by_default() { let pending_client = futures::future::pending::>() .boxed() .shared(); - let approval_policy = Constrained::allow_any(AskForApproval::OnFailure); + let approval_policy = Constrained::allow_any(AskForApproval::OnRequest); let permission_profile = Constrained::allow_any(PermissionProfile::default()); let mut manager = McpConnectionManager::new_uninitialized( &approval_policy, @@ -952,7 +949,7 @@ async fn list_all_tools_blocks_while_client_is_pending_without_cached_tool_info_ let pending_client = futures::future::pending::>() .boxed() .shared(); - let approval_policy = Constrained::allow_any(AskForApproval::OnFailure); + let approval_policy = Constrained::allow_any(AskForApproval::OnRequest); let permission_profile = Constrained::allow_any(PermissionProfile::default()); let mut manager = McpConnectionManager::new_uninitialized( &approval_policy, @@ -989,7 +986,7 @@ async fn shutdown_cancels_pending_tool_listing() { } .boxed() .shared(); - let approval_policy = Constrained::allow_any(AskForApproval::OnFailure); + let approval_policy = Constrained::allow_any(AskForApproval::OnRequest); let permission_profile = Constrained::allow_any(PermissionProfile::default()); let mut manager = McpConnectionManager::new_uninitialized( &approval_policy, @@ -1025,7 +1022,7 @@ async fn list_all_tools_does_not_block_when_cached_tool_info_snapshot_is_empty() let pending_client = futures::future::pending::>() .boxed() .shared(); - let approval_policy = Constrained::allow_any(AskForApproval::OnFailure); + let approval_policy = Constrained::allow_any(AskForApproval::OnRequest); let permission_profile = Constrained::allow_any(PermissionProfile::default()); let mut manager = McpConnectionManager::new_uninitialized( &approval_policy, @@ -1065,7 +1062,7 @@ async fn list_all_tools_uses_cached_tool_info_snapshot_when_client_startup_fails )) .boxed() .shared(); - let approval_policy = Constrained::allow_any(AskForApproval::OnFailure); + let approval_policy = Constrained::allow_any(AskForApproval::OnRequest); let permission_profile = Constrained::allow_any(PermissionProfile::default()); let mut manager = McpConnectionManager::new_uninitialized( &approval_policy, @@ -1112,7 +1109,7 @@ async fn list_all_tools_adds_server_metadata_to_cached_tools() { let pending_client = futures::future::pending::>() .boxed() .shared(); - let approval_policy = Constrained::allow_any(AskForApproval::OnFailure); + let approval_policy = Constrained::allow_any(AskForApproval::OnRequest); let permission_profile = Constrained::allow_any(PermissionProfile::default()); let mut manager = McpConnectionManager::new_uninitialized( &approval_policy, @@ -1214,7 +1211,7 @@ fn host_owned_codex_apps_matches_reserved_name_with_server_metadata() { #[tokio::test] async fn no_local_runtime_fails_local_stdio_but_keeps_local_http_server() { - let approval_policy = Constrained::allow_any(AskForApproval::OnFailure); + let approval_policy = Constrained::allow_any(AskForApproval::OnRequest); let (tx_event, rx_event) = async_channel::unbounded(); drop(rx_event); let codex_home = tempdir().expect("tempdir"); diff --git a/codex-rs/codex-mcp/src/elicitation.rs b/codex-rs/codex-mcp/src/elicitation.rs index abd5a46899e6..d6a685b50203 100644 --- a/codex-rs/codex-mcp/src/elicitation.rs +++ b/codex-rs/codex-mcp/src/elicitation.rs @@ -247,7 +247,6 @@ impl ElicitationRequestManager { pub(crate) fn elicitation_is_rejected_by_policy(approval_policy: AskForApproval) -> bool { match approval_policy { AskForApproval::Never => true, - AskForApproval::OnFailure => false, AskForApproval::OnRequest => false, AskForApproval::UnlessTrusted => false, AskForApproval::Granular(granular_config) => !granular_config.allows_mcp_elicitations(), diff --git a/codex-rs/codex-mcp/src/mcp/mod_tests.rs b/codex-rs/codex-mcp/src/mcp/mod_tests.rs index 31c31960c737..9617dca08921 100644 --- a/codex-rs/codex-mcp/src/mcp/mod_tests.rs +++ b/codex-rs/codex-mcp/src/mcp/mod_tests.rs @@ -27,7 +27,7 @@ fn test_mcp_config(codex_home: PathBuf) -> McpConfig { mcp_oauth_callback_port: None, mcp_oauth_callback_url: None, skill_mcp_dependency_install_enabled: true, - approval_policy: Constrained::allow_any(AskForApproval::OnFailure), + approval_policy: Constrained::allow_any(AskForApproval::OnRequest), codex_linux_sandbox_exe: None, use_legacy_landlock: false, apps_enabled: false, @@ -83,7 +83,6 @@ fn mcp_prompt_auto_approval_honors_unrestricted_managed_profiles() { fn mcp_prompt_auto_approval_honors_approved_tools_in_all_permission_modes() { for approval_policy in [ AskForApproval::UnlessTrusted, - AskForApproval::OnFailure, AskForApproval::OnRequest, AskForApproval::Granular(GranularApprovalConfig { sandbox_approval: true, diff --git a/codex-rs/config/src/config_requirements.rs b/codex-rs/config/src/config_requirements.rs index ac5173453686..4ccf4523aac4 100644 --- a/codex-rs/config/src/config_requirements.rs +++ b/codex-rs/config/src/config_requirements.rs @@ -2513,17 +2513,6 @@ allowed_approvals_reviewers = ["user"] .can_set(&AskForApproval::UnlessTrusted) .is_ok() ); - assert_eq!( - requirements - .approval_policy - .can_set(&AskForApproval::OnFailure), - Err(ConstraintError::InvalidValue { - field_name: "approval_policy", - candidate: "OnFailure".into(), - allowed: "[UnlessTrusted, OnRequest]".into(), - requirement_source: RequirementSource::Unknown, - }) - ); assert!( requirements .approval_policy diff --git a/codex-rs/config/src/state_tests.rs b/codex-rs/config/src/state_tests.rs index fb6e26968b1a..7ad4ed297de4 100644 --- a/codex-rs/config/src/state_tests.rs +++ b/codex-rs/config/src/state_tests.rs @@ -52,7 +52,7 @@ fn active_user_layer_is_highest_precedence_user_layer() { toml::from_str( r#" model = "base" -approval_policy = "on-failure" +approval_policy = "on-request" "#, ) .expect("base config"), @@ -86,7 +86,7 @@ approval_policy = "on-failure" .expect("merged user config") .get("approval_policy") .and_then(toml::Value::as_str), - Some("on-failure") + Some("on-request") ); } @@ -107,7 +107,7 @@ fn with_user_config_updates_matching_user_layer_without_replacing_active_profile file: profile_file.clone(), profile: Some("work".to_string()), }, - toml::from_str(r#"approval_policy = "on-failure""#).expect("profile config"), + toml::from_str(r#"approval_policy = "on-request""#).expect("profile config"), ); let stack = ConfigLayerStack::new( vec![base_layer, profile_layer], @@ -136,6 +136,6 @@ fn with_user_config_updates_matching_user_layer_without_replacing_active_profile .expect("merged user config") .get("approval_policy") .and_then(toml::Value::as_str), - Some("on-failure") + Some("on-request") ); } diff --git a/codex-rs/core/config.schema.json b/codex-rs/core/config.schema.json index 31dcc667d1bf..ad99c9cffb98 100644 --- a/codex-rs/core/config.schema.json +++ b/codex-rs/core/config.schema.json @@ -252,13 +252,6 @@ ], "type": "string" }, - { - "description": "DEPRECATED: *All* commands are auto‑approved, but they are expected to run inside a sandbox where network access is disabled and writes are confined to a specific set of paths. If the command fails, it will be escalated to the user to approve execution without a sandbox. Prefer `OnRequest` for interactive runs or `Never` for non-interactive runs.", - "enum": [ - "on-failure" - ], - "type": "string" - }, { "description": "The model decides when to ask the user for approval.", "enum": [ diff --git a/codex-rs/core/gpt_5_1_prompt.md b/codex-rs/core/gpt_5_1_prompt.md index 440422ae6ae7..da2ec674f79c 100644 --- a/codex-rs/core/gpt_5_1_prompt.md +++ b/codex-rs/core/gpt_5_1_prompt.md @@ -171,7 +171,7 @@ For all of testing, running, building, and formatting, do not attempt to fix unr Be mindful of whether to run validation commands proactively. In the absence of behavioral guidance: -- When running in non-interactive approval modes like **never** or **on-failure**, you can proactively run tests, lint and do whatever you need to ensure you've completed the task. If you are unable to run tests, you must still do your utmost best to complete the task. +- When running in the non-interactive approval mode **never**, you can proactively run tests, lint and do whatever you need to ensure you've completed the task. If you are unable to run tests, you must still do your utmost best to complete the task. - When working in interactive approval modes like **untrusted**, or **on-request**, hold off on running tests or lint commands until the user is ready for you to finalize your output, because these commands take time to run and slow down iteration. Instead suggest what you want to do next, and let the user confirm first. - When working on test-related tasks, such as adding tests, fixing tests, or reproducing a bug to verify behavior, you may proactively run tests regardless of approval mode. Use your judgement to decide whether this is a test-related task. diff --git a/codex-rs/core/gpt_5_2_prompt.md b/codex-rs/core/gpt_5_2_prompt.md index 7dd684bf061e..8aa188f5e1c5 100644 --- a/codex-rs/core/gpt_5_2_prompt.md +++ b/codex-rs/core/gpt_5_2_prompt.md @@ -145,7 +145,7 @@ For all of testing, running, building, and formatting, do not attempt to fix unr Be mindful of whether to run validation commands proactively. In the absence of behavioral guidance: -- When running in non-interactive approval modes like **never** or **on-failure**, you can proactively run tests, lint and do whatever you need to ensure you've completed the task. If you are unable to run tests, you must still do your utmost best to complete the task. +- When running in the non-interactive approval mode **never**, you can proactively run tests, lint and do whatever you need to ensure you've completed the task. If you are unable to run tests, you must still do your utmost best to complete the task. - When working in interactive approval modes like **untrusted**, or **on-request**, hold off on running tests or lint commands until the user is ready for you to finalize your output, because these commands take time to run and slow down iteration. Instead suggest what you want to do next, and let the user confirm first. - When working on test-related tasks, such as adding tests, fixing tests, or reproducing a bug to verify behavior, you may proactively run tests regardless of approval mode. Use your judgement to decide whether this is a test-related task. diff --git a/codex-rs/core/prompt_with_apply_patch_instructions.md b/codex-rs/core/prompt_with_apply_patch_instructions.md index f9c308fbd15c..2650c6709ce7 100644 --- a/codex-rs/core/prompt_with_apply_patch_instructions.md +++ b/codex-rs/core/prompt_with_apply_patch_instructions.md @@ -158,7 +158,7 @@ For all of testing, running, building, and formatting, do not attempt to fix unr Be mindful of whether to run validation commands proactively. In the absence of behavioral guidance: -- When running in non-interactive approval modes like **never** or **on-failure**, proactively run tests, lint and do whatever you need to ensure you've completed the task. +- When running in the non-interactive approval mode **never**, proactively run tests, lint and do whatever you need to ensure you've completed the task. - When working in interactive approval modes like **untrusted**, or **on-request**, hold off on running tests or lint commands until the user is ready for you to finalize your output, because these commands take time to run and slow down iteration. Instead suggest what you want to do next, and let the user confirm first. - When working on test-related tasks, such as adding tests, fixing tests, or reproducing a bug to verify behavior, you may proactively run tests regardless of approval mode. Use your judgement to decide whether this is a test-related task. diff --git a/codex-rs/core/src/config/config_loader_tests.rs b/codex-rs/core/src/config/config_loader_tests.rs index 1a9245b1aa8e..9142ac51de12 100644 --- a/codex-rs/core/src/config/config_loader_tests.rs +++ b/codex-rs/core/src/config/config_loader_tests.rs @@ -640,7 +640,7 @@ async fn selected_user_config_file_layers_over_base_user_config() { tmp.path().join(CONFIG_TOML_FILE), r#" model = "gpt-main" -approval_policy = "on-failure" +approval_policy = "on-request" "#, ) .expect("write default user config"); @@ -697,7 +697,7 @@ approval_policy = "on-failure" .effective_config() .get("approval_policy") .and_then(TomlValue::as_str), - Some("on-failure") + Some("on-request") ); } @@ -1033,12 +1033,6 @@ personality = true config_requirements .approval_policy .can_set(&AskForApproval::Never)?; - assert!( - config_requirements - .approval_policy - .can_set(&AskForApproval::OnFailure) - .is_err() - ); assert_eq!( config_requirements.web_search_mode.value(), WebSearchMode::Cached diff --git a/codex-rs/core/src/config/config_tests.rs b/codex-rs/core/src/config/config_tests.rs index 67cb0932de69..66680f735e83 100644 --- a/codex-rs/core/src/config/config_tests.rs +++ b/codex-rs/core/src/config/config_tests.rs @@ -8272,7 +8272,7 @@ model_provider = "openai-custom" [profiles.zdr] model = "o3" model_provider = "openai" -approval_policy = "on-failure" +approval_policy = "on-request" [profiles.zdr.analytics] enabled = false @@ -8280,7 +8280,7 @@ enabled = false [profiles.gpt5] model = "gpt-5.4" model_provider = "openai" -approval_policy = "on-failure" +approval_policy = "on-request" model_reasoning_effort = "high" model_reasoning_summary = "detailed" model_verbosity = "high" diff --git a/codex-rs/core/src/exec_policy.rs b/codex-rs/core/src/exec_policy.rs index 7b33a196b086..d79faba1ac21 100644 --- a/codex-rs/core/src/exec_policy.rs +++ b/codex-rs/core/src/exec_policy.rs @@ -177,7 +177,6 @@ pub(crate) fn prompt_is_rejected_by_policy( ) -> Option<&'static str> { match approval_policy { AskForApproval::Never => Some(PROMPT_CONFLICT_REASON), - AskForApproval::OnFailure => None, AskForApproval::OnRequest => None, AskForApproval::UnlessTrusted => None, AskForApproval::Granular(granular_config) => { @@ -689,15 +688,14 @@ pub(crate) fn render_decision_for_unmatched_command( Decision::Forbidden } } - AskForApproval::OnFailure - | AskForApproval::OnRequest + AskForApproval::OnRequest | AskForApproval::UnlessTrusted | AskForApproval::Granular(_) => Decision::Prompt, }; } match approval_policy { - AskForApproval::Never | AskForApproval::OnFailure => { + AskForApproval::Never => { // We allow the command to run, relying on the sandbox for // protection. Decision::Allow diff --git a/codex-rs/core/src/hook_runtime.rs b/codex-rs/core/src/hook_runtime.rs index 96ae6c9908a3..12627e2d5292 100644 --- a/codex-rs/core/src/hook_runtime.rs +++ b/codex-rs/core/src/hook_runtime.rs @@ -738,10 +738,9 @@ fn hook_run_metric_tags(run: &HookRunSummary) -> [(&'static str, &'static str); fn hook_permission_mode(turn_context: &TurnContext) -> String { match turn_context.approval_policy.value() { AskForApproval::Never => "bypassPermissions", - AskForApproval::UnlessTrusted - | AskForApproval::OnFailure - | AskForApproval::OnRequest - | AskForApproval::Granular(_) => "default", + AskForApproval::UnlessTrusted | AskForApproval::OnRequest | AskForApproval::Granular(_) => { + "default" + } } .to_string() } diff --git a/codex-rs/core/src/mcp_tool_call.rs b/codex-rs/core/src/mcp_tool_call.rs index 0cb0c11a2a9d..71b3e60b7eab 100644 --- a/codex-rs/core/src/mcp_tool_call.rs +++ b/codex-rs/core/src/mcp_tool_call.rs @@ -653,10 +653,8 @@ async fn maybe_request_codex_apps_auth_elicitation( AskForApproval::Granular(granular_config) if !granular_config.allows_mcp_elicitations() => { return result; } - AskForApproval::OnFailure - | AskForApproval::OnRequest - | AskForApproval::UnlessTrusted - | AskForApproval::Granular(_) => {} + AskForApproval::OnRequest | AskForApproval::UnlessTrusted | AskForApproval::Granular(_) => { + } } let connector_id = metadata.and_then(|metadata| metadata.connector_id.as_deref()); diff --git a/codex-rs/core/src/mcp_tool_call_tests.rs b/codex-rs/core/src/mcp_tool_call_tests.rs index f8b94de5aa01..89b4f9de6c30 100644 --- a/codex-rs/core/src/mcp_tool_call_tests.rs +++ b/codex-rs/core/src/mcp_tool_call_tests.rs @@ -2915,7 +2915,6 @@ async fn approve_mode_skips_guardian_in_every_permission_mode() { for approval_policy in [ AskForApproval::UnlessTrusted, - AskForApproval::OnFailure, AskForApproval::OnRequest, AskForApproval::Granular(GranularApprovalConfig { sandbox_approval: true, diff --git a/codex-rs/core/src/safety.rs b/codex-rs/core/src/safety.rs index 916379705b22..1fe9b0257b81 100644 --- a/codex-rs/core/src/safety.rs +++ b/codex-rs/core/src/safety.rs @@ -44,10 +44,7 @@ pub fn assess_patch_safety( } match policy { - AskForApproval::OnFailure - | AskForApproval::Never - | AskForApproval::OnRequest - | AskForApproval::Granular(_) => { + AskForApproval::Never | AskForApproval::OnRequest | AskForApproval::Granular(_) => { // Continue to see if this can be auto-approved. } // TODO(ragona): I'm not sure this is actually correct? I believe in this case @@ -66,9 +63,7 @@ pub fn assess_patch_safety( // Even though the patch appears to be constrained to writable paths, it is // possible that paths in the patch are hard links to files outside the // writable roots, so we should still run `apply_patch` in a sandbox in that case. - if is_write_patch_constrained_to_writable_paths(action, file_system_sandbox_policy, cwd) - || matches!(policy, AskForApproval::OnFailure) - { + if is_write_patch_constrained_to_writable_paths(action, file_system_sandbox_policy, cwd) { if matches!( permission_profile, PermissionProfile::Disabled | PermissionProfile::External { .. } diff --git a/codex-rs/core/src/session/mod.rs b/codex-rs/core/src/session/mod.rs index 95db34858335..bde452149f49 100644 --- a/codex-rs/core/src/session/mod.rs +++ b/codex-rs/core/src/session/mod.rs @@ -2236,8 +2236,7 @@ impl Session { strict_auto_review: false, }); } - AskForApproval::OnFailure - | AskForApproval::OnRequest + AskForApproval::OnRequest | AskForApproval::UnlessTrusted | AskForApproval::Granular(_) => {} } diff --git a/codex-rs/core/src/session/session.rs b/codex-rs/core/src/session/session.rs index 69f1959cce2e..00c5b64e8ac9 100644 --- a/codex-rs/core/src/session/session.rs +++ b/codex-rs/core/src/session/session.rs @@ -748,15 +748,6 @@ impl Session { ) { post_session_configured_events.push(event); } - if config.permissions.approval_policy.value() == AskForApproval::OnFailure { - post_session_configured_events.push(Event { - id: "".to_owned(), - msg: EventMsg::Warning(WarningEvent { - message: "`on-failure` approval policy is deprecated and will be removed in a future release. Use `on-request` for interactive approvals or `never` for non-interactive runs.".to_string(), - }), - }); - } - let auth = auth.as_ref(); let auth_mode = auth.map(CodexAuth::auth_mode).map(TelemetryAuthMode::from); let account_id = auth.and_then(CodexAuth::get_account_id); diff --git a/codex-rs/core/src/session/tests.rs b/codex-rs/core/src/session/tests.rs index a76cacabf28c..482fec38a2ed 100644 --- a/codex-rs/core/src/session/tests.rs +++ b/codex-rs/core/src/session/tests.rs @@ -1288,7 +1288,7 @@ async fn reload_user_config_layer_updates_base_and_selected_profile_layers() { let profile_config_path = codex_home.join("work.config.toml"); std::fs::write( &base_config_path, - "model = \"base\"\napproval_policy = \"on-failure\"\n", + "model = \"base\"\napproval_policy = \"on-request\"\n", ) .expect("write base user config"); std::fs::write(&profile_config_path, "model = \"profile-old\"\n") @@ -10132,7 +10132,7 @@ async fn rejects_escalated_permissions_when_policy_not_on_request() { // Ensure policy is NOT OnRequest so the early rejection path triggers turn_context_raw .approval_policy - .set(AskForApproval::OnFailure) + .set(AskForApproval::Never) .expect("test setup should allow updating approval policy"); let session = Arc::new(session); let mut turn_context = Arc::new(turn_context_raw); @@ -10295,7 +10295,7 @@ async fn unified_exec_rejects_escalated_permissions_when_policy_not_on_request() let (session, mut turn_context_raw) = make_session_and_context().await; turn_context_raw .approval_policy - .set(AskForApproval::OnFailure) + .set(AskForApproval::Never) .expect("test setup should allow updating approval policy"); let session = Arc::new(session); let turn_context = Arc::new(turn_context_raw); diff --git a/codex-rs/core/src/session/tests/guardian_tests.rs b/codex-rs/core/src/session/tests/guardian_tests.rs index e44b12ef720a..32e4ef9820ce 100644 --- a/codex-rs/core/src/session/tests/guardian_tests.rs +++ b/codex-rs/core/src/session/tests/guardian_tests.rs @@ -93,7 +93,7 @@ async fn request_permissions_routes_to_guardian_when_reviewer_is_enabled() { *session.active_turn.lock().await = Some(ActiveTurn::default()); turn_context_raw .approval_policy - .set(AskForApproval::OnRequest) + .set(AskForApproval::Never) .expect("test setup should allow updating approval policy"); let mut config = (*turn_context_raw.config).clone(); config @@ -407,7 +407,7 @@ async fn strict_auto_review_turn_grant_forces_guardian_for_shell_command_policy_ turn_context_raw .approval_policy - .set(AskForApproval::OnFailure) + .set(AskForApproval::OnRequest) .expect("test setup should allow updating approval policy"); turn_context_raw.permission_profile = codex_protocol::models::PermissionProfile::Disabled; let mut config = (*turn_context_raw.config).clone(); diff --git a/codex-rs/core/src/tools/network_approval_tests.rs b/codex-rs/core/src/tools/network_approval_tests.rs index 60c7215b1b0b..7a9ba86cef87 100644 --- a/codex-rs/core/src/tools/network_approval_tests.rs +++ b/codex-rs/core/src/tools/network_approval_tests.rs @@ -250,7 +250,6 @@ fn allow_once_and_allow_for_session_both_allow_network() { fn only_never_policy_disables_network_approval_flow() { assert!(!allows_network_approval_flow(AskForApproval::Never)); assert!(allows_network_approval_flow(AskForApproval::OnRequest)); - assert!(allows_network_approval_flow(AskForApproval::OnFailure)); assert!(allows_network_approval_flow(AskForApproval::UnlessTrusted)); } diff --git a/codex-rs/core/src/tools/runtimes/apply_patch.rs b/codex-rs/core/src/tools/runtimes/apply_patch.rs index 7ef7687842ad..840a0dd01e73 100644 --- a/codex-rs/core/src/tools/runtimes/apply_patch.rs +++ b/codex-rs/core/src/tools/runtimes/apply_patch.rs @@ -205,7 +205,6 @@ impl Approvable for ApplyPatchRuntime { match policy { AskForApproval::Never => false, AskForApproval::Granular(granular_config) => granular_config.allows_sandbox_approval(), - AskForApproval::OnFailure => true, AskForApproval::OnRequest => true, AskForApproval::UnlessTrusted => true, } diff --git a/codex-rs/core/src/tools/sandboxing.rs b/codex-rs/core/src/tools/sandboxing.rs index 77f68d96b511..b84e8b760c2a 100644 --- a/codex-rs/core/src/tools/sandboxing.rs +++ b/codex-rs/core/src/tools/sandboxing.rs @@ -196,7 +196,7 @@ impl ExecApprovalRequirement { } } -/// - Never, OnFailure: do not ask +/// - Never: do not ask /// - OnRequest: ask unless filesystem access is unrestricted /// - Granular: ask unless filesystem access is unrestricted, but auto-reject /// when granular sandbox approval is disabled. @@ -206,7 +206,7 @@ pub(crate) fn default_exec_approval_requirement( file_system_sandbox_policy: &FileSystemSandboxPolicy, ) -> ExecApprovalRequirement { let needs_approval = match policy { - AskForApproval::Never | AskForApproval::OnFailure => false, + AskForApproval::Never => false, AskForApproval::OnRequest | AskForApproval::Granular(_) => { matches!( file_system_sandbox_policy.kind, @@ -356,7 +356,6 @@ pub(crate) trait Approvable { /// Decide we can request an approval for no-sandbox execution. fn wants_no_sandbox_approval(&self, policy: AskForApproval) -> bool { match policy { - AskForApproval::OnFailure => true, AskForApproval::UnlessTrusted => true, AskForApproval::Never => false, AskForApproval::OnRequest => false, diff --git a/codex-rs/core/tests/suite/approvals.rs b/codex-rs/core/tests/suite/approvals.rs index f26b8e4b85c7..f0ab48c5e16c 100644 --- a/codex-rs/core/tests/suite/approvals.rs +++ b/codex-rs/core/tests/suite/approvals.rs @@ -1085,40 +1085,6 @@ fn scenarios() -> Vec { output_contains: "rejected by user", }, }, - ScenarioSpec { - name: "danger_full_access_on_failure_allows_outside_write", - approval_policy: OnFailure, - sandbox_policy: SandboxPolicy::DangerFullAccess, - action: ActionKind::WriteFile { - target: TargetPath::OutsideWorkspace("dfa_on_failure.txt"), - content: "danger-on-failure", - }, - sandbox_permissions: SandboxPermissions::UseDefault, - features: vec![], - model_override: Some("gpt-5.2"), - outcome: Outcome::Auto, - expectation: Expectation::FileCreated { - target: TargetPath::OutsideWorkspace("dfa_on_failure.txt"), - content: "danger-on-failure", - }, - }, - ScenarioSpec { - name: "danger_full_access_on_failure_allows_outside_write_gpt_5_1_no_exit", - approval_policy: OnFailure, - sandbox_policy: SandboxPolicy::DangerFullAccess, - action: ActionKind::WriteFile { - target: TargetPath::OutsideWorkspace("dfa_on_failure_5_1.txt"), - content: "danger-on-failure", - }, - sandbox_permissions: SandboxPermissions::UseDefault, - features: vec![], - model_override: Some("gpt-5.4"), - outcome: Outcome::Auto, - expectation: Expectation::FileCreatedNoExitCode { - target: TargetPath::OutsideWorkspace("dfa_on_failure_5_1.txt"), - content: "danger-on-failure", - }, - }, ScenarioSpec { name: "danger_full_access_unless_trusted_requests_approval", approval_policy: UnlessTrusted, @@ -1297,48 +1263,6 @@ fn scenarios() -> Vec { message_contains: &["exec command rejected by user"], }, }, - #[cfg(not(target_os = "linux"))] // TODO (pakrym): figure out why linux behaves differently - ScenarioSpec { - name: "read_only_on_failure_escalates_after_sandbox_error", - approval_policy: OnFailure, - sandbox_policy: SandboxPolicy::new_read_only_policy(), - action: ActionKind::WriteFile { - target: TargetPath::Workspace("ro_on_failure.txt"), - content: "read-only-on-failure", - }, - sandbox_permissions: SandboxPermissions::UseDefault, - features: vec![], - model_override: Some("gpt-5.2"), - outcome: Outcome::ExecApproval { - decision: ReviewDecision::Approved, - expected_reason: Some("command failed; retry without sandbox?"), - }, - expectation: Expectation::FileCreated { - target: TargetPath::Workspace("ro_on_failure.txt"), - content: "read-only-on-failure", - }, - }, - #[cfg(not(target_os = "linux"))] - ScenarioSpec { - name: "read_only_on_failure_escalates_after_sandbox_error_gpt_5_1_no_exit", - approval_policy: OnFailure, - sandbox_policy: SandboxPolicy::new_read_only_policy(), - action: ActionKind::WriteFile { - target: TargetPath::Workspace("ro_on_failure_5_1.txt"), - content: "read-only-on-failure", - }, - sandbox_permissions: SandboxPermissions::UseDefault, - features: vec![], - model_override: Some("gpt-5.4"), - outcome: Outcome::ExecApproval { - decision: ReviewDecision::Approved, - expected_reason: Some("command failed; retry without sandbox?"), - }, - expectation: Expectation::FileCreatedNoExitCode { - target: TargetPath::Workspace("ro_on_failure_5_1.txt"), - content: "read-only-on-failure", - }, - }, ScenarioSpec { name: "read_only_on_request_network_escalates_when_approved", approval_policy: OnRequest, @@ -1676,27 +1600,6 @@ fn scenarios() -> Vec { body_contains: "workspace-network-ok", }, }, - #[cfg(not(target_os = "linux"))] // TODO (pakrym): figure out why linux behaves differently - ScenarioSpec { - name: "workspace_write_on_failure_escalates_outside_workspace", - approval_policy: OnFailure, - sandbox_policy: workspace_write(false), - action: ActionKind::WriteFile { - target: TargetPath::OutsideWorkspace("ww_on_failure.txt"), - content: "workspace-on-failure", - }, - sandbox_permissions: SandboxPermissions::UseDefault, - features: vec![], - model_override: Some("gpt-5.2"), - outcome: Outcome::ExecApproval { - decision: ReviewDecision::Approved, - expected_reason: Some("command failed; retry without sandbox?"), - }, - expectation: Expectation::FileCreated { - target: TargetPath::OutsideWorkspace("ww_on_failure.txt"), - content: "workspace-on-failure", - }, - }, ScenarioSpec { name: "workspace_write_unless_trusted_requires_approval_outside_workspace", approval_policy: UnlessTrusted, @@ -2982,7 +2885,7 @@ mode = "limited" allow_local_binding = true "#, )?; - let approval_policy = AskForApproval::OnFailure; + let approval_policy = AskForApproval::OnRequest; let sandbox_policy = SandboxPolicy::WorkspaceWrite { writable_roots: vec![], network_access: true, @@ -3467,7 +3370,7 @@ mode = "limited" allow_local_binding = true "#, )?; - let approval_policy = AskForApproval::OnFailure; + let approval_policy = AskForApproval::OnRequest; let turn_sandbox_policy = SandboxPolicy::WorkspaceWrite { writable_roots: vec![], network_access: true, diff --git a/codex-rs/core/tests/suite/hooks.rs b/codex-rs/core/tests/suite/hooks.rs index f0ad29fd6805..71c0acfe846a 100644 --- a/codex-rs/core/tests/suite/hooks.rs +++ b/codex-rs/core/tests/suite/hooks.rs @@ -2200,7 +2200,7 @@ allow_local_binding = true ) .await; - let approval_policy = AskForApproval::OnFailure; + let approval_policy = AskForApproval::OnRequest; let permission_profile = network_workspace_write_profile(); let permission_profile_for_config = permission_profile.clone(); let test = test_codex() @@ -2283,71 +2283,6 @@ allow_local_binding = true Ok(()) } -#[cfg(not(target_os = "linux"))] -#[tokio::test] -async fn permission_request_hook_sees_retry_context_after_sandbox_denial() -> Result<()> { - skip_if_no_network!(Ok(())); - - let server = start_mock_server().await; - let call_id = "permissionrequest-retry-shell-command"; - let marker = "permissionrequest_retry_marker.txt"; - let command = format!("printf retry > {marker}"); - let args = serde_json::json!({ "command": command }); - let responses = mount_sse_sequence( - &server, - vec![ - sse(vec![ - ev_response_created("resp-1"), - core_test_support::responses::ev_function_call( - call_id, - "shell_command", - &serde_json::to_string(&args)?, - ), - ev_completed("resp-1"), - ]), - sse(vec![ - ev_response_created("resp-2"), - ev_assistant_message("msg-1", "permission request hook allowed retry"), - ev_completed("resp-2"), - ]), - ], - ) - .await; - - let mut builder = test_codex() - .with_pre_build_hook(|home| { - install_allow_permission_request_hook(home) - .expect("failed to write permission request hook test fixture"); - }) - .with_config(trust_discovered_hooks); - let test = builder.build(&server).await?; - let marker_path = test.workspace_path(marker); - let _ = fs::remove_file(&marker_path); - - test.submit_turn_with_approval_and_permission_profile( - "retry the shell command after sandbox denial", - AskForApproval::OnFailure, - PermissionProfile::read_only(), - ) - .await?; - - let requests = responses.requests(); - assert_eq!(requests.len(), 2); - requests[1].function_call_output(call_id); - assert_eq!( - fs::read_to_string(&marker_path).context("read retry marker")?, - "retry" - ); - - assert_single_permission_request_hook_input( - test.codex_home_path(), - &command, - /*description*/ None, - )?; - - Ok(()) -} - #[tokio::test] async fn pre_tool_use_blocks_shell_command_before_execution() -> Result<()> { skip_if_no_network!(Ok(())); diff --git a/codex-rs/mcp-server/src/codex_tool_config.rs b/codex-rs/mcp-server/src/codex_tool_config.rs index f90686dbea16..531c8f8038ca 100644 --- a/codex-rs/mcp-server/src/codex_tool_config.rs +++ b/codex-rs/mcp-server/src/codex_tool_config.rs @@ -36,7 +36,7 @@ pub struct CodexToolCallParam { pub cwd: Option, /// Approval policy for shell commands generated by the model: - /// `untrusted`, `on-failure`, `on-request`, `never`. + /// `untrusted`, `on-request`, `never`. #[serde(default, skip_serializing_if = "Option::is_none")] pub approval_policy: Option, @@ -68,7 +68,6 @@ pub struct CodexToolCallParam { #[serde(rename_all = "kebab-case")] pub enum CodexToolCallApprovalPolicy { Untrusted, - OnFailure, OnRequest, Never, } @@ -77,7 +76,6 @@ impl From for AskForApproval { fn from(value: CodexToolCallApprovalPolicy) -> Self { match value { CodexToolCallApprovalPolicy::Untrusted => AskForApproval::UnlessTrusted, - CodexToolCallApprovalPolicy::OnFailure => AskForApproval::OnFailure, CodexToolCallApprovalPolicy::OnRequest => AskForApproval::OnRequest, CodexToolCallApprovalPolicy::Never => AskForApproval::Never, } @@ -301,10 +299,9 @@ mod tests { "additionalProperties": false, "properties": { "approval-policy": { - "description": "Approval policy for shell commands generated by the model: `untrusted`, `on-failure`, `on-request`, `never`.", + "description": "Approval policy for shell commands generated by the model: `untrusted`, `on-request`, `never`.", "enum": [ "untrusted", - "on-failure", "on-request", "never" ], diff --git a/codex-rs/models-manager/models.json b/codex-rs/models-manager/models.json index 213fdcf6c42f..d17785476fd1 100644 --- a/codex-rs/models-manager/models.json +++ b/codex-rs/models-manager/models.json @@ -404,7 +404,7 @@ "migration_markdown": "Introducing GPT-5.4\n\nCodex just got an upgrade with GPT-5.4, our most capable model for professional work. It outperforms prior models while being more token efficient, with notable improvements on long-running tasks, tool calling, computer use, and frontend development.\n\nLearn more: https://openai.com/index/introducing-gpt-5-4\n\nYou can always keep using GPT-5.3-Codex if you prefer.\n" }, "priority": 10, - "base_instructions": "You are GPT-5.2 running in the Codex CLI, a terminal-based coding assistant. Codex CLI is an open source project led by OpenAI. You are expected to be precise, safe, and helpful.\n\nYour capabilities:\n\n- Receive user prompts and other context provided by the harness, such as files in the workspace.\n- Communicate with the user by streaming thinking & responses, and by making & updating plans.\n- Emit function calls to run terminal commands and apply patches. Depending on how this specific run is configured, you can request that these function calls be escalated to the user for approval before running. More on this in the \"Sandbox and approvals\" section.\n\nWithin this context, Codex refers to the open-source agentic coding interface (not the old Codex language model built by OpenAI).\n\n# How you work\n\n## Personality\n\nYour default personality and tone is concise, direct, and friendly. You communicate efficiently, always keeping the user clearly informed about ongoing actions without unnecessary detail. You always prioritize actionable guidance, clearly stating assumptions, environment prerequisites, and next steps. Unless explicitly asked, you avoid excessively verbose explanations about your work.\n\n## AGENTS.md spec\n- Repos often contain AGENTS.md files. These files can appear anywhere within the repository.\n- These files are a way for humans to give you (the agent) instructions or tips for working within the container.\n- Some examples might be: coding conventions, info about how code is organized, or instructions for how to run or test code.\n- Instructions in AGENTS.md files:\n - The scope of an AGENTS.md file is the entire directory tree rooted at the folder that contains it.\n - For every file you touch in the final patch, you must obey instructions in any AGENTS.md file whose scope includes that file.\n - Instructions about code style, structure, naming, etc. apply only to code within the AGENTS.md file's scope, unless the file states otherwise.\n - More-deeply-nested AGENTS.md files take precedence in the case of conflicting instructions.\n - Direct system/developer/user instructions (as part of a prompt) take precedence over AGENTS.md instructions.\n- The contents of the AGENTS.md file at the root of the repo and any directories from the CWD up to the root are included with the developer message and don't need to be re-read. When working in a subdirectory of CWD, or a directory outside the CWD, check for any AGENTS.md files that may be applicable.\n\n## Autonomy and Persistence\nPersist until the task is fully handled end-to-end within the current turn whenever feasible: do not stop at analysis or partial fixes; carry changes through implementation, verification, and a clear explanation of outcomes unless the user explicitly pauses or redirects you.\n\nUnless the user explicitly asks for a plan, asks a question about the code, is brainstorming potential solutions, or some other intent that makes it clear that code should not be written, assume the user wants you to make code changes or run tools to solve the user's problem. In these cases, it's bad to output your proposed solution in a message, you should go ahead and actually implement the change. If you encounter challenges or blockers, you should attempt to resolve them yourself.\n\n## Responsiveness\n\n## Planning\n\nYou have access to an `update_plan` tool which tracks steps and progress and renders them to the user. Using the tool helps demonstrate that you've understood the task and convey how you're approaching it. Plans can help to make complex, ambiguous, or multi-phase work clearer and more collaborative for the user. A good plan should break the task into meaningful, logically ordered steps that are easy to verify as you go.\n\nNote that plans are not for padding out simple work with filler steps or stating the obvious. The content of your plan should not involve doing anything that you aren't capable of doing (i.e. don't try to test things that you can't test). Do not use plans for simple or single-step queries that you can just do or answer immediately.\n\nDo not repeat the full contents of the plan after an `update_plan` call — the harness already displays it. Instead, summarize the change made and highlight any important context or next step.\n\nBefore running a command, consider whether or not you have completed the previous step, and make sure to mark it as completed before moving on to the next step. It may be the case that you complete all steps in your plan after a single pass of implementation. If this is the case, you can simply mark all the planned steps as completed. Sometimes, you may need to change plans in the middle of a task: call `update_plan` with the updated plan and make sure to provide an `explanation` of the rationale when doing so.\n\nMaintain statuses in the tool: exactly one item in_progress at a time; mark items complete when done; post timely status transitions. Do not jump an item from pending to completed: always set it to in_progress first. Do not batch-complete multiple items after the fact. Finish with all items completed or explicitly canceled/deferred before ending the turn. Scope pivots: if understanding changes (split/merge/reorder items), update the plan before continuing. Do not let the plan go stale while coding.\n\nUse a plan when:\n\n- The task is non-trivial and will require multiple actions over a long time horizon.\n- There are logical phases or dependencies where sequencing matters.\n- The work has ambiguity that benefits from outlining high-level goals.\n- You want intermediate checkpoints for feedback and validation.\n- When the user asked you to do more than one thing in a single prompt\n- The user has asked you to use the plan tool (aka \"TODOs\")\n- You generate additional steps while working, and plan to do them before yielding to the user\n\n### Examples\n\n**High-quality plans**\n\nExample 1:\n\n1. Add CLI entry with file args\n2. Parse Markdown via CommonMark library\n3. Apply semantic HTML template\n4. Handle code blocks, images, links\n5. Add error handling for invalid files\n\nExample 2:\n\n1. Define CSS variables for colors\n2. Add toggle with localStorage state\n3. Refactor components to use variables\n4. Verify all views for readability\n5. Add smooth theme-change transition\n\nExample 3:\n\n1. Set up Node.js + WebSocket server\n2. Add join/leave broadcast events\n3. Implement messaging with timestamps\n4. Add usernames + mention highlighting\n5. Persist messages in lightweight DB\n6. Add typing indicators + unread count\n\n**Low-quality plans**\n\nExample 1:\n\n1. Create CLI tool\n2. Add Markdown parser\n3. Convert to HTML\n\nExample 2:\n\n1. Add dark mode toggle\n2. Save preference\n3. Make styles look good\n\nExample 3:\n\n1. Create single-file HTML game\n2. Run quick sanity check\n3. Summarize usage instructions\n\nIf you need to write a plan, only write high quality plans, not low quality ones.\n\n## Task execution\n\nYou are a coding agent. You must keep going until the query or task is completely resolved, before ending your turn and yielding back to the user. Persist until the task is fully handled end-to-end within the current turn whenever feasible and persevere even when function calls fail. Only terminate your turn when you are sure that the problem is solved. Autonomously resolve the query to the best of your ability, using the tools available to you, before coming back to the user. Do NOT guess or make up an answer.\n\nYou MUST adhere to the following criteria when solving queries:\n\n- Working on the repo(s) in the current environment is allowed, even if they are proprietary.\n- Analyzing code for vulnerabilities is allowed.\n- Showing user code and tool call details is allowed.\n- Use the `apply_patch` tool to edit files (NEVER try `applypatch` or `apply-patch`, only `apply_patch`). This is a FREEFORM tool, so do not wrap the patch in JSON.\n\nIf completing the user's task requires writing or modifying files, your code and final answer should follow these coding guidelines, though user instructions (i.e. AGENTS.md) may override these guidelines:\n\n- Fix the problem at the root cause rather than applying surface-level patches, when possible.\n- Avoid unneeded complexity in your solution.\n- Do not attempt to fix unrelated bugs or broken tests. It is not your responsibility to fix them. (You may mention them to the user in your final message though.)\n- Update documentation as necessary.\n- Keep changes consistent with the style of the existing codebase. Changes should be minimal and focused on the task.\n- If you're building a web app from scratch, give it a beautiful and modern UI, imbued with best UX practices.\n- Use `git log` and `git blame` to search the history of the codebase if additional context is required.\n- NEVER add copyright or license headers unless specifically requested.\n- Do not waste tokens by re-reading files after calling `apply_patch` on them. The tool call will fail if it didn't work. The same goes for making folders, deleting folders, etc.\n- Do not `git commit` your changes or create new git branches unless explicitly requested.\n- Do not add inline comments within code unless explicitly requested.\n- Do not use one-letter variable names unless explicitly requested.\n- NEVER output inline citations like \"【F:README.md†L5-L14】\" in your outputs. The CLI is not able to render these so they will just be broken in the UI. Instead, if you output valid filepaths, users will be able to click on them to open the files in their editor.\n\n## Validating your work\n\nIf the codebase has tests, or the ability to build or run tests, consider using them to verify changes once your work is complete.\n\nWhen testing, your philosophy should be to start as specific as possible to the code you changed so that you can catch issues efficiently, then make your way to broader tests as you build confidence. If there's no test for the code you changed, and if the adjacent patterns in the codebases show that there's a logical place for you to add a test, you may do so. However, do not add tests to codebases with no tests.\n\nSimilarly, once you're confident in correctness, you can suggest or use formatting commands to ensure that your code is well formatted. If there are issues you can iterate up to 3 times to get formatting right, but if you still can't manage it's better to save the user time and present them a correct solution where you call out the formatting in your final message. If the codebase does not have a formatter configured, do not add one.\n\nFor all of testing, running, building, and formatting, do not attempt to fix unrelated bugs. It is not your responsibility to fix them. (You may mention them to the user in your final message though.)\n\nBe mindful of whether to run validation commands proactively. In the absence of behavioral guidance:\n\n- When running in non-interactive approval modes like **never** or **on-failure**, you can proactively run tests, lint and do whatever you need to ensure you've completed the task. If you are unable to run tests, you must still do your utmost best to complete the task.\n- When working in interactive approval modes like **untrusted**, or **on-request**, hold off on running tests or lint commands until the user is ready for you to finalize your output, because these commands take time to run and slow down iteration. Instead suggest what you want to do next, and let the user confirm first.\n- When working on test-related tasks, such as adding tests, fixing tests, or reproducing a bug to verify behavior, you may proactively run tests regardless of approval mode. Use your judgement to decide whether this is a test-related task.\n\n## Ambition vs. precision\n\nFor tasks that have no prior context (i.e. the user is starting something brand new), you should feel free to be ambitious and demonstrate creativity with your implementation.\n\nIf you're operating in an existing codebase, you should make sure you do exactly what the user asks with surgical precision. Treat the surrounding codebase with respect, and don't overstep (i.e. changing filenames or variables unnecessarily). You should balance being sufficiently ambitious and proactive when completing tasks of this nature.\n\nYou should use judicious initiative to decide on the right level of detail and complexity to deliver based on the user's needs. This means showing good judgment that you're capable of doing the right extras without gold-plating. This might be demonstrated by high-value, creative touches when scope of the task is vague; while being surgical and targeted when scope is tightly specified.\n\n## Presenting your work \n\nYour final message should read naturally, like an update from a concise teammate. For casual conversation, brainstorming tasks, or quick questions from the user, respond in a friendly, conversational tone. You should ask questions, suggest ideas, and adapt to the user’s style. If you've finished a large amount of work, when describing what you've done to the user, you should follow the final answer formatting guidelines to communicate substantive changes. You don't need to add structured formatting for one-word answers, greetings, or purely conversational exchanges.\n\nYou can skip heavy formatting for single, simple actions or confirmations. In these cases, respond in plain sentences with any relevant next step or quick option. Reserve multi-section structured responses for results that need grouping or explanation.\n\nThe user is working on the same computer as you, and has access to your work. As such there's no need to show the contents of files you have already written unless the user explicitly asks for them. Similarly, if you've created or modified files using `apply_patch`, there's no need to tell users to \"save the file\" or \"copy the code into a file\"—just reference the file path.\n\nIf there's something that you think you could help with as a logical next step, concisely ask the user if they want you to do so. Good examples of this are running tests, committing changes, or building out the next logical component. If there’s something that you couldn't do (even with approval) but that the user might want to do (such as verifying changes by running the app), include those instructions succinctly.\n\nBrevity is very important as a default. You should be very concise (i.e. no more than 10 lines), but can relax this requirement for tasks where additional detail and comprehensiveness is important for the user's understanding.\n\n### Final answer structure and style guidelines\n\nYou are producing plain text that will later be styled by the CLI. Follow these rules exactly. Formatting should make results easy to scan, but not feel mechanical. Use judgment to decide how much structure adds value.\n\n**Section Headers**\n\n- Use only when they improve clarity — they are not mandatory for every answer.\n- Choose descriptive names that fit the content\n- Keep headers short (1–3 words) and in `**Title Case**`. Always start headers with `**` and end with `**`\n- Leave no blank line before the first bullet under a header.\n- Section headers should only be used where they genuinely improve scanability; avoid fragmenting the answer.\n\n**Bullets**\n\n- Use `-` followed by a space for every bullet.\n- Merge related points when possible; avoid a bullet for every trivial detail.\n- Keep bullets to one line unless breaking for clarity is unavoidable.\n- Group into short lists (4–6 bullets) ordered by importance.\n- Use consistent keyword phrasing and formatting across sections.\n\n**Monospace**\n\n- Wrap all commands, file paths, env vars, code identifiers, and code samples in backticks (`` `...` ``).\n- Apply to inline examples and to bullet keywords if the keyword itself is a literal file/command.\n- Never mix monospace and bold markers; choose one based on whether it’s a keyword (`**`) or inline code/path (`` ` ``).\n\n**File References**\nWhen referencing files in your response, make sure to include the relevant start line and always follow the below rules:\n * Use inline code to make file paths clickable.\n * Each reference should have a stand alone path. Even if it's the same file.\n * Accepted: absolute, workspace‑relative, a/ or b/ diff prefixes, or bare filename/suffix.\n * Line/column (1‑based, optional): :line[:column] or #Lline[Ccolumn] (column defaults to 1).\n * Do not use URIs like file://, vscode://, or https://.\n * Do not provide range of lines\n * Examples: src/app.ts, src/app.ts:42, b/server/index.js#L10, C:\\repo\\project\\main.rs:12:5\n\n**Structure**\n\n- Place related bullets together; don’t mix unrelated concepts in the same section.\n- Order sections from general → specific → supporting info.\n- For subsections (e.g., “Binaries” under “Rust Workspace”), introduce with a bolded keyword bullet, then list items under it.\n- Match structure to complexity:\n - Multi-part or detailed results → use clear headers and grouped bullets.\n - Simple results → minimal headers, possibly just a short list or paragraph.\n\n**Tone**\n\n- Keep the voice collaborative and natural, like a coding partner handing off work.\n- Be concise and factual — no filler or conversational commentary and avoid unnecessary repetition\n- Use present tense and active voice (e.g., “Runs tests” not “This will run tests”).\n- Keep descriptions self-contained; don’t refer to “above” or “below”.\n- Use parallel structure in lists for consistency.\n\n**Verbosity**\n- Final answer compactness rules (enforced):\n - Tiny/small single-file change (≤ ~10 lines): 2–5 sentences or ≤3 bullets. No headings. 0–1 short snippet (≤3 lines) only if essential.\n - Medium change (single area or a few files): ≤6 bullets or 6–10 sentences. At most 1–2 short snippets total (≤8 lines each).\n - Large/multi-file change: Summarize per file with 1–2 bullets; avoid inlining code unless critical (still ≤2 short snippets total).\n - Never include \"before/after\" pairs, full method bodies, or large/scrolling code blocks in the final message. Prefer referencing file/symbol names instead.\n\n**Don’t**\n\n- Don’t use literal words “bold” or “monospace” in the content.\n- Don’t nest bullets or create deep hierarchies.\n- Don’t output ANSI escape codes directly — the CLI renderer applies them.\n- Don’t cram unrelated keywords into a single bullet; split for clarity.\n- Don’t let keyword lists run long — wrap or reformat for scanability.\n\nGenerally, ensure your final answers adapt their shape and depth to the request. For example, answers to code explanations should have a precise, structured explanation with code references that answer the question directly. For tasks with a simple implementation, lead with the outcome and supplement only with what’s needed for clarity. Larger changes can be presented as a logical walkthrough of your approach, grouping related steps, explaining rationale where it adds value, and highlighting next actions to accelerate the user. Your answers should provide the right level of detail while being easily scannable.\n\nFor casual greetings, acknowledgements, or other one-off conversational messages that are not delivering substantive information or structured results, respond naturally without section headers or bullet formatting.\n\n# Tool Guidelines\n\n## Shell commands\n\nWhen using the shell, you must adhere to the following guidelines:\n\n- When searching for text or files, prefer using `rg` or `rg --files` respectively because `rg` is much faster than alternatives like `grep`. (If the `rg` command is not found, then use alternatives.)\n- Do not use python scripts to attempt to output larger chunks of a file.\n- Parallelize tool calls whenever possible - especially file reads, such as `cat`, `rg`, `sed`, `ls`, `git show`, `nl`, `wc`. Use `multi_tool_use.parallel` to parallelize tool calls and only this.\n\n## apply_patch\n\nUse the `apply_patch` tool to edit files. Your patch language is a stripped‑down, file‑oriented diff format designed to be easy to parse and safe to apply. You can think of it as a high‑level envelope:\n\n*** Begin Patch\n[ one or more file sections ]\n*** End Patch\n\nWithin that envelope, you get a sequence of file operations.\nYou MUST include a header to specify the action you are taking.\nEach operation starts with one of three headers:\n\n*** Add File: - create a new file. Every following line is a + line (the initial contents).\n*** Delete File: - remove an existing file. Nothing follows.\n*** Update File: - patch an existing file in place (optionally with a rename).\n\nExample patch:\n\n```\n*** Begin Patch\n*** Add File: hello.txt\n+Hello world\n*** Update File: src/app.py\n*** Move to: src/main.py\n@@ def greet():\n-print(\"Hi\")\n+print(\"Hello, world!\")\n*** Delete File: obsolete.txt\n*** End Patch\n```\n\nIt is important to remember:\n\n- You must include a header with your intended action (Add/Delete/Update)\n- You must prefix new lines with `+` even when creating a new file\n\n## `update_plan`\n\nA tool named `update_plan` is available to you. You can use it to keep an up‑to‑date, step‑by‑step plan for the task.\n\nTo create a new plan, call `update_plan` with a short list of 1‑sentence steps (no more than 5-7 words each) with a `status` for each step (`pending`, `in_progress`, or `completed`).\n\nWhen steps have been completed, use `update_plan` to mark each finished step as `completed` and the next step you are working on as `in_progress`. There should always be exactly one `in_progress` step until everything is done. You can mark multiple items as complete in a single `update_plan` call.\n\nIf all steps are complete, ensure you call `update_plan` to mark all steps as `completed`.\n", + "base_instructions": "You are GPT-5.2 running in the Codex CLI, a terminal-based coding assistant. Codex CLI is an open source project led by OpenAI. You are expected to be precise, safe, and helpful.\n\nYour capabilities:\n\n- Receive user prompts and other context provided by the harness, such as files in the workspace.\n- Communicate with the user by streaming thinking & responses, and by making & updating plans.\n- Emit function calls to run terminal commands and apply patches. Depending on how this specific run is configured, you can request that these function calls be escalated to the user for approval before running. More on this in the \"Sandbox and approvals\" section.\n\nWithin this context, Codex refers to the open-source agentic coding interface (not the old Codex language model built by OpenAI).\n\n# How you work\n\n## Personality\n\nYour default personality and tone is concise, direct, and friendly. You communicate efficiently, always keeping the user clearly informed about ongoing actions without unnecessary detail. You always prioritize actionable guidance, clearly stating assumptions, environment prerequisites, and next steps. Unless explicitly asked, you avoid excessively verbose explanations about your work.\n\n## AGENTS.md spec\n- Repos often contain AGENTS.md files. These files can appear anywhere within the repository.\n- These files are a way for humans to give you (the agent) instructions or tips for working within the container.\n- Some examples might be: coding conventions, info about how code is organized, or instructions for how to run or test code.\n- Instructions in AGENTS.md files:\n - The scope of an AGENTS.md file is the entire directory tree rooted at the folder that contains it.\n - For every file you touch in the final patch, you must obey instructions in any AGENTS.md file whose scope includes that file.\n - Instructions about code style, structure, naming, etc. apply only to code within the AGENTS.md file's scope, unless the file states otherwise.\n - More-deeply-nested AGENTS.md files take precedence in the case of conflicting instructions.\n - Direct system/developer/user instructions (as part of a prompt) take precedence over AGENTS.md instructions.\n- The contents of the AGENTS.md file at the root of the repo and any directories from the CWD up to the root are included with the developer message and don't need to be re-read. When working in a subdirectory of CWD, or a directory outside the CWD, check for any AGENTS.md files that may be applicable.\n\n## Autonomy and Persistence\nPersist until the task is fully handled end-to-end within the current turn whenever feasible: do not stop at analysis or partial fixes; carry changes through implementation, verification, and a clear explanation of outcomes unless the user explicitly pauses or redirects you.\n\nUnless the user explicitly asks for a plan, asks a question about the code, is brainstorming potential solutions, or some other intent that makes it clear that code should not be written, assume the user wants you to make code changes or run tools to solve the user's problem. In these cases, it's bad to output your proposed solution in a message, you should go ahead and actually implement the change. If you encounter challenges or blockers, you should attempt to resolve them yourself.\n\n## Responsiveness\n\n## Planning\n\nYou have access to an `update_plan` tool which tracks steps and progress and renders them to the user. Using the tool helps demonstrate that you've understood the task and convey how you're approaching it. Plans can help to make complex, ambiguous, or multi-phase work clearer and more collaborative for the user. A good plan should break the task into meaningful, logically ordered steps that are easy to verify as you go.\n\nNote that plans are not for padding out simple work with filler steps or stating the obvious. The content of your plan should not involve doing anything that you aren't capable of doing (i.e. don't try to test things that you can't test). Do not use plans for simple or single-step queries that you can just do or answer immediately.\n\nDo not repeat the full contents of the plan after an `update_plan` call — the harness already displays it. Instead, summarize the change made and highlight any important context or next step.\n\nBefore running a command, consider whether or not you have completed the previous step, and make sure to mark it as completed before moving on to the next step. It may be the case that you complete all steps in your plan after a single pass of implementation. If this is the case, you can simply mark all the planned steps as completed. Sometimes, you may need to change plans in the middle of a task: call `update_plan` with the updated plan and make sure to provide an `explanation` of the rationale when doing so.\n\nMaintain statuses in the tool: exactly one item in_progress at a time; mark items complete when done; post timely status transitions. Do not jump an item from pending to completed: always set it to in_progress first. Do not batch-complete multiple items after the fact. Finish with all items completed or explicitly canceled/deferred before ending the turn. Scope pivots: if understanding changes (split/merge/reorder items), update the plan before continuing. Do not let the plan go stale while coding.\n\nUse a plan when:\n\n- The task is non-trivial and will require multiple actions over a long time horizon.\n- There are logical phases or dependencies where sequencing matters.\n- The work has ambiguity that benefits from outlining high-level goals.\n- You want intermediate checkpoints for feedback and validation.\n- When the user asked you to do more than one thing in a single prompt\n- The user has asked you to use the plan tool (aka \"TODOs\")\n- You generate additional steps while working, and plan to do them before yielding to the user\n\n### Examples\n\n**High-quality plans**\n\nExample 1:\n\n1. Add CLI entry with file args\n2. Parse Markdown via CommonMark library\n3. Apply semantic HTML template\n4. Handle code blocks, images, links\n5. Add error handling for invalid files\n\nExample 2:\n\n1. Define CSS variables for colors\n2. Add toggle with localStorage state\n3. Refactor components to use variables\n4. Verify all views for readability\n5. Add smooth theme-change transition\n\nExample 3:\n\n1. Set up Node.js + WebSocket server\n2. Add join/leave broadcast events\n3. Implement messaging with timestamps\n4. Add usernames + mention highlighting\n5. Persist messages in lightweight DB\n6. Add typing indicators + unread count\n\n**Low-quality plans**\n\nExample 1:\n\n1. Create CLI tool\n2. Add Markdown parser\n3. Convert to HTML\n\nExample 2:\n\n1. Add dark mode toggle\n2. Save preference\n3. Make styles look good\n\nExample 3:\n\n1. Create single-file HTML game\n2. Run quick sanity check\n3. Summarize usage instructions\n\nIf you need to write a plan, only write high quality plans, not low quality ones.\n\n## Task execution\n\nYou are a coding agent. You must keep going until the query or task is completely resolved, before ending your turn and yielding back to the user. Persist until the task is fully handled end-to-end within the current turn whenever feasible and persevere even when function calls fail. Only terminate your turn when you are sure that the problem is solved. Autonomously resolve the query to the best of your ability, using the tools available to you, before coming back to the user. Do NOT guess or make up an answer.\n\nYou MUST adhere to the following criteria when solving queries:\n\n- Working on the repo(s) in the current environment is allowed, even if they are proprietary.\n- Analyzing code for vulnerabilities is allowed.\n- Showing user code and tool call details is allowed.\n- Use the `apply_patch` tool to edit files (NEVER try `applypatch` or `apply-patch`, only `apply_patch`). This is a FREEFORM tool, so do not wrap the patch in JSON.\n\nIf completing the user's task requires writing or modifying files, your code and final answer should follow these coding guidelines, though user instructions (i.e. AGENTS.md) may override these guidelines:\n\n- Fix the problem at the root cause rather than applying surface-level patches, when possible.\n- Avoid unneeded complexity in your solution.\n- Do not attempt to fix unrelated bugs or broken tests. It is not your responsibility to fix them. (You may mention them to the user in your final message though.)\n- Update documentation as necessary.\n- Keep changes consistent with the style of the existing codebase. Changes should be minimal and focused on the task.\n- If you're building a web app from scratch, give it a beautiful and modern UI, imbued with best UX practices.\n- Use `git log` and `git blame` to search the history of the codebase if additional context is required.\n- NEVER add copyright or license headers unless specifically requested.\n- Do not waste tokens by re-reading files after calling `apply_patch` on them. The tool call will fail if it didn't work. The same goes for making folders, deleting folders, etc.\n- Do not `git commit` your changes or create new git branches unless explicitly requested.\n- Do not add inline comments within code unless explicitly requested.\n- Do not use one-letter variable names unless explicitly requested.\n- NEVER output inline citations like \"【F:README.md†L5-L14】\" in your outputs. The CLI is not able to render these so they will just be broken in the UI. Instead, if you output valid filepaths, users will be able to click on them to open the files in their editor.\n\n## Validating your work\n\nIf the codebase has tests, or the ability to build or run tests, consider using them to verify changes once your work is complete.\n\nWhen testing, your philosophy should be to start as specific as possible to the code you changed so that you can catch issues efficiently, then make your way to broader tests as you build confidence. If there's no test for the code you changed, and if the adjacent patterns in the codebases show that there's a logical place for you to add a test, you may do so. However, do not add tests to codebases with no tests.\n\nSimilarly, once you're confident in correctness, you can suggest or use formatting commands to ensure that your code is well formatted. If there are issues you can iterate up to 3 times to get formatting right, but if you still can't manage it's better to save the user time and present them a correct solution where you call out the formatting in your final message. If the codebase does not have a formatter configured, do not add one.\n\nFor all of testing, running, building, and formatting, do not attempt to fix unrelated bugs. It is not your responsibility to fix them. (You may mention them to the user in your final message though.)\n\nBe mindful of whether to run validation commands proactively. In the absence of behavioral guidance:\n\n- When running in the non-interactive approval mode **never**, you can proactively run tests, lint and do whatever you need to ensure you've completed the task. If you are unable to run tests, you must still do your utmost best to complete the task.\n- When working in interactive approval modes like **untrusted**, or **on-request**, hold off on running tests or lint commands until the user is ready for you to finalize your output, because these commands take time to run and slow down iteration. Instead suggest what you want to do next, and let the user confirm first.\n- When working on test-related tasks, such as adding tests, fixing tests, or reproducing a bug to verify behavior, you may proactively run tests regardless of approval mode. Use your judgement to decide whether this is a test-related task.\n\n## Ambition vs. precision\n\nFor tasks that have no prior context (i.e. the user is starting something brand new), you should feel free to be ambitious and demonstrate creativity with your implementation.\n\nIf you're operating in an existing codebase, you should make sure you do exactly what the user asks with surgical precision. Treat the surrounding codebase with respect, and don't overstep (i.e. changing filenames or variables unnecessarily). You should balance being sufficiently ambitious and proactive when completing tasks of this nature.\n\nYou should use judicious initiative to decide on the right level of detail and complexity to deliver based on the user's needs. This means showing good judgment that you're capable of doing the right extras without gold-plating. This might be demonstrated by high-value, creative touches when scope of the task is vague; while being surgical and targeted when scope is tightly specified.\n\n## Presenting your work \n\nYour final message should read naturally, like an update from a concise teammate. For casual conversation, brainstorming tasks, or quick questions from the user, respond in a friendly, conversational tone. You should ask questions, suggest ideas, and adapt to the user’s style. If you've finished a large amount of work, when describing what you've done to the user, you should follow the final answer formatting guidelines to communicate substantive changes. You don't need to add structured formatting for one-word answers, greetings, or purely conversational exchanges.\n\nYou can skip heavy formatting for single, simple actions or confirmations. In these cases, respond in plain sentences with any relevant next step or quick option. Reserve multi-section structured responses for results that need grouping or explanation.\n\nThe user is working on the same computer as you, and has access to your work. As such there's no need to show the contents of files you have already written unless the user explicitly asks for them. Similarly, if you've created or modified files using `apply_patch`, there's no need to tell users to \"save the file\" or \"copy the code into a file\"—just reference the file path.\n\nIf there's something that you think you could help with as a logical next step, concisely ask the user if they want you to do so. Good examples of this are running tests, committing changes, or building out the next logical component. If there’s something that you couldn't do (even with approval) but that the user might want to do (such as verifying changes by running the app), include those instructions succinctly.\n\nBrevity is very important as a default. You should be very concise (i.e. no more than 10 lines), but can relax this requirement for tasks where additional detail and comprehensiveness is important for the user's understanding.\n\n### Final answer structure and style guidelines\n\nYou are producing plain text that will later be styled by the CLI. Follow these rules exactly. Formatting should make results easy to scan, but not feel mechanical. Use judgment to decide how much structure adds value.\n\n**Section Headers**\n\n- Use only when they improve clarity — they are not mandatory for every answer.\n- Choose descriptive names that fit the content\n- Keep headers short (1–3 words) and in `**Title Case**`. Always start headers with `**` and end with `**`\n- Leave no blank line before the first bullet under a header.\n- Section headers should only be used where they genuinely improve scanability; avoid fragmenting the answer.\n\n**Bullets**\n\n- Use `-` followed by a space for every bullet.\n- Merge related points when possible; avoid a bullet for every trivial detail.\n- Keep bullets to one line unless breaking for clarity is unavoidable.\n- Group into short lists (4–6 bullets) ordered by importance.\n- Use consistent keyword phrasing and formatting across sections.\n\n**Monospace**\n\n- Wrap all commands, file paths, env vars, code identifiers, and code samples in backticks (`` `...` ``).\n- Apply to inline examples and to bullet keywords if the keyword itself is a literal file/command.\n- Never mix monospace and bold markers; choose one based on whether it’s a keyword (`**`) or inline code/path (`` ` ``).\n\n**File References**\nWhen referencing files in your response, make sure to include the relevant start line and always follow the below rules:\n * Use inline code to make file paths clickable.\n * Each reference should have a stand alone path. Even if it's the same file.\n * Accepted: absolute, workspace‑relative, a/ or b/ diff prefixes, or bare filename/suffix.\n * Line/column (1‑based, optional): :line[:column] or #Lline[Ccolumn] (column defaults to 1).\n * Do not use URIs like file://, vscode://, or https://.\n * Do not provide range of lines\n * Examples: src/app.ts, src/app.ts:42, b/server/index.js#L10, C:\\repo\\project\\main.rs:12:5\n\n**Structure**\n\n- Place related bullets together; don’t mix unrelated concepts in the same section.\n- Order sections from general → specific → supporting info.\n- For subsections (e.g., “Binaries” under “Rust Workspace”), introduce with a bolded keyword bullet, then list items under it.\n- Match structure to complexity:\n - Multi-part or detailed results → use clear headers and grouped bullets.\n - Simple results → minimal headers, possibly just a short list or paragraph.\n\n**Tone**\n\n- Keep the voice collaborative and natural, like a coding partner handing off work.\n- Be concise and factual — no filler or conversational commentary and avoid unnecessary repetition\n- Use present tense and active voice (e.g., “Runs tests” not “This will run tests”).\n- Keep descriptions self-contained; don’t refer to “above” or “below”.\n- Use parallel structure in lists for consistency.\n\n**Verbosity**\n- Final answer compactness rules (enforced):\n - Tiny/small single-file change (≤ ~10 lines): 2–5 sentences or ≤3 bullets. No headings. 0–1 short snippet (≤3 lines) only if essential.\n - Medium change (single area or a few files): ≤6 bullets or 6–10 sentences. At most 1–2 short snippets total (≤8 lines each).\n - Large/multi-file change: Summarize per file with 1–2 bullets; avoid inlining code unless critical (still ≤2 short snippets total).\n - Never include \"before/after\" pairs, full method bodies, or large/scrolling code blocks in the final message. Prefer referencing file/symbol names instead.\n\n**Don’t**\n\n- Don’t use literal words “bold” or “monospace” in the content.\n- Don’t nest bullets or create deep hierarchies.\n- Don’t output ANSI escape codes directly — the CLI renderer applies them.\n- Don’t cram unrelated keywords into a single bullet; split for clarity.\n- Don’t let keyword lists run long — wrap or reformat for scanability.\n\nGenerally, ensure your final answers adapt their shape and depth to the request. For example, answers to code explanations should have a precise, structured explanation with code references that answer the question directly. For tasks with a simple implementation, lead with the outcome and supplement only with what’s needed for clarity. Larger changes can be presented as a logical walkthrough of your approach, grouping related steps, explaining rationale where it adds value, and highlighting next actions to accelerate the user. Your answers should provide the right level of detail while being easily scannable.\n\nFor casual greetings, acknowledgements, or other one-off conversational messages that are not delivering substantive information or structured results, respond naturally without section headers or bullet formatting.\n\n# Tool Guidelines\n\n## Shell commands\n\nWhen using the shell, you must adhere to the following guidelines:\n\n- When searching for text or files, prefer using `rg` or `rg --files` respectively because `rg` is much faster than alternatives like `grep`. (If the `rg` command is not found, then use alternatives.)\n- Do not use python scripts to attempt to output larger chunks of a file.\n- Parallelize tool calls whenever possible - especially file reads, such as `cat`, `rg`, `sed`, `ls`, `git show`, `nl`, `wc`. Use `multi_tool_use.parallel` to parallelize tool calls and only this.\n\n## apply_patch\n\nUse the `apply_patch` tool to edit files. Your patch language is a stripped‑down, file‑oriented diff format designed to be easy to parse and safe to apply. You can think of it as a high‑level envelope:\n\n*** Begin Patch\n[ one or more file sections ]\n*** End Patch\n\nWithin that envelope, you get a sequence of file operations.\nYou MUST include a header to specify the action you are taking.\nEach operation starts with one of three headers:\n\n*** Add File: - create a new file. Every following line is a + line (the initial contents).\n*** Delete File: - remove an existing file. Nothing follows.\n*** Update File: - patch an existing file in place (optionally with a rename).\n\nExample patch:\n\n```\n*** Begin Patch\n*** Add File: hello.txt\n+Hello world\n*** Update File: src/app.py\n*** Move to: src/main.py\n@@ def greet():\n-print(\"Hi\")\n+print(\"Hello, world!\")\n*** Delete File: obsolete.txt\n*** End Patch\n```\n\nIt is important to remember:\n\n- You must include a header with your intended action (Add/Delete/Update)\n- You must prefix new lines with `+` even when creating a new file\n\n## `update_plan`\n\nA tool named `update_plan` is available to you. You can use it to keep an up‑to‑date, step‑by‑step plan for the task.\n\nTo create a new plan, call `update_plan` with a short list of 1‑sentence steps (no more than 5-7 words each) with a `status` for each step (`pending`, `in_progress`, or `completed`).\n\nWhen steps have been completed, use `update_plan` to mark each finished step as `completed` and the next step you are working on as `in_progress`. There should always be exactly one `in_progress` step until everything is done. You can mark multiple items as complete in a single `update_plan` call.\n\nIf all steps are complete, ensure you call `update_plan` to mark all steps as `completed`.\n", "model_messages": null, "experimental_supported_tools": [], "available_in_plans": [ diff --git a/codex-rs/models-manager/prompt.md b/codex-rs/models-manager/prompt.md index 4886c7ef4455..907ff8b87702 100644 --- a/codex-rs/models-manager/prompt.md +++ b/codex-rs/models-manager/prompt.md @@ -158,7 +158,7 @@ For all of testing, running, building, and formatting, do not attempt to fix unr Be mindful of whether to run validation commands proactively. In the absence of behavioral guidance: -- When running in non-interactive approval modes like **never** or **on-failure**, proactively run tests, lint and do whatever you need to ensure you've completed the task. +- When running in the non-interactive approval mode **never**, proactively run tests, lint and do whatever you need to ensure you've completed the task. - When working in interactive approval modes like **untrusted**, or **on-request**, hold off on running tests or lint commands until the user is ready for you to finalize your output, because these commands take time to run and slow down iteration. Instead suggest what you want to do next, and let the user confirm first. - When working on test-related tasks, such as adding tests, fixing tests, or reproducing a bug to verify behavior, you may proactively run tests regardless of approval mode. Use your judgement to decide whether this is a test-related task. diff --git a/codex-rs/prompts/src/permissions_instructions.rs b/codex-rs/prompts/src/permissions_instructions.rs index a4a043f24fae..090254705e0e 100644 --- a/codex-rs/prompts/src/permissions_instructions.rs +++ b/codex-rs/prompts/src/permissions_instructions.rs @@ -18,8 +18,6 @@ const APPROVAL_POLICY_NEVER: &str = include_str!("../templates/permissions/approval_policy/never.md"); const APPROVAL_POLICY_UNLESS_TRUSTED: &str = include_str!("../templates/permissions/approval_policy/unless_trusted.md"); -const APPROVAL_POLICY_ON_FAILURE: &str = - include_str!("../templates/permissions/approval_policy/on_failure.md"); const APPROVAL_POLICY_ON_REQUEST_RULE: &str = include_str!("../templates/permissions/approval_policy/on_request.md"); const APPROVAL_POLICY_ON_REQUEST_AUTO_REVIEW: &str = @@ -231,7 +229,6 @@ fn approval_text( AskForApproval::UnlessTrusted => { with_request_permissions_tool(APPROVAL_POLICY_UNLESS_TRUSTED) } - AskForApproval::OnFailure => with_request_permissions_tool(APPROVAL_POLICY_ON_FAILURE), AskForApproval::OnRequest => on_request_instructions(), AskForApproval::Granular(granular_config) => granular_instructions( granular_config, diff --git a/codex-rs/prompts/src/permissions_instructions_tests.rs b/codex-rs/prompts/src/permissions_instructions_tests.rs index 8564a7cf1ecf..8250aea57d44 100644 --- a/codex-rs/prompts/src/permissions_instructions_tests.rs +++ b/codex-rs/prompts/src/permissions_instructions_tests.rs @@ -175,26 +175,6 @@ fn includes_request_permissions_tool_instructions_for_unless_trusted_when_enable assert!(text.contains("# request_permissions Tool")); } -#[test] -fn includes_request_permissions_tool_instructions_for_on_failure_when_enabled() { - let instructions = PermissionsInstructions::from_permissions_with_network( - SandboxMode::WorkspaceWrite, - NetworkAccess::Enabled, - PermissionsPromptConfig { - approval_policy: AskForApproval::OnFailure, - approvals_reviewer: ApprovalsReviewer::User, - exec_policy: &Policy::empty(), - exec_permission_approvals_enabled: false, - request_permissions_tool_enabled: true, - }, - /*writable_roots*/ None, - ); - - let text = instructions.body(); - assert!(text.contains("`approval_policy` is `on-failure`")); - assert!(text.contains("# request_permissions Tool")); -} - #[test] fn includes_request_permission_rule_instructions_for_on_request_when_enabled() { let instructions = PermissionsInstructions::from_permissions_with_network( diff --git a/codex-rs/prompts/templates/permissions/approval_policy/on_failure.md b/codex-rs/prompts/templates/permissions/approval_policy/on_failure.md deleted file mode 100644 index 7ee26dbd494c..000000000000 --- a/codex-rs/prompts/templates/permissions/approval_policy/on_failure.md +++ /dev/null @@ -1 +0,0 @@ -Approvals are your mechanism to get user consent to run shell commands without the sandbox. `approval_policy` is `on-failure`: The harness will allow all commands to run in the sandbox (if enabled), and failures will be escalated to the user for approval to run again without the sandbox. diff --git a/codex-rs/protocol/src/prompts/base_instructions/default.md b/codex-rs/protocol/src/prompts/base_instructions/default.md index 4886c7ef4455..907ff8b87702 100644 --- a/codex-rs/protocol/src/prompts/base_instructions/default.md +++ b/codex-rs/protocol/src/prompts/base_instructions/default.md @@ -158,7 +158,7 @@ For all of testing, running, building, and formatting, do not attempt to fix unr Be mindful of whether to run validation commands proactively. In the absence of behavioral guidance: -- When running in non-interactive approval modes like **never** or **on-failure**, proactively run tests, lint and do whatever you need to ensure you've completed the task. +- When running in the non-interactive approval mode **never**, proactively run tests, lint and do whatever you need to ensure you've completed the task. - When working in interactive approval modes like **untrusted**, or **on-request**, hold off on running tests or lint commands until the user is ready for you to finalize your output, because these commands take time to run and slow down iteration. Instead suggest what you want to do next, and let the user confirm first. - When working on test-related tasks, such as adding tests, fixing tests, or reproducing a bug to verify behavior, you may proactively run tests regardless of approval mode. Use your judgement to decide whether this is a test-related task. diff --git a/codex-rs/protocol/src/protocol.rs b/codex-rs/protocol/src/protocol.rs index 8a678281d22b..7aa6bbcadd39 100644 --- a/codex-rs/protocol/src/protocol.rs +++ b/codex-rs/protocol/src/protocol.rs @@ -870,14 +870,6 @@ pub enum AskForApproval { #[strum(serialize = "untrusted")] UnlessTrusted, - /// DEPRECATED: *All* commands are auto‑approved, but they are expected to - /// run inside a sandbox where network access is disabled and writes are - /// confined to a specific set of paths. If the command fails, it will be - /// escalated to the user to approve execution without a sandbox. - /// Prefer `OnRequest` for interactive runs or `Never` for non-interactive - /// runs. - OnFailure, - /// The model decides when to ask the user for approval. #[default] OnRequest, diff --git a/codex-rs/utils/cli/src/approval_mode_cli_arg.rs b/codex-rs/utils/cli/src/approval_mode_cli_arg.rs index ee4ecabcb6db..255ff6ea596b 100644 --- a/codex-rs/utils/cli/src/approval_mode_cli_arg.rs +++ b/codex-rs/utils/cli/src/approval_mode_cli_arg.rs @@ -12,12 +12,6 @@ pub enum ApprovalModeCliArg { /// is not in the "trusted" set. Untrusted, - /// DEPRECATED: Run all commands without asking for user approval. - /// Only asks for approval if a command fails to execute, in which case it - /// will escalate to the user to ask for un-sandboxed execution. - /// Prefer `on-request` for interactive runs or `never` for non-interactive runs. - OnFailure, - /// The model decides when to ask the user for approval. OnRequest, @@ -30,7 +24,6 @@ impl From for AskForApproval { fn from(value: ApprovalModeCliArg) -> Self { match value { ApprovalModeCliArg::Untrusted => AskForApproval::UnlessTrusted, - ApprovalModeCliArg::OnFailure => AskForApproval::OnFailure, ApprovalModeCliArg::OnRequest => AskForApproval::OnRequest, ApprovalModeCliArg::Never => AskForApproval::Never, } From ee7b8a420eab02aeeaa86191ad7244f835564476 Mon Sep 17 00:00:00 2001 From: Dylan Hurd Date: Mon, 15 Jun 2026 17:57:03 -0700 Subject: [PATCH 2/6] regenerate sdk --- .../generated/notification_registry.py | 135 +++++---- .../src/openai_codex/generated/v2_all.py | 283 +++++++++++++++++- 2 files changed, 338 insertions(+), 80 deletions(-) diff --git a/sdk/python/src/openai_codex/generated/notification_registry.py b/sdk/python/src/openai_codex/generated/notification_registry.py index d5e620a7a3cd..cf9df32270fe 100644 --- a/sdk/python/src/openai_codex/generated/notification_registry.py +++ b/sdk/python/src/openai_codex/generated/notification_registry.py @@ -5,70 +5,74 @@ from pydantic import BaseModel -from .v2_all import AccountLoginCompletedNotification -from .v2_all import AccountRateLimitsUpdatedNotification -from .v2_all import AccountUpdatedNotification -from .v2_all import AgentMessageDeltaNotification -from .v2_all import AppListUpdatedNotification -from .v2_all import CommandExecOutputDeltaNotification -from .v2_all import CommandExecutionOutputDeltaNotification -from .v2_all import ConfigWarningNotification -from .v2_all import ContextCompactedNotification -from .v2_all import DeprecationNoticeNotification -from .v2_all import ErrorNotification -from .v2_all import ExternalAgentConfigImportCompletedNotification -from .v2_all import FileChangeOutputDeltaNotification -from .v2_all import FileChangePatchUpdatedNotification -from .v2_all import FsChangedNotification -from .v2_all import FuzzyFileSearchSessionCompletedNotification -from .v2_all import FuzzyFileSearchSessionUpdatedNotification -from .v2_all import GuardianWarningNotification -from .v2_all import HookCompletedNotification -from .v2_all import HookStartedNotification -from .v2_all import ItemCompletedNotification -from .v2_all import ItemGuardianApprovalReviewCompletedNotification -from .v2_all import ItemGuardianApprovalReviewStartedNotification -from .v2_all import ItemStartedNotification -from .v2_all import McpServerOauthLoginCompletedNotification -from .v2_all import McpServerStatusUpdatedNotification -from .v2_all import McpToolCallProgressNotification -from .v2_all import ModelReroutedNotification -from .v2_all import ModelVerificationNotification -from .v2_all import PlanDeltaNotification -from .v2_all import ProcessExitedNotification -from .v2_all import ProcessOutputDeltaNotification -from .v2_all import ReasoningSummaryPartAddedNotification -from .v2_all import ReasoningSummaryTextDeltaNotification -from .v2_all import ReasoningTextDeltaNotification -from .v2_all import RemoteControlStatusChangedNotification -from .v2_all import ServerRequestResolvedNotification -from .v2_all import SkillsChangedNotification -from .v2_all import TerminalInteractionNotification -from .v2_all import ThreadArchivedNotification -from .v2_all import ThreadClosedNotification -from .v2_all import ThreadGoalClearedNotification -from .v2_all import ThreadGoalUpdatedNotification -from .v2_all import ThreadNameUpdatedNotification -from .v2_all import ThreadRealtimeClosedNotification -from .v2_all import ThreadRealtimeErrorNotification -from .v2_all import ThreadRealtimeItemAddedNotification -from .v2_all import ThreadRealtimeOutputAudioDeltaNotification -from .v2_all import ThreadRealtimeSdpNotification -from .v2_all import ThreadRealtimeStartedNotification -from .v2_all import ThreadRealtimeTranscriptDeltaNotification -from .v2_all import ThreadRealtimeTranscriptDoneNotification -from .v2_all import ThreadSettingsUpdatedNotification -from .v2_all import ThreadStartedNotification -from .v2_all import ThreadStatusChangedNotification -from .v2_all import ThreadTokenUsageUpdatedNotification -from .v2_all import ThreadUnarchivedNotification -from .v2_all import TurnCompletedNotification -from .v2_all import TurnDiffUpdatedNotification -from .v2_all import TurnPlanUpdatedNotification -from .v2_all import TurnStartedNotification -from .v2_all import WarningNotification -from .v2_all import WindowsSandboxSetupCompletedNotification -from .v2_all import WindowsWorldWritableWarningNotification +from .v2_all import ( + AccountLoginCompletedNotification, + AccountRateLimitsUpdatedNotification, + AccountUpdatedNotification, + AgentMessageDeltaNotification, + AppListUpdatedNotification, + CommandExecOutputDeltaNotification, + CommandExecutionOutputDeltaNotification, + ConfigWarningNotification, + ContextCompactedNotification, + DeprecationNoticeNotification, + ErrorNotification, + ExternalAgentConfigImportCompletedNotification, + FileChangeOutputDeltaNotification, + FileChangePatchUpdatedNotification, + FsChangedNotification, + FuzzyFileSearchSessionCompletedNotification, + FuzzyFileSearchSessionUpdatedNotification, + GuardianWarningNotification, + HookCompletedNotification, + HookStartedNotification, + ItemCompletedNotification, + ItemGuardianApprovalReviewCompletedNotification, + ItemGuardianApprovalReviewStartedNotification, + ItemStartedNotification, + McpServerOauthLoginCompletedNotification, + McpServerStatusUpdatedNotification, + McpToolCallProgressNotification, + ModelReroutedNotification, + ModelVerificationNotification, + PlanDeltaNotification, + ProcessExitedNotification, + ProcessOutputDeltaNotification, + ReasoningSummaryPartAddedNotification, + ReasoningSummaryTextDeltaNotification, + ReasoningTextDeltaNotification, + RemoteControlStatusChangedNotification, + ServerRequestResolvedNotification, + SkillsChangedNotification, + TerminalInteractionNotification, + ThreadArchivedNotification, + ThreadClosedNotification, + ThreadDeletedNotification, + ThreadGoalClearedNotification, + ThreadGoalUpdatedNotification, + ThreadNameUpdatedNotification, + ThreadRealtimeClosedNotification, + ThreadRealtimeErrorNotification, + ThreadRealtimeItemAddedNotification, + ThreadRealtimeOutputAudioDeltaNotification, + ThreadRealtimeSdpNotification, + ThreadRealtimeStartedNotification, + ThreadRealtimeTranscriptDeltaNotification, + ThreadRealtimeTranscriptDoneNotification, + ThreadSettingsUpdatedNotification, + ThreadStartedNotification, + ThreadStatusChangedNotification, + ThreadTokenUsageUpdatedNotification, + ThreadUnarchivedNotification, + TurnCompletedNotification, + TurnDiffUpdatedNotification, + TurnModerationMetadataNotification, + TurnPlanUpdatedNotification, + TurnStartedNotification, + WarningNotification, + WindowsSandboxSetupCompletedNotification, + WindowsWorldWritableWarningNotification, +) NOTIFICATION_MODELS: dict[str, type[BaseModel]] = { "account/login/completed": AccountLoginCompletedNotification, @@ -112,6 +116,7 @@ "thread/archived": ThreadArchivedNotification, "thread/closed": ThreadClosedNotification, "thread/compacted": ContextCompactedNotification, + "thread/deleted": ThreadDeletedNotification, "thread/goal/cleared": ThreadGoalClearedNotification, "thread/goal/updated": ThreadGoalUpdatedNotification, "thread/name/updated": ThreadNameUpdatedNotification, @@ -130,6 +135,7 @@ "thread/unarchived": ThreadUnarchivedNotification, "turn/completed": TurnCompletedNotification, "turn/diff/updated": TurnDiffUpdatedNotification, + "turn/moderationMetadata": TurnModerationMetadataNotification, "turn/plan/updated": TurnPlanUpdatedNotification, "turn/started": TurnStartedNotification, "warning": WarningNotification, @@ -161,6 +167,7 @@ ThreadGoalUpdatedNotification, ThreadTokenUsageUpdatedNotification, TurnDiffUpdatedNotification, + TurnModerationMetadataNotification, TurnPlanUpdatedNotification, ) diff --git a/sdk/python/src/openai_codex/generated/v2_all.py b/sdk/python/src/openai_codex/generated/v2_all.py index c024a2c8c07c..34978a612456 100644 --- a/sdk/python/src/openai_codex/generated/v2_all.py +++ b/sdk/python/src/openai_codex/generated/v2_all.py @@ -2,9 +2,11 @@ # filename: codex_app_server_protocol.v2.schemas.json from __future__ import annotations -from pydantic import BaseModel, ConfigDict, Field, RootModel -from typing import Annotated, Any, Literal + from enum import Enum +from typing import Annotated, Any, Literal + +from pydantic import BaseModel, ConfigDict, Field, RootModel class CodexAppServerProtocolV2(BaseModel): @@ -49,6 +51,25 @@ class AccountLoginCompletedNotification(BaseModel): success: bool +class AccountTokenUsageDailyBucket(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + start_date: Annotated[str, Field(alias="startDate")] + tokens: int + + +class AccountTokenUsageSummary(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + current_streak_days: Annotated[int | None, Field(alias="currentStreakDays")] = None + lifetime_tokens: Annotated[int | None, Field(alias="lifetimeTokens")] = None + longest_running_turn_sec: Annotated[int | None, Field(alias="longestRunningTurnSec")] = None + longest_streak_days: Annotated[int | None, Field(alias="longestStreakDays")] = None + peak_daily_tokens: Annotated[int | None, Field(alias="peakDailyTokens")] = None + + class ActivePermissionProfile(BaseModel): model_config = ConfigDict( populate_by_name=True, @@ -99,6 +120,33 @@ class AgentMessageDeltaNotification(BaseModel): turn_id: Annotated[str, Field(alias="turnId")] +class InputTextAgentMessageInputContent(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + text: str + type: Annotated[Literal["input_text"], Field(title="InputTextAgentMessageInputContentType")] + + +class EncryptedContentAgentMessageInputContent(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + encrypted_content: str + type: Annotated[ + Literal["encrypted_content"], Field(title="EncryptedContentAgentMessageInputContentType") + ] + + +class AgentMessageInputContent( + RootModel[InputTextAgentMessageInputContent | EncryptedContentAgentMessageInputContent] +): + model_config = ConfigDict( + populate_by_name=True, + ) + root: InputTextAgentMessageInputContent | EncryptedContentAgentMessageInputContent + + class AgentPath(RootModel[str]): model_config = ConfigDict( populate_by_name=True, @@ -146,11 +194,16 @@ class AppSummary(BaseModel): model_config = ConfigDict( populate_by_name=True, ) + category: str | None = None description: str | None = None id: str install_url: Annotated[str | None, Field(alias="installUrl")] = None name: str - needs_auth: Annotated[bool, Field(alias="needsAuth")] + + +class AppTemplateUnavailableReason(Enum): + not_configured_for_workspace = "NOT_CONFIGURED_FOR_WORKSPACE" + no_active_workspace = "NO_ACTIVE_WORKSPACE" class AppToolApproval(Enum): @@ -184,6 +237,7 @@ class AppsDefaultConfig(BaseModel): model_config = ConfigDict( populate_by_name=True, ) + approvals_reviewer: ApprovalsReviewer | None = None destructive_enabled: bool | None = True enabled: bool | None = True open_world_enabled: bool | None = True @@ -218,7 +272,6 @@ class AppsListParams(BaseModel): class AskForApprovalValue(Enum): untrusted = "untrusted" - on_failure = "on-failure" on_request = "on-request" never = "never" @@ -254,6 +307,8 @@ class AuthMode(Enum): chatgpt = "chatgpt" chatgpt_auth_tokens = "chatgptAuthTokens" agent_identity = "agentIdentity" + personal_access_token = "personalAccessToken" + bedrock_api_key = "bedrockApiKey" class AutoCompactTokenLimitScope(Enum): @@ -293,6 +348,25 @@ class CancelLoginAccountStatus(Enum): not_found = "notFound" +class EnvironmentCapabilityRootLocation(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + environment_id: Annotated[str, Field(alias="environmentId")] + path: str + type: Annotated[Literal["environment"], Field(title="EnvironmentCapabilityRootLocationType")] + + +class CapabilityRootLocation(RootModel[EnvironmentCapabilityRootLocation]): + model_config = ConfigDict( + populate_by_name=True, + ) + root: Annotated[ + EnvironmentCapabilityRootLocation, + Field(description="Location used to resolve a selected capability root."), + ] + + class ClientInfo(BaseModel): model_config = ConfigDict( populate_by_name=True, @@ -782,6 +856,11 @@ class ContextCompactedNotification(BaseModel): turn_id: Annotated[str, Field(alias="turnId")] +class ConversationTextRole(Enum): + user = "user" + developer = "developer" + + class CreditsSnapshot(BaseModel): model_config = ConfigDict( populate_by_name=True, @@ -1384,6 +1463,16 @@ class GetAccountParams(BaseModel): ] = None +class GetAccountTokenUsageResponse(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + daily_usage_buckets: Annotated[ + list[AccountTokenUsageDailyBucket] | None, Field(alias="dailyUsageBuckets") + ] = None + summary: AccountTokenUsageSummary + + class GitInfo(BaseModel): model_config = ConfigDict( populate_by_name=True, @@ -1958,6 +2047,7 @@ class McpServerStatusUpdatedNotification(BaseModel): error: str | None = None name: str status: McpServerStartupState + thread_id: Annotated[str | None, Field(alias="threadId")] = None class McpServerToolCallParams(BaseModel): @@ -2674,6 +2764,11 @@ class RateLimitWindow(BaseModel): window_duration_mins: Annotated[int | None, Field(alias="windowDurationMins")] = None +class RealtimeConversationArchitecture(Enum): + realtimeapi = "realtimeapi" + avas = "avas" + + class RealtimeConversationVersion(Enum): v1 = "v1" v2 = "v2" @@ -2716,13 +2811,16 @@ class RealtimeVoicesList(BaseModel): v2: list[RealtimeVoice] -class ReasoningEffort(Enum): - none = "none" - minimal = "minimal" - low = "low" - medium = "medium" - high = "high" - xhigh = "xhigh" +class ReasoningEffort(RootModel[str]): + model_config = ConfigDict( + populate_by_name=True, + ) + root: Annotated[ + str, + Field( + description="A non-empty reasoning effort value advertised by the model.", min_length=1 + ), + ] class ReasoningEffortOption(BaseModel): @@ -2830,6 +2928,20 @@ class RemoteControlConnectionStatus(Enum): errored = "errored" +class RemoteControlDisableParams(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + ephemeral: bool | None = None + + +class RemoteControlEnableParams(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + ephemeral: bool | None = None + + class RemoteControlStatusChangedNotification(BaseModel): model_config = ConfigDict( populate_by_name=True, @@ -2911,6 +3023,16 @@ class ResourceTemplate(BaseModel): uri_template: Annotated[str, Field(alias="uriTemplate")] +class AgentMessageResponseItem(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + author: str + content: list[AgentMessageInputContent] + recipient: str + type: Annotated[Literal["agent_message"], Field(title="AgentMessageResponseItemType")] + + class ReasoningResponseItem(BaseModel): model_config = ConfigDict( populate_by_name=True, @@ -3209,6 +3331,18 @@ class SandboxWorkspaceWrite(BaseModel): writable_roots: list[str] | None = [] +class SelectedCapabilityRoot(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + id: Annotated[ + str, Field(description="Stable identifier supplied by the capability selection platform.") + ] + location: Annotated[ + CapabilityRootLocation, Field(description="Where the selected root can be resolved.") + ] + + class SendAddCreditsNudgeEmailParams(BaseModel): model_config = ConfigDict( populate_by_name=True, @@ -3607,6 +3741,12 @@ class SpendControlLimitSnapshot(BaseModel): used: str +class SubAgentActivityKind(Enum): + started = "started" + interacted = "interacted" + interrupted = "interrupted" + + class SubAgentSourceValue(Enum): review = "review" compact = "compact" @@ -3740,6 +3880,27 @@ class ThreadCompactStartResponse(BaseModel): ) +class ThreadDeleteParams(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + thread_id: Annotated[str, Field(alias="threadId")] + + +class ThreadDeleteResponse(BaseModel): + pass + model_config = ConfigDict( + populate_by_name=True, + ) + + +class ThreadDeletedNotification(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + thread_id: Annotated[str, Field(alias="threadId")] + + class ThreadGoalClearParams(BaseModel): model_config = ConfigDict( populate_by_name=True, @@ -3916,6 +4077,17 @@ class DynamicToolCallThreadItem(BaseModel): type: Annotated[Literal["dynamicToolCall"], Field(title="DynamicToolCallThreadItemType")] +class SubAgentActivityThreadItem(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + agent_path: Annotated[str, Field(alias="agentPath")] + agent_thread_id: Annotated[str, Field(alias="agentThreadId")] + id: str + kind: SubAgentActivityKind + type: Annotated[Literal["subAgentActivity"], Field(title="SubAgentActivityThreadItemType")] + + class ImageViewThreadItem(BaseModel): model_config = ConfigDict( populate_by_name=True, @@ -4255,10 +4427,11 @@ class ThreadSortKey(Enum): updated_at = "updated_at" -class ThreadSource(Enum): - user = "user" - subagent = "subagent" - memory_consolidation = "memory_consolidation" +class ThreadSource(RootModel[str]): + model_config = ConfigDict( + populate_by_name=True, + ) + root: str class ThreadSourceKind(Enum): @@ -4417,6 +4590,15 @@ class TurnItemsView(Enum): full = "full" +class TurnModerationMetadataNotification(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + metadata: Any + thread_id: Annotated[str, Field(alias="threadId")] + turn_id: Annotated[str, Field(alias="turnId")] + + class TurnPlanStepStatus(Enum): pending = "pending" in_progress = "inProgress" @@ -4717,6 +4899,21 @@ class AppMetadata(BaseModel): version_notes: Annotated[str | None, Field(alias="versionNotes")] = None +class AppTemplateSummary(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + canonical_connector_id: Annotated[str | None, Field(alias="canonicalConnectorId")] = None + category: str | None = None + description: str | None = None + logo_url: Annotated[str | None, Field(alias="logoUrl")] = None + logo_url_dark: Annotated[str | None, Field(alias="logoUrlDark")] = None + materialized_app_ids: Annotated[list[str], Field(alias="materializedAppIds")] + name: str + reason: AppTemplateUnavailableReason | None = None + template_id: Annotated[str, Field(alias="templateId")] + + class AppsConfig(BaseModel): model_config = ConfigDict( populate_by_name=True, @@ -4758,6 +4955,15 @@ class ThreadArchiveRequest(BaseModel): params: ThreadArchiveParams +class ThreadDeleteRequest(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + id: RequestId + method: Annotated[Literal["thread/delete"], Field(title="Thread/deleteRequestMethod")] + params: ThreadDeleteParams + + class ThreadUnsubscribeRequest(BaseModel): model_config = ConfigDict( populate_by_name=True, @@ -5302,6 +5508,15 @@ class AccountRateLimitsReadRequest(BaseModel): params: None = None +class AccountUsageReadRequest(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + id: RequestId + method: Annotated[Literal["account/usage/read"], Field(title="Account/usage/readRequestMethod")] + params: None = None + + class AccountSendAddCreditsNudgeEmailRequest(BaseModel): model_config = ConfigDict( populate_by_name=True, @@ -5620,10 +5835,13 @@ class ConfigRequirements(BaseModel): ) allow_appshots: Annotated[bool | None, Field(alias="allowAppshots")] = None allow_managed_hooks_only: Annotated[bool | None, Field(alias="allowManagedHooksOnly")] = None + allow_remote_control: Annotated[bool | None, Field(alias="allowRemoteControl")] = None allowed_approval_policies: Annotated[ list[AskForApproval] | None, Field(alias="allowedApprovalPolicies") ] = None - allowed_permissions: Annotated[list[str] | None, Field(alias="allowedPermissions")] = None + allowed_permission_profiles: Annotated[ + dict[str, Any] | None, Field(alias="allowedPermissionProfiles") + ] = None allowed_sandbox_modes: Annotated[ list[SandboxMode] | None, Field(alias="allowedSandboxModes") ] = None @@ -5634,6 +5852,7 @@ class ConfigRequirements(BaseModel): list[WindowsSandboxSetupMode] | None, Field(alias="allowedWindowsSandboxImplementations") ] = None computer_use: Annotated[ComputerUseRequirements | None, Field(alias="computerUse")] = None + default_permissions: Annotated[str | None, Field(alias="defaultPermissions")] = None enforce_residency: Annotated[ResidencyRequirement | None, Field(alias="enforceResidency")] = ( None ) @@ -6214,6 +6433,14 @@ class ThreadArchivedServerNotification(BaseModel): params: ThreadArchivedNotification +class ThreadDeletedServerNotification(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + method: Annotated[Literal["thread/deleted"], Field(title="Thread/deletedNotificationMethod")] + params: ThreadDeletedNotification + + class ThreadUnarchivedServerNotification(BaseModel): model_config = ConfigDict( populate_by_name=True, @@ -6328,6 +6555,16 @@ class AccountUpdatedServerNotification(BaseModel): params: AccountUpdatedNotification +class TurnModerationMetadataServerNotification(BaseModel): + model_config = ConfigDict( + populate_by_name=True, + ) + method: Annotated[ + Literal["turn/moderationMetadata"], Field(title="Turn/moderationMetadataNotificationMethod") + ] + params: TurnModerationMetadataNotification + + class WarningServerNotification(BaseModel): model_config = ConfigDict( populate_by_name=True, @@ -6691,6 +6928,7 @@ class ThreadItem( | McpToolCallThreadItem | DynamicToolCallThreadItem | CollabAgentToolCallThreadItem + | SubAgentActivityThreadItem | WebSearchThreadItem | ImageViewThreadItem | ImageGenerationThreadItem @@ -6713,6 +6951,7 @@ class ThreadItem( | McpToolCallThreadItem | DynamicToolCallThreadItem | CollabAgentToolCallThreadItem + | SubAgentActivityThreadItem | WebSearchThreadItem | ImageViewThreadItem | ImageGenerationThreadItem @@ -7504,6 +7743,7 @@ class CustomToolCallOutputResponseItem(BaseModel): class ResponseItem( RootModel[ MessageResponseItem + | AgentMessageResponseItem | ReasoningResponseItem | LocalShellCallResponseItem | FunctionCallResponseItem @@ -7525,6 +7765,7 @@ class ResponseItem( ) root: ( MessageResponseItem + | AgentMessageResponseItem | ReasoningResponseItem | LocalShellCallResponseItem | FunctionCallResponseItem @@ -7878,12 +8119,14 @@ class PluginDetail(BaseModel): model_config = ConfigDict( populate_by_name=True, ) + app_templates: Annotated[list[AppTemplateSummary], Field(alias="appTemplates")] apps: list[AppSummary] description: str | None = None hooks: list[PluginHookSummary] marketplace_name: Annotated[str, Field(alias="marketplaceName")] marketplace_path: Annotated[AbsolutePathBuf | None, Field(alias="marketplacePath")] = None mcp_servers: Annotated[list[str], Field(alias="mcpServers")] + share_url: Annotated[str | None, Field(alias="shareUrl")] = None skills: list[SkillSummary] summary: PluginSummary @@ -8278,6 +8521,7 @@ class ClientRequest( | ThreadResumeRequest | ThreadForkRequest | ThreadArchiveRequest + | ThreadDeleteRequest | ThreadUnsubscribeRequest | ThreadNameSetRequest | ThreadGoalSetRequest @@ -8341,6 +8585,7 @@ class ClientRequest( | AccountLoginCancelRequest | AccountLogoutRequest | AccountRateLimitsReadRequest + | AccountUsageReadRequest | AccountSendAddCreditsNudgeEmailRequest | FeedbackUploadRequest | CommandExecRequest @@ -8366,6 +8611,7 @@ class ClientRequest( | ThreadResumeRequest | ThreadForkRequest | ThreadArchiveRequest + | ThreadDeleteRequest | ThreadUnsubscribeRequest | ThreadNameSetRequest | ThreadGoalSetRequest @@ -8429,6 +8675,7 @@ class ClientRequest( | AccountLoginCancelRequest | AccountLogoutRequest | AccountRateLimitsReadRequest + | AccountUsageReadRequest | AccountSendAddCreditsNudgeEmailRequest | FeedbackUploadRequest | CommandExecRequest @@ -8482,6 +8729,7 @@ class ServerNotification( | ThreadStartedServerNotification | ThreadStatusChangedServerNotification | ThreadArchivedServerNotification + | ThreadDeletedServerNotification | ThreadUnarchivedServerNotification | ThreadClosedServerNotification | SkillsChangedServerNotification @@ -8525,6 +8773,7 @@ class ServerNotification( | ThreadCompactedServerNotification | ModelReroutedServerNotification | ModelVerificationServerNotification + | TurnModerationMetadataServerNotification | WarningServerNotification | GuardianWarningServerNotification | DeprecationNoticeServerNotification @@ -8552,6 +8801,7 @@ class ServerNotification( | ThreadStartedServerNotification | ThreadStatusChangedServerNotification | ThreadArchivedServerNotification + | ThreadDeletedServerNotification | ThreadUnarchivedServerNotification | ThreadClosedServerNotification | SkillsChangedServerNotification @@ -8595,6 +8845,7 @@ class ServerNotification( | ThreadCompactedServerNotification | ModelReroutedServerNotification | ModelVerificationServerNotification + | TurnModerationMetadataServerNotification | WarningServerNotification | GuardianWarningServerNotification | DeprecationNoticeServerNotification From 55425ec67635777335d0850ba28dd975f80c6bc3 Mon Sep 17 00:00:00 2001 From: Dylan Hurd Date: Mon, 15 Jun 2026 22:19:54 -0700 Subject: [PATCH 3/6] codex: address PR review feedback (#28418) --- codex-rs/core/src/session/tests/guardian_tests.rs | 4 ++-- codex-rs/protocol/src/protocol.rs | 15 +++++++++++++++ sdk/typescript/src/threadOptions.ts | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/codex-rs/core/src/session/tests/guardian_tests.rs b/codex-rs/core/src/session/tests/guardian_tests.rs index 32e4ef9820ce..a146d91869b1 100644 --- a/codex-rs/core/src/session/tests/guardian_tests.rs +++ b/codex-rs/core/src/session/tests/guardian_tests.rs @@ -93,7 +93,7 @@ async fn request_permissions_routes_to_guardian_when_reviewer_is_enabled() { *session.active_turn.lock().await = Some(ActiveTurn::default()); turn_context_raw .approval_policy - .set(AskForApproval::Never) + .set(AskForApproval::OnRequest) .expect("test setup should allow updating approval policy"); let mut config = (*turn_context_raw.config).clone(); config @@ -407,7 +407,7 @@ async fn strict_auto_review_turn_grant_forces_guardian_for_shell_command_policy_ turn_context_raw .approval_policy - .set(AskForApproval::OnRequest) + .set(AskForApproval::Never) .expect("test setup should allow updating approval policy"); turn_context_raw.permission_profile = codex_protocol::models::PermissionProfile::Disabled; let mut config = (*turn_context_raw.config).clone(); diff --git a/codex-rs/protocol/src/protocol.rs b/codex-rs/protocol/src/protocol.rs index 7aa6bbcadd39..6e93dc91209e 100644 --- a/codex-rs/protocol/src/protocol.rs +++ b/codex-rs/protocol/src/protocol.rs @@ -871,6 +871,7 @@ pub enum AskForApproval { UnlessTrusted, /// The model decides when to ask the user for approval. + #[serde(alias = "on-failure")] #[default] OnRequest, @@ -5431,6 +5432,20 @@ mod tests { Ok(()) } + #[test] + fn turn_context_item_deserializes_legacy_on_failure_as_on_request() -> Result<()> { + let item: TurnContextItem = serde_json::from_value(json!({ + "cwd": test_path_buf("/tmp"), + "approval_policy": "on-failure", + "sandbox_policy": { "type": "danger-full-access" }, + "model": "gpt-5", + "summary": "auto", + }))?; + + assert_eq!(item.approval_policy, AskForApproval::OnRequest); + Ok(()) + } + #[test] fn multi_agent_version_uses_newest_present_session_meta_value() -> Result<()> { let thread_id = ThreadId::from_string("67e55044-10b1-426f-9247-bb680e5fe0c8")?; diff --git a/sdk/typescript/src/threadOptions.ts b/sdk/typescript/src/threadOptions.ts index 7bde5e4d78fe..c9e0cc644bd9 100644 --- a/sdk/typescript/src/threadOptions.ts +++ b/sdk/typescript/src/threadOptions.ts @@ -1,4 +1,4 @@ -export type ApprovalMode = "never" | "on-request" | "on-failure" | "untrusted"; +export type ApprovalMode = "never" | "on-request" | "untrusted"; export type SandboxMode = "read-only" | "workspace-write" | "danger-full-access"; From 95fc7ac0878347836407f6ef9dc19fb42d4a64a9 Mon Sep 17 00:00:00 2001 From: Dylan Hurd Date: Mon, 15 Jun 2026 22:33:11 -0700 Subject: [PATCH 4/6] codex: fix Python SDK contract generation on PR #28418 --- .../generated/notification_registry.py | 135 ++++----- .../src/openai_codex/generated/v2_all.py | 283 +----------------- 2 files changed, 80 insertions(+), 338 deletions(-) diff --git a/sdk/python/src/openai_codex/generated/notification_registry.py b/sdk/python/src/openai_codex/generated/notification_registry.py index cf9df32270fe..d5e620a7a3cd 100644 --- a/sdk/python/src/openai_codex/generated/notification_registry.py +++ b/sdk/python/src/openai_codex/generated/notification_registry.py @@ -5,74 +5,70 @@ from pydantic import BaseModel -from .v2_all import ( - AccountLoginCompletedNotification, - AccountRateLimitsUpdatedNotification, - AccountUpdatedNotification, - AgentMessageDeltaNotification, - AppListUpdatedNotification, - CommandExecOutputDeltaNotification, - CommandExecutionOutputDeltaNotification, - ConfigWarningNotification, - ContextCompactedNotification, - DeprecationNoticeNotification, - ErrorNotification, - ExternalAgentConfigImportCompletedNotification, - FileChangeOutputDeltaNotification, - FileChangePatchUpdatedNotification, - FsChangedNotification, - FuzzyFileSearchSessionCompletedNotification, - FuzzyFileSearchSessionUpdatedNotification, - GuardianWarningNotification, - HookCompletedNotification, - HookStartedNotification, - ItemCompletedNotification, - ItemGuardianApprovalReviewCompletedNotification, - ItemGuardianApprovalReviewStartedNotification, - ItemStartedNotification, - McpServerOauthLoginCompletedNotification, - McpServerStatusUpdatedNotification, - McpToolCallProgressNotification, - ModelReroutedNotification, - ModelVerificationNotification, - PlanDeltaNotification, - ProcessExitedNotification, - ProcessOutputDeltaNotification, - ReasoningSummaryPartAddedNotification, - ReasoningSummaryTextDeltaNotification, - ReasoningTextDeltaNotification, - RemoteControlStatusChangedNotification, - ServerRequestResolvedNotification, - SkillsChangedNotification, - TerminalInteractionNotification, - ThreadArchivedNotification, - ThreadClosedNotification, - ThreadDeletedNotification, - ThreadGoalClearedNotification, - ThreadGoalUpdatedNotification, - ThreadNameUpdatedNotification, - ThreadRealtimeClosedNotification, - ThreadRealtimeErrorNotification, - ThreadRealtimeItemAddedNotification, - ThreadRealtimeOutputAudioDeltaNotification, - ThreadRealtimeSdpNotification, - ThreadRealtimeStartedNotification, - ThreadRealtimeTranscriptDeltaNotification, - ThreadRealtimeTranscriptDoneNotification, - ThreadSettingsUpdatedNotification, - ThreadStartedNotification, - ThreadStatusChangedNotification, - ThreadTokenUsageUpdatedNotification, - ThreadUnarchivedNotification, - TurnCompletedNotification, - TurnDiffUpdatedNotification, - TurnModerationMetadataNotification, - TurnPlanUpdatedNotification, - TurnStartedNotification, - WarningNotification, - WindowsSandboxSetupCompletedNotification, - WindowsWorldWritableWarningNotification, -) +from .v2_all import AccountLoginCompletedNotification +from .v2_all import AccountRateLimitsUpdatedNotification +from .v2_all import AccountUpdatedNotification +from .v2_all import AgentMessageDeltaNotification +from .v2_all import AppListUpdatedNotification +from .v2_all import CommandExecOutputDeltaNotification +from .v2_all import CommandExecutionOutputDeltaNotification +from .v2_all import ConfigWarningNotification +from .v2_all import ContextCompactedNotification +from .v2_all import DeprecationNoticeNotification +from .v2_all import ErrorNotification +from .v2_all import ExternalAgentConfigImportCompletedNotification +from .v2_all import FileChangeOutputDeltaNotification +from .v2_all import FileChangePatchUpdatedNotification +from .v2_all import FsChangedNotification +from .v2_all import FuzzyFileSearchSessionCompletedNotification +from .v2_all import FuzzyFileSearchSessionUpdatedNotification +from .v2_all import GuardianWarningNotification +from .v2_all import HookCompletedNotification +from .v2_all import HookStartedNotification +from .v2_all import ItemCompletedNotification +from .v2_all import ItemGuardianApprovalReviewCompletedNotification +from .v2_all import ItemGuardianApprovalReviewStartedNotification +from .v2_all import ItemStartedNotification +from .v2_all import McpServerOauthLoginCompletedNotification +from .v2_all import McpServerStatusUpdatedNotification +from .v2_all import McpToolCallProgressNotification +from .v2_all import ModelReroutedNotification +from .v2_all import ModelVerificationNotification +from .v2_all import PlanDeltaNotification +from .v2_all import ProcessExitedNotification +from .v2_all import ProcessOutputDeltaNotification +from .v2_all import ReasoningSummaryPartAddedNotification +from .v2_all import ReasoningSummaryTextDeltaNotification +from .v2_all import ReasoningTextDeltaNotification +from .v2_all import RemoteControlStatusChangedNotification +from .v2_all import ServerRequestResolvedNotification +from .v2_all import SkillsChangedNotification +from .v2_all import TerminalInteractionNotification +from .v2_all import ThreadArchivedNotification +from .v2_all import ThreadClosedNotification +from .v2_all import ThreadGoalClearedNotification +from .v2_all import ThreadGoalUpdatedNotification +from .v2_all import ThreadNameUpdatedNotification +from .v2_all import ThreadRealtimeClosedNotification +from .v2_all import ThreadRealtimeErrorNotification +from .v2_all import ThreadRealtimeItemAddedNotification +from .v2_all import ThreadRealtimeOutputAudioDeltaNotification +from .v2_all import ThreadRealtimeSdpNotification +from .v2_all import ThreadRealtimeStartedNotification +from .v2_all import ThreadRealtimeTranscriptDeltaNotification +from .v2_all import ThreadRealtimeTranscriptDoneNotification +from .v2_all import ThreadSettingsUpdatedNotification +from .v2_all import ThreadStartedNotification +from .v2_all import ThreadStatusChangedNotification +from .v2_all import ThreadTokenUsageUpdatedNotification +from .v2_all import ThreadUnarchivedNotification +from .v2_all import TurnCompletedNotification +from .v2_all import TurnDiffUpdatedNotification +from .v2_all import TurnPlanUpdatedNotification +from .v2_all import TurnStartedNotification +from .v2_all import WarningNotification +from .v2_all import WindowsSandboxSetupCompletedNotification +from .v2_all import WindowsWorldWritableWarningNotification NOTIFICATION_MODELS: dict[str, type[BaseModel]] = { "account/login/completed": AccountLoginCompletedNotification, @@ -116,7 +112,6 @@ "thread/archived": ThreadArchivedNotification, "thread/closed": ThreadClosedNotification, "thread/compacted": ContextCompactedNotification, - "thread/deleted": ThreadDeletedNotification, "thread/goal/cleared": ThreadGoalClearedNotification, "thread/goal/updated": ThreadGoalUpdatedNotification, "thread/name/updated": ThreadNameUpdatedNotification, @@ -135,7 +130,6 @@ "thread/unarchived": ThreadUnarchivedNotification, "turn/completed": TurnCompletedNotification, "turn/diff/updated": TurnDiffUpdatedNotification, - "turn/moderationMetadata": TurnModerationMetadataNotification, "turn/plan/updated": TurnPlanUpdatedNotification, "turn/started": TurnStartedNotification, "warning": WarningNotification, @@ -167,7 +161,6 @@ ThreadGoalUpdatedNotification, ThreadTokenUsageUpdatedNotification, TurnDiffUpdatedNotification, - TurnModerationMetadataNotification, TurnPlanUpdatedNotification, ) diff --git a/sdk/python/src/openai_codex/generated/v2_all.py b/sdk/python/src/openai_codex/generated/v2_all.py index 34978a612456..c024a2c8c07c 100644 --- a/sdk/python/src/openai_codex/generated/v2_all.py +++ b/sdk/python/src/openai_codex/generated/v2_all.py @@ -2,11 +2,9 @@ # filename: codex_app_server_protocol.v2.schemas.json from __future__ import annotations - -from enum import Enum -from typing import Annotated, Any, Literal - from pydantic import BaseModel, ConfigDict, Field, RootModel +from typing import Annotated, Any, Literal +from enum import Enum class CodexAppServerProtocolV2(BaseModel): @@ -51,25 +49,6 @@ class AccountLoginCompletedNotification(BaseModel): success: bool -class AccountTokenUsageDailyBucket(BaseModel): - model_config = ConfigDict( - populate_by_name=True, - ) - start_date: Annotated[str, Field(alias="startDate")] - tokens: int - - -class AccountTokenUsageSummary(BaseModel): - model_config = ConfigDict( - populate_by_name=True, - ) - current_streak_days: Annotated[int | None, Field(alias="currentStreakDays")] = None - lifetime_tokens: Annotated[int | None, Field(alias="lifetimeTokens")] = None - longest_running_turn_sec: Annotated[int | None, Field(alias="longestRunningTurnSec")] = None - longest_streak_days: Annotated[int | None, Field(alias="longestStreakDays")] = None - peak_daily_tokens: Annotated[int | None, Field(alias="peakDailyTokens")] = None - - class ActivePermissionProfile(BaseModel): model_config = ConfigDict( populate_by_name=True, @@ -120,33 +99,6 @@ class AgentMessageDeltaNotification(BaseModel): turn_id: Annotated[str, Field(alias="turnId")] -class InputTextAgentMessageInputContent(BaseModel): - model_config = ConfigDict( - populate_by_name=True, - ) - text: str - type: Annotated[Literal["input_text"], Field(title="InputTextAgentMessageInputContentType")] - - -class EncryptedContentAgentMessageInputContent(BaseModel): - model_config = ConfigDict( - populate_by_name=True, - ) - encrypted_content: str - type: Annotated[ - Literal["encrypted_content"], Field(title="EncryptedContentAgentMessageInputContentType") - ] - - -class AgentMessageInputContent( - RootModel[InputTextAgentMessageInputContent | EncryptedContentAgentMessageInputContent] -): - model_config = ConfigDict( - populate_by_name=True, - ) - root: InputTextAgentMessageInputContent | EncryptedContentAgentMessageInputContent - - class AgentPath(RootModel[str]): model_config = ConfigDict( populate_by_name=True, @@ -194,16 +146,11 @@ class AppSummary(BaseModel): model_config = ConfigDict( populate_by_name=True, ) - category: str | None = None description: str | None = None id: str install_url: Annotated[str | None, Field(alias="installUrl")] = None name: str - - -class AppTemplateUnavailableReason(Enum): - not_configured_for_workspace = "NOT_CONFIGURED_FOR_WORKSPACE" - no_active_workspace = "NO_ACTIVE_WORKSPACE" + needs_auth: Annotated[bool, Field(alias="needsAuth")] class AppToolApproval(Enum): @@ -237,7 +184,6 @@ class AppsDefaultConfig(BaseModel): model_config = ConfigDict( populate_by_name=True, ) - approvals_reviewer: ApprovalsReviewer | None = None destructive_enabled: bool | None = True enabled: bool | None = True open_world_enabled: bool | None = True @@ -272,6 +218,7 @@ class AppsListParams(BaseModel): class AskForApprovalValue(Enum): untrusted = "untrusted" + on_failure = "on-failure" on_request = "on-request" never = "never" @@ -307,8 +254,6 @@ class AuthMode(Enum): chatgpt = "chatgpt" chatgpt_auth_tokens = "chatgptAuthTokens" agent_identity = "agentIdentity" - personal_access_token = "personalAccessToken" - bedrock_api_key = "bedrockApiKey" class AutoCompactTokenLimitScope(Enum): @@ -348,25 +293,6 @@ class CancelLoginAccountStatus(Enum): not_found = "notFound" -class EnvironmentCapabilityRootLocation(BaseModel): - model_config = ConfigDict( - populate_by_name=True, - ) - environment_id: Annotated[str, Field(alias="environmentId")] - path: str - type: Annotated[Literal["environment"], Field(title="EnvironmentCapabilityRootLocationType")] - - -class CapabilityRootLocation(RootModel[EnvironmentCapabilityRootLocation]): - model_config = ConfigDict( - populate_by_name=True, - ) - root: Annotated[ - EnvironmentCapabilityRootLocation, - Field(description="Location used to resolve a selected capability root."), - ] - - class ClientInfo(BaseModel): model_config = ConfigDict( populate_by_name=True, @@ -856,11 +782,6 @@ class ContextCompactedNotification(BaseModel): turn_id: Annotated[str, Field(alias="turnId")] -class ConversationTextRole(Enum): - user = "user" - developer = "developer" - - class CreditsSnapshot(BaseModel): model_config = ConfigDict( populate_by_name=True, @@ -1463,16 +1384,6 @@ class GetAccountParams(BaseModel): ] = None -class GetAccountTokenUsageResponse(BaseModel): - model_config = ConfigDict( - populate_by_name=True, - ) - daily_usage_buckets: Annotated[ - list[AccountTokenUsageDailyBucket] | None, Field(alias="dailyUsageBuckets") - ] = None - summary: AccountTokenUsageSummary - - class GitInfo(BaseModel): model_config = ConfigDict( populate_by_name=True, @@ -2047,7 +1958,6 @@ class McpServerStatusUpdatedNotification(BaseModel): error: str | None = None name: str status: McpServerStartupState - thread_id: Annotated[str | None, Field(alias="threadId")] = None class McpServerToolCallParams(BaseModel): @@ -2764,11 +2674,6 @@ class RateLimitWindow(BaseModel): window_duration_mins: Annotated[int | None, Field(alias="windowDurationMins")] = None -class RealtimeConversationArchitecture(Enum): - realtimeapi = "realtimeapi" - avas = "avas" - - class RealtimeConversationVersion(Enum): v1 = "v1" v2 = "v2" @@ -2811,16 +2716,13 @@ class RealtimeVoicesList(BaseModel): v2: list[RealtimeVoice] -class ReasoningEffort(RootModel[str]): - model_config = ConfigDict( - populate_by_name=True, - ) - root: Annotated[ - str, - Field( - description="A non-empty reasoning effort value advertised by the model.", min_length=1 - ), - ] +class ReasoningEffort(Enum): + none = "none" + minimal = "minimal" + low = "low" + medium = "medium" + high = "high" + xhigh = "xhigh" class ReasoningEffortOption(BaseModel): @@ -2928,20 +2830,6 @@ class RemoteControlConnectionStatus(Enum): errored = "errored" -class RemoteControlDisableParams(BaseModel): - model_config = ConfigDict( - populate_by_name=True, - ) - ephemeral: bool | None = None - - -class RemoteControlEnableParams(BaseModel): - model_config = ConfigDict( - populate_by_name=True, - ) - ephemeral: bool | None = None - - class RemoteControlStatusChangedNotification(BaseModel): model_config = ConfigDict( populate_by_name=True, @@ -3023,16 +2911,6 @@ class ResourceTemplate(BaseModel): uri_template: Annotated[str, Field(alias="uriTemplate")] -class AgentMessageResponseItem(BaseModel): - model_config = ConfigDict( - populate_by_name=True, - ) - author: str - content: list[AgentMessageInputContent] - recipient: str - type: Annotated[Literal["agent_message"], Field(title="AgentMessageResponseItemType")] - - class ReasoningResponseItem(BaseModel): model_config = ConfigDict( populate_by_name=True, @@ -3331,18 +3209,6 @@ class SandboxWorkspaceWrite(BaseModel): writable_roots: list[str] | None = [] -class SelectedCapabilityRoot(BaseModel): - model_config = ConfigDict( - populate_by_name=True, - ) - id: Annotated[ - str, Field(description="Stable identifier supplied by the capability selection platform.") - ] - location: Annotated[ - CapabilityRootLocation, Field(description="Where the selected root can be resolved.") - ] - - class SendAddCreditsNudgeEmailParams(BaseModel): model_config = ConfigDict( populate_by_name=True, @@ -3741,12 +3607,6 @@ class SpendControlLimitSnapshot(BaseModel): used: str -class SubAgentActivityKind(Enum): - started = "started" - interacted = "interacted" - interrupted = "interrupted" - - class SubAgentSourceValue(Enum): review = "review" compact = "compact" @@ -3880,27 +3740,6 @@ class ThreadCompactStartResponse(BaseModel): ) -class ThreadDeleteParams(BaseModel): - model_config = ConfigDict( - populate_by_name=True, - ) - thread_id: Annotated[str, Field(alias="threadId")] - - -class ThreadDeleteResponse(BaseModel): - pass - model_config = ConfigDict( - populate_by_name=True, - ) - - -class ThreadDeletedNotification(BaseModel): - model_config = ConfigDict( - populate_by_name=True, - ) - thread_id: Annotated[str, Field(alias="threadId")] - - class ThreadGoalClearParams(BaseModel): model_config = ConfigDict( populate_by_name=True, @@ -4077,17 +3916,6 @@ class DynamicToolCallThreadItem(BaseModel): type: Annotated[Literal["dynamicToolCall"], Field(title="DynamicToolCallThreadItemType")] -class SubAgentActivityThreadItem(BaseModel): - model_config = ConfigDict( - populate_by_name=True, - ) - agent_path: Annotated[str, Field(alias="agentPath")] - agent_thread_id: Annotated[str, Field(alias="agentThreadId")] - id: str - kind: SubAgentActivityKind - type: Annotated[Literal["subAgentActivity"], Field(title="SubAgentActivityThreadItemType")] - - class ImageViewThreadItem(BaseModel): model_config = ConfigDict( populate_by_name=True, @@ -4427,11 +4255,10 @@ class ThreadSortKey(Enum): updated_at = "updated_at" -class ThreadSource(RootModel[str]): - model_config = ConfigDict( - populate_by_name=True, - ) - root: str +class ThreadSource(Enum): + user = "user" + subagent = "subagent" + memory_consolidation = "memory_consolidation" class ThreadSourceKind(Enum): @@ -4590,15 +4417,6 @@ class TurnItemsView(Enum): full = "full" -class TurnModerationMetadataNotification(BaseModel): - model_config = ConfigDict( - populate_by_name=True, - ) - metadata: Any - thread_id: Annotated[str, Field(alias="threadId")] - turn_id: Annotated[str, Field(alias="turnId")] - - class TurnPlanStepStatus(Enum): pending = "pending" in_progress = "inProgress" @@ -4899,21 +4717,6 @@ class AppMetadata(BaseModel): version_notes: Annotated[str | None, Field(alias="versionNotes")] = None -class AppTemplateSummary(BaseModel): - model_config = ConfigDict( - populate_by_name=True, - ) - canonical_connector_id: Annotated[str | None, Field(alias="canonicalConnectorId")] = None - category: str | None = None - description: str | None = None - logo_url: Annotated[str | None, Field(alias="logoUrl")] = None - logo_url_dark: Annotated[str | None, Field(alias="logoUrlDark")] = None - materialized_app_ids: Annotated[list[str], Field(alias="materializedAppIds")] - name: str - reason: AppTemplateUnavailableReason | None = None - template_id: Annotated[str, Field(alias="templateId")] - - class AppsConfig(BaseModel): model_config = ConfigDict( populate_by_name=True, @@ -4955,15 +4758,6 @@ class ThreadArchiveRequest(BaseModel): params: ThreadArchiveParams -class ThreadDeleteRequest(BaseModel): - model_config = ConfigDict( - populate_by_name=True, - ) - id: RequestId - method: Annotated[Literal["thread/delete"], Field(title="Thread/deleteRequestMethod")] - params: ThreadDeleteParams - - class ThreadUnsubscribeRequest(BaseModel): model_config = ConfigDict( populate_by_name=True, @@ -5508,15 +5302,6 @@ class AccountRateLimitsReadRequest(BaseModel): params: None = None -class AccountUsageReadRequest(BaseModel): - model_config = ConfigDict( - populate_by_name=True, - ) - id: RequestId - method: Annotated[Literal["account/usage/read"], Field(title="Account/usage/readRequestMethod")] - params: None = None - - class AccountSendAddCreditsNudgeEmailRequest(BaseModel): model_config = ConfigDict( populate_by_name=True, @@ -5835,13 +5620,10 @@ class ConfigRequirements(BaseModel): ) allow_appshots: Annotated[bool | None, Field(alias="allowAppshots")] = None allow_managed_hooks_only: Annotated[bool | None, Field(alias="allowManagedHooksOnly")] = None - allow_remote_control: Annotated[bool | None, Field(alias="allowRemoteControl")] = None allowed_approval_policies: Annotated[ list[AskForApproval] | None, Field(alias="allowedApprovalPolicies") ] = None - allowed_permission_profiles: Annotated[ - dict[str, Any] | None, Field(alias="allowedPermissionProfiles") - ] = None + allowed_permissions: Annotated[list[str] | None, Field(alias="allowedPermissions")] = None allowed_sandbox_modes: Annotated[ list[SandboxMode] | None, Field(alias="allowedSandboxModes") ] = None @@ -5852,7 +5634,6 @@ class ConfigRequirements(BaseModel): list[WindowsSandboxSetupMode] | None, Field(alias="allowedWindowsSandboxImplementations") ] = None computer_use: Annotated[ComputerUseRequirements | None, Field(alias="computerUse")] = None - default_permissions: Annotated[str | None, Field(alias="defaultPermissions")] = None enforce_residency: Annotated[ResidencyRequirement | None, Field(alias="enforceResidency")] = ( None ) @@ -6433,14 +6214,6 @@ class ThreadArchivedServerNotification(BaseModel): params: ThreadArchivedNotification -class ThreadDeletedServerNotification(BaseModel): - model_config = ConfigDict( - populate_by_name=True, - ) - method: Annotated[Literal["thread/deleted"], Field(title="Thread/deletedNotificationMethod")] - params: ThreadDeletedNotification - - class ThreadUnarchivedServerNotification(BaseModel): model_config = ConfigDict( populate_by_name=True, @@ -6555,16 +6328,6 @@ class AccountUpdatedServerNotification(BaseModel): params: AccountUpdatedNotification -class TurnModerationMetadataServerNotification(BaseModel): - model_config = ConfigDict( - populate_by_name=True, - ) - method: Annotated[ - Literal["turn/moderationMetadata"], Field(title="Turn/moderationMetadataNotificationMethod") - ] - params: TurnModerationMetadataNotification - - class WarningServerNotification(BaseModel): model_config = ConfigDict( populate_by_name=True, @@ -6928,7 +6691,6 @@ class ThreadItem( | McpToolCallThreadItem | DynamicToolCallThreadItem | CollabAgentToolCallThreadItem - | SubAgentActivityThreadItem | WebSearchThreadItem | ImageViewThreadItem | ImageGenerationThreadItem @@ -6951,7 +6713,6 @@ class ThreadItem( | McpToolCallThreadItem | DynamicToolCallThreadItem | CollabAgentToolCallThreadItem - | SubAgentActivityThreadItem | WebSearchThreadItem | ImageViewThreadItem | ImageGenerationThreadItem @@ -7743,7 +7504,6 @@ class CustomToolCallOutputResponseItem(BaseModel): class ResponseItem( RootModel[ MessageResponseItem - | AgentMessageResponseItem | ReasoningResponseItem | LocalShellCallResponseItem | FunctionCallResponseItem @@ -7765,7 +7525,6 @@ class ResponseItem( ) root: ( MessageResponseItem - | AgentMessageResponseItem | ReasoningResponseItem | LocalShellCallResponseItem | FunctionCallResponseItem @@ -8119,14 +7878,12 @@ class PluginDetail(BaseModel): model_config = ConfigDict( populate_by_name=True, ) - app_templates: Annotated[list[AppTemplateSummary], Field(alias="appTemplates")] apps: list[AppSummary] description: str | None = None hooks: list[PluginHookSummary] marketplace_name: Annotated[str, Field(alias="marketplaceName")] marketplace_path: Annotated[AbsolutePathBuf | None, Field(alias="marketplacePath")] = None mcp_servers: Annotated[list[str], Field(alias="mcpServers")] - share_url: Annotated[str | None, Field(alias="shareUrl")] = None skills: list[SkillSummary] summary: PluginSummary @@ -8521,7 +8278,6 @@ class ClientRequest( | ThreadResumeRequest | ThreadForkRequest | ThreadArchiveRequest - | ThreadDeleteRequest | ThreadUnsubscribeRequest | ThreadNameSetRequest | ThreadGoalSetRequest @@ -8585,7 +8341,6 @@ class ClientRequest( | AccountLoginCancelRequest | AccountLogoutRequest | AccountRateLimitsReadRequest - | AccountUsageReadRequest | AccountSendAddCreditsNudgeEmailRequest | FeedbackUploadRequest | CommandExecRequest @@ -8611,7 +8366,6 @@ class ClientRequest( | ThreadResumeRequest | ThreadForkRequest | ThreadArchiveRequest - | ThreadDeleteRequest | ThreadUnsubscribeRequest | ThreadNameSetRequest | ThreadGoalSetRequest @@ -8675,7 +8429,6 @@ class ClientRequest( | AccountLoginCancelRequest | AccountLogoutRequest | AccountRateLimitsReadRequest - | AccountUsageReadRequest | AccountSendAddCreditsNudgeEmailRequest | FeedbackUploadRequest | CommandExecRequest @@ -8729,7 +8482,6 @@ class ServerNotification( | ThreadStartedServerNotification | ThreadStatusChangedServerNotification | ThreadArchivedServerNotification - | ThreadDeletedServerNotification | ThreadUnarchivedServerNotification | ThreadClosedServerNotification | SkillsChangedServerNotification @@ -8773,7 +8525,6 @@ class ServerNotification( | ThreadCompactedServerNotification | ModelReroutedServerNotification | ModelVerificationServerNotification - | TurnModerationMetadataServerNotification | WarningServerNotification | GuardianWarningServerNotification | DeprecationNoticeServerNotification @@ -8801,7 +8552,6 @@ class ServerNotification( | ThreadStartedServerNotification | ThreadStatusChangedServerNotification | ThreadArchivedServerNotification - | ThreadDeletedServerNotification | ThreadUnarchivedServerNotification | ThreadClosedServerNotification | SkillsChangedServerNotification @@ -8845,7 +8595,6 @@ class ServerNotification( | ThreadCompactedServerNotification | ModelReroutedServerNotification | ModelVerificationServerNotification - | TurnModerationMetadataServerNotification | WarningServerNotification | GuardianWarningServerNotification | DeprecationNoticeServerNotification From b9b9527d47018b2f6ba51ab82c338aa71f1d8589 Mon Sep 17 00:00:00 2001 From: Dylan Hurd Date: Tue, 16 Jun 2026 10:41:33 -0700 Subject: [PATCH 5/6] codex: defer SDK approval mode regeneration --- sdk/typescript/src/threadOptions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/typescript/src/threadOptions.ts b/sdk/typescript/src/threadOptions.ts index c9e0cc644bd9..7bde5e4d78fe 100644 --- a/sdk/typescript/src/threadOptions.ts +++ b/sdk/typescript/src/threadOptions.ts @@ -1,4 +1,4 @@ -export type ApprovalMode = "never" | "on-request" | "untrusted"; +export type ApprovalMode = "never" | "on-request" | "on-failure" | "untrusted"; export type SandboxMode = "read-only" | "workspace-write" | "danger-full-access"; From 86a87aced2737b4d27b9f4e7ce2afc6aa0c97f1c Mon Sep 17 00:00:00 2001 From: Dylan Hurd Date: Tue, 23 Jun 2026 12:48:01 -0400 Subject: [PATCH 6/6] codex: fix CI failure on PR #28418 --- .../codex-mcp/src/connection_manager_tests.rs | 4 +- codex-rs/core/tests/suite/network_approval.rs | 4 +- codex-rs/core/tests/suite/remote_env.rs | 145 ------------------ 3 files changed, 4 insertions(+), 149 deletions(-) diff --git a/codex-rs/codex-mcp/src/connection_manager_tests.rs b/codex-rs/codex-mcp/src/connection_manager_tests.rs index 47e8cbdd058a..955acd3f81d2 100644 --- a/codex-rs/codex-mcp/src/connection_manager_tests.rs +++ b/codex-rs/codex-mcp/src/connection_manager_tests.rs @@ -1176,7 +1176,7 @@ fn server_metadata_preserves_tool_approval_policy() { #[test] fn host_owned_codex_apps_requires_server_metadata() { - let approval_policy = Constrained::allow_any(AskForApproval::OnFailure); + let approval_policy = Constrained::allow_any(AskForApproval::OnRequest); let permission_profile = Constrained::allow_any(PermissionProfile::default()); let manager = McpConnectionManager::new_uninitialized( &approval_policy, @@ -1189,7 +1189,7 @@ fn host_owned_codex_apps_requires_server_metadata() { #[test] fn host_owned_codex_apps_matches_reserved_name_with_server_metadata() { - let approval_policy = Constrained::allow_any(AskForApproval::OnFailure); + let approval_policy = Constrained::allow_any(AskForApproval::OnRequest); let permission_profile = Constrained::allow_any(PermissionProfile::default()); let mut manager = McpConnectionManager::new_uninitialized( &approval_policy, diff --git a/codex-rs/core/tests/suite/network_approval.rs b/codex-rs/core/tests/suite/network_approval.rs index f476fb72878c..e644fcf6b80a 100644 --- a/codex-rs/core/tests/suite/network_approval.rs +++ b/codex-rs/core/tests/suite/network_approval.rs @@ -165,7 +165,7 @@ mode = "limited" allow_local_binding = true "#, )?; - let approval_policy = AskForApproval::OnFailure; + let approval_policy = AskForApproval::OnRequest; let permission_profile = PermissionProfile::workspace_write_with( &[], NetworkSandboxPolicy::Enabled, @@ -263,7 +263,7 @@ async fn submit_managed_network_turn( additional_context: Default::default(), thread_settings: codex_protocol::protocol::ThreadSettingsOverrides { environments: Some(turn_environment_selections), - approval_policy: Some(AskForApproval::OnFailure), + approval_policy: Some(AskForApproval::OnRequest), approvals_reviewer: Some(ApprovalsReviewer::User), sandbox_policy: Some(sandbox_policy), permission_profile, diff --git a/codex-rs/core/tests/suite/remote_env.rs b/codex-rs/core/tests/suite/remote_env.rs index 2df03f92a8e1..976da1349c3d 100644 --- a/codex-rs/core/tests/suite/remote_env.rs +++ b/codex-rs/core/tests/suite/remote_env.rs @@ -313,151 +313,6 @@ async fn explicit_remote_shell_runs_in_remote_cwd() -> Result<()> { Ok(()) } -#[tokio::test(flavor = "multi_thread", worker_threads = 2)] -async fn remote_sandbox_denial_requests_approval_and_retries() -> Result<()> { - skip_if_no_network!(Ok(())); - skip_if_wine_exec!(Ok(()), "requires the Docker-backed POSIX executor"); - let Some(_remote_env) = get_remote_test_env() else { - return Ok(()); - }; - - const CALL_ID: &str = "remote-sandbox-denial"; - const CONTENTS: &str = "remote sandbox retry succeeded"; - - let server = start_mock_server().await; - let test = unified_exec_test(&server).await?; - let nonce = SystemTime::now().duration_since(UNIX_EPOCH)?.as_millis(); - let remote_cwd = PathBuf::from(format!("/tmp/codex-remote-denial-cwd-{nonce}")).abs(); - let target_path = PathBuf::from(format!("/tmp/codex-remote-denial-target-{nonce}")).abs(); - let remote_cwd_uri = PathUri::from_host_native_path(&remote_cwd)?; - let target_uri = PathUri::from_host_native_path(&target_path)?; - test.fs() - .create_directory( - &remote_cwd_uri, - CreateDirectoryOptions { recursive: true }, - /*sandbox*/ None, - ) - .await?; - test.fs() - .remove( - &target_uri, - RemoveOptions { - recursive: false, - force: true, - }, - /*sandbox*/ None, - ) - .await?; - - let command = format!("printf {CONTENTS:?} > {target_path:?} && cat {target_path:?}"); - let response_mock = mount_sse_sequence( - &server, - vec![ - sse(vec![ - ev_response_created("resp-remote-denial-1"), - ev_function_call( - CALL_ID, - "exec_command", - &json!({ - "shell": "/bin/sh", - "cmd": command, - "login": false, - "yield_time_ms": 5_000, - "environment_id": REMOTE_ENVIRONMENT_ID, - }) - .to_string(), - ), - ev_completed("resp-remote-denial-1"), - ]), - sse(vec![ - ev_response_created("resp-remote-denial-2"), - ev_assistant_message("msg-remote-denial", "done"), - ev_completed("resp-remote-denial-2"), - ]), - ], - ) - .await; - - submit_turn_with_approval_and_environments( - &test, - "retry a sandbox-denied command in the remote environment", - vec![TurnEnvironmentSelection { - environment_id: REMOTE_ENVIRONMENT_ID.to_string(), - cwd: PathUri::from_abs_path(&remote_cwd), - }], - AskForApproval::OnFailure, - ) - .await?; - - let event = wait_for_event(&test.codex, |event| { - matches!( - event, - EventMsg::ExecApprovalRequest(_) | EventMsg::TurnComplete(_) - ) - }) - .await; - let EventMsg::ExecApprovalRequest(approval) = event else { - panic!("expected remote sandbox approval before completion: {event:?}"); - }; - assert_eq!(approval.call_id, CALL_ID); - assert_eq!( - approval.environment_id.as_deref(), - Some(REMOTE_ENVIRONMENT_ID) - ); - assert_eq!( - approval.reason.as_deref(), - Some("command failed; retry without sandbox?") - ); - - test.codex - .submit(Op::ExecApproval { - id: approval.effective_approval_id(), - turn_id: None, - decision: ReviewDecision::Approved, - }) - .await?; - wait_for_event(&test.codex, |event| { - matches!(event, EventMsg::TurnComplete(_)) - }) - .await; - - assert!( - response_mock - .function_call_output_text(CALL_ID) - .is_some_and(|output| output.contains(CONTENTS)), - "approved retry should return the remote command output" - ); - assert_eq!( - test.fs() - .read_file_text(&target_uri, /*sandbox*/ None) - .await?, - CONTENTS - ); - - test.fs() - .remove( - &target_uri, - RemoveOptions { - recursive: false, - force: true, - }, - /*sandbox*/ None, - ) - .await?; - test.fs() - .remove( - &remote_cwd_uri, - RemoveOptions { - recursive: true, - force: true, - }, - /*sandbox*/ None, - ) - .await?; - - Ok(()) -} - #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn deferred_executor_does_not_duplicate_initial_environment_context() -> Result<()> { let server = start_mock_server().await;