mirror of
https://github.com/openai/codex.git
synced 2026-11-03 19:53:25 +00:00
remove execution mode
This commit is contained in:
@@ -13784,13 +13784,6 @@
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ToolExecutionMode": {
|
||||
"enum": [
|
||||
"auto",
|
||||
"manual"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"ToolsV2": {
|
||||
"properties": {
|
||||
"enabled": {
|
||||
@@ -13803,17 +13796,6 @@
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"execution_mode": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/v2/ToolExecutionMode"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Execution policy for approval-capable tools."
|
||||
},
|
||||
"view_image": {
|
||||
"description": "Legacy enablement for the `view_image` capability.",
|
||||
"type": [
|
||||
|
||||
@@ -11544,13 +11544,6 @@
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ToolExecutionMode": {
|
||||
"enum": [
|
||||
"auto",
|
||||
"manual"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"ToolsV2": {
|
||||
"properties": {
|
||||
"enabled": {
|
||||
@@ -11563,17 +11556,6 @@
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"execution_mode": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ToolExecutionMode"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Execution policy for approval-capable tools."
|
||||
},
|
||||
"view_image": {
|
||||
"description": "Legacy enablement for the `view_image` capability.",
|
||||
"type": [
|
||||
|
||||
@@ -760,13 +760,6 @@
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"ToolExecutionMode": {
|
||||
"enum": [
|
||||
"auto",
|
||||
"manual"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"ToolsV2": {
|
||||
"properties": {
|
||||
"enabled": {
|
||||
@@ -779,17 +772,6 @@
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"execution_mode": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ToolExecutionMode"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"description": "Execution policy for approval-capable tools."
|
||||
},
|
||||
"view_image": {
|
||||
"description": "Legacy enablement for the `view_image` capability.",
|
||||
"type": [
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
// GENERATED CODE! DO NOT MODIFY BY HAND!
|
||||
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type ToolExecutionMode = "auto" | "manual";
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { WebSearchToolConfig } from "../WebSearchToolConfig";
|
||||
import type { ToolExecutionMode } from "./ToolExecutionMode";
|
||||
|
||||
export type ToolsV2 = {
|
||||
/**
|
||||
@@ -16,8 +15,4 @@ view_image: boolean | null,
|
||||
/**
|
||||
* Canonical capability names to enable. If omitted, legacy/default resolution applies.
|
||||
*/
|
||||
enabled: Array<string> | null,
|
||||
/**
|
||||
* Execution policy for approval-capable tools.
|
||||
*/
|
||||
execution_mode: ToolExecutionMode | null, };
|
||||
enabled: Array<string> | null, };
|
||||
|
||||
@@ -305,7 +305,6 @@ export type { ThreadUnsubscribeParams } from "./ThreadUnsubscribeParams";
|
||||
export type { ThreadUnsubscribeResponse } from "./ThreadUnsubscribeResponse";
|
||||
export type { ThreadUnsubscribeStatus } from "./ThreadUnsubscribeStatus";
|
||||
export type { TokenUsageBreakdown } from "./TokenUsageBreakdown";
|
||||
export type { ToolExecutionMode } from "./ToolExecutionMode";
|
||||
export type { ToolRequestUserInputAnswer } from "./ToolRequestUserInputAnswer";
|
||||
export type { ToolRequestUserInputOption } from "./ToolRequestUserInputOption";
|
||||
export type { ToolRequestUserInputParams } from "./ToolRequestUserInputParams";
|
||||
|
||||
@@ -533,14 +533,6 @@ pub struct SandboxWorkspaceWrite {
|
||||
pub exclude_slash_tmp: bool,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub enum ToolExecutionMode {
|
||||
Auto,
|
||||
Manual,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[ts(export_to = "v2/")]
|
||||
@@ -551,8 +543,6 @@ pub struct ToolsV2 {
|
||||
pub view_image: Option<bool>,
|
||||
/// Canonical capability names to enable. If omitted, legacy/default resolution applies.
|
||||
pub enabled: Option<Vec<String>>,
|
||||
/// Execution policy for approval-capable tools.
|
||||
pub execution_mode: Option<ToolExecutionMode>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
|
||||
@@ -102,7 +102,6 @@ allowed_domains = ["example.com"]
|
||||
|
||||
[tools]
|
||||
view_image = false
|
||||
execution_mode = "manual"
|
||||
enabled = ["shell", "apply_patch"]
|
||||
"#,
|
||||
)?;
|
||||
@@ -140,7 +139,6 @@ enabled = ["shell", "apply_patch"]
|
||||
}),
|
||||
view_image: Some(false),
|
||||
enabled: Some(vec!["shell".to_string(), "apply_patch".to_string()]),
|
||||
execution_mode: Some(codex_app_server_protocol::ToolExecutionMode::Manual),
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
@@ -167,12 +165,6 @@ enabled = ["shell", "apply_patch"]
|
||||
file: user_file.clone(),
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
origins.get("tools.execution_mode").expect("origin").name,
|
||||
ConfigLayerSource::User {
|
||||
file: user_file.clone(),
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
origins.get("tools.enabled.0").expect("origin").name,
|
||||
ConfigLayerSource::User {
|
||||
|
||||
@@ -169,7 +169,6 @@ async fn thread_start_accepts_enabled_tool_overrides() -> Result<()> {
|
||||
config: Some(HashMap::from([(
|
||||
"tools".to_string(),
|
||||
json!({
|
||||
"execution_mode": "manual",
|
||||
"enabled": ["shell", "apply_patch", "web_search"],
|
||||
"web_search": {
|
||||
"context_size": "low",
|
||||
|
||||
@@ -1552,13 +1552,6 @@
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"ToolExecutionMode": {
|
||||
"enum": [
|
||||
"auto",
|
||||
"manual"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"ToolSuggestConfig": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
@@ -1606,15 +1599,6 @@
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"execution_mode": {
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ToolExecutionMode"
|
||||
}
|
||||
],
|
||||
"default": null,
|
||||
"description": "Execution policy for approval-capable tools."
|
||||
},
|
||||
"view_image": {
|
||||
"default": null,
|
||||
"description": "Legacy enablement for the `view_image` capability.",
|
||||
|
||||
@@ -38,8 +38,6 @@ pub(crate) async fn apply_patch(
|
||||
file_system_sandbox_policy: &FileSystemSandboxPolicy,
|
||||
action: ApplyPatchAction,
|
||||
) -> InternalApplyPatchInvocation {
|
||||
let manual_tool_approval_required = turn_context.tools_config.requires_manual_tool_approval();
|
||||
|
||||
match assess_patch_safety(
|
||||
&action,
|
||||
turn_context.approval_policy.value(),
|
||||
@@ -54,16 +52,9 @@ pub(crate) async fn apply_patch(
|
||||
} => InternalApplyPatchInvocation::DelegateToExec(ApplyPatchExec {
|
||||
action,
|
||||
auto_approved: !user_explicitly_approved,
|
||||
exec_approval_requirement: if manual_tool_approval_required {
|
||||
ExecApprovalRequirement::NeedsApproval {
|
||||
reason: None,
|
||||
proposed_execpolicy_amendment: None,
|
||||
}
|
||||
} else {
|
||||
ExecApprovalRequirement::Skip {
|
||||
bypass_sandbox: false,
|
||||
proposed_execpolicy_amendment: None,
|
||||
}
|
||||
exec_approval_requirement: ExecApprovalRequirement::Skip {
|
||||
bypass_sandbox: false,
|
||||
proposed_execpolicy_amendment: None,
|
||||
},
|
||||
}),
|
||||
SafetyCheck::AskUser => {
|
||||
|
||||
@@ -891,7 +891,6 @@ impl TurnContext {
|
||||
})
|
||||
.with_enabled_tool_capabilities(config.enabled_tool_capabilities.clone())
|
||||
.with_legacy_view_image_override(config.legacy_view_image_override)
|
||||
.with_execution_mode(config.tool_execution_mode)
|
||||
.with_unified_exec_shell_mode(self.tools_config.unified_exec_shell_mode.clone())
|
||||
.with_web_search_config(self.tools_config.web_search_config.clone())
|
||||
.with_allow_login_shell(self.tools_config.allow_login_shell)
|
||||
@@ -1332,7 +1331,6 @@ impl Session {
|
||||
})
|
||||
.with_enabled_tool_capabilities(per_turn_config.enabled_tool_capabilities.clone())
|
||||
.with_legacy_view_image_override(per_turn_config.legacy_view_image_override)
|
||||
.with_execution_mode(per_turn_config.tool_execution_mode)
|
||||
.with_unified_exec_shell_mode_for_session(
|
||||
user_shell,
|
||||
shell_zsh_path,
|
||||
@@ -5200,7 +5198,6 @@ async fn spawn_review_thread(
|
||||
})
|
||||
.with_enabled_tool_capabilities(config.enabled_tool_capabilities.clone())
|
||||
.with_legacy_view_image_override(config.legacy_view_image_override)
|
||||
.with_execution_mode(config.tool_execution_mode)
|
||||
.with_unified_exec_shell_mode_for_session(
|
||||
sess.services.user_shell.as_ref(),
|
||||
sess.services.shell_zsh_path.as_ref(),
|
||||
|
||||
@@ -198,7 +198,6 @@ web_search = true
|
||||
web_search: None,
|
||||
view_image: None,
|
||||
enabled: None,
|
||||
execution_mode: None,
|
||||
})
|
||||
);
|
||||
}
|
||||
@@ -219,17 +218,15 @@ web_search = false
|
||||
web_search: None,
|
||||
view_image: None,
|
||||
enabled: None,
|
||||
execution_mode: None,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tools_enabled_deserialize_with_execution_mode() {
|
||||
fn tools_enabled_deserializes() {
|
||||
let cfg: ConfigToml = toml::from_str(
|
||||
r#"
|
||||
[tools]
|
||||
execution_mode = "manual"
|
||||
enabled = ["shell", "apply_patch"]
|
||||
"#,
|
||||
)
|
||||
@@ -241,7 +238,6 @@ enabled = ["shell", "apply_patch"]
|
||||
web_search: None,
|
||||
view_image: None,
|
||||
enabled: Some(vec!["shell".to_string(), "apply_patch".to_string()]),
|
||||
execution_mode: Some(ToolExecutionMode::Manual),
|
||||
})
|
||||
);
|
||||
}
|
||||
@@ -4410,7 +4406,6 @@ fn test_precedence_fixture_with_o3_profile() -> std::io::Result<()> {
|
||||
web_search_config: None,
|
||||
enabled_tool_capabilities: None,
|
||||
legacy_view_image_override: None,
|
||||
tool_execution_mode: ToolExecutionMode::Auto,
|
||||
use_experimental_unified_exec_tool: !cfg!(windows),
|
||||
background_terminal_max_timeout: DEFAULT_MAX_BACKGROUND_TERMINAL_TIMEOUT_MS,
|
||||
ghost_snapshot: GhostSnapshotConfig::default(),
|
||||
@@ -4556,7 +4551,6 @@ fn test_precedence_fixture_with_gpt3_profile() -> std::io::Result<()> {
|
||||
web_search_config: None,
|
||||
enabled_tool_capabilities: None,
|
||||
legacy_view_image_override: None,
|
||||
tool_execution_mode: ToolExecutionMode::Auto,
|
||||
use_experimental_unified_exec_tool: !cfg!(windows),
|
||||
background_terminal_max_timeout: DEFAULT_MAX_BACKGROUND_TERMINAL_TIMEOUT_MS,
|
||||
ghost_snapshot: GhostSnapshotConfig::default(),
|
||||
@@ -4700,7 +4694,6 @@ fn test_precedence_fixture_with_zdr_profile() -> std::io::Result<()> {
|
||||
web_search_config: None,
|
||||
enabled_tool_capabilities: None,
|
||||
legacy_view_image_override: None,
|
||||
tool_execution_mode: ToolExecutionMode::Auto,
|
||||
use_experimental_unified_exec_tool: !cfg!(windows),
|
||||
background_terminal_max_timeout: DEFAULT_MAX_BACKGROUND_TERMINAL_TIMEOUT_MS,
|
||||
ghost_snapshot: GhostSnapshotConfig::default(),
|
||||
@@ -4830,7 +4823,6 @@ fn test_precedence_fixture_with_gpt5_profile() -> std::io::Result<()> {
|
||||
web_search_config: None,
|
||||
enabled_tool_capabilities: None,
|
||||
legacy_view_image_override: None,
|
||||
tool_execution_mode: ToolExecutionMode::Auto,
|
||||
use_experimental_unified_exec_tool: !cfg!(windows),
|
||||
background_terminal_max_timeout: DEFAULT_MAX_BACKGROUND_TERMINAL_TIMEOUT_MS,
|
||||
ghost_snapshot: GhostSnapshotConfig::default(),
|
||||
|
||||
@@ -552,9 +552,6 @@ pub struct Config {
|
||||
/// Legacy `tools.view_image` fallback used when no explicit capability override is present.
|
||||
pub legacy_view_image_override: Option<bool>,
|
||||
|
||||
/// Execution policy for approval-capable tools.
|
||||
pub tool_execution_mode: ToolExecutionMode,
|
||||
|
||||
/// If set to `true`, used only the experimental unified exec tool.
|
||||
pub use_experimental_unified_exec_tool: bool,
|
||||
|
||||
@@ -1629,17 +1626,6 @@ pub struct ToolsToml {
|
||||
/// Canonical capability names to enable. If omitted, legacy/default resolution applies.
|
||||
#[serde(default)]
|
||||
pub enabled: Option<Vec<String>>,
|
||||
|
||||
/// Execution policy for approval-capable tools.
|
||||
#[serde(default)]
|
||||
pub execution_mode: Option<ToolExecutionMode>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum ToolExecutionMode {
|
||||
Auto,
|
||||
Manual,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
@@ -2141,23 +2127,6 @@ fn resolve_legacy_view_image_override(
|
||||
})
|
||||
}
|
||||
|
||||
fn resolve_tool_execution_mode(
|
||||
config_toml: &ConfigToml,
|
||||
config_profile: &ConfigProfile,
|
||||
) -> ToolExecutionMode {
|
||||
config_profile
|
||||
.tools
|
||||
.as_ref()
|
||||
.and_then(|tools| tools.execution_mode)
|
||||
.or_else(|| {
|
||||
config_toml
|
||||
.tools
|
||||
.as_ref()
|
||||
.and_then(|tools| tools.execution_mode)
|
||||
})
|
||||
.unwrap_or(ToolExecutionMode::Auto)
|
||||
}
|
||||
|
||||
pub(crate) fn resolve_web_search_mode_for_turn(
|
||||
web_search_mode: &Constrained<WebSearchMode>,
|
||||
sandbox_policy: &SandboxPolicy,
|
||||
@@ -2482,7 +2451,6 @@ impl Config {
|
||||
.unwrap_or(WebSearchMode::Cached);
|
||||
let web_search_config = resolve_web_search_config(&cfg, &config_profile);
|
||||
let legacy_view_image_override = resolve_legacy_view_image_override(&cfg, &config_profile);
|
||||
let tool_execution_mode = resolve_tool_execution_mode(&cfg, &config_profile);
|
||||
|
||||
let agent_roles =
|
||||
agent_roles::load_agent_roles(&cfg, &config_layer_stack, &mut startup_warnings)?;
|
||||
@@ -2904,7 +2872,6 @@ impl Config {
|
||||
web_search_config,
|
||||
enabled_tool_capabilities,
|
||||
legacy_view_image_override,
|
||||
tool_execution_mode,
|
||||
use_experimental_unified_exec_tool,
|
||||
background_terminal_max_timeout,
|
||||
ghost_snapshot,
|
||||
|
||||
@@ -444,11 +444,6 @@ impl ShellHandler {
|
||||
prefix_rule,
|
||||
})
|
||||
.await;
|
||||
let exec_approval_requirement = if turn.tools_config.requires_manual_tool_approval() {
|
||||
exec_approval_requirement.force_manual_approval()
|
||||
} else {
|
||||
exec_approval_requirement
|
||||
};
|
||||
|
||||
let req = ShellRequest {
|
||||
command: exec_params.command.clone(),
|
||||
|
||||
@@ -157,19 +157,6 @@ impl ExecApprovalRequirement {
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn force_manual_approval(self) -> Self {
|
||||
match self {
|
||||
Self::Skip {
|
||||
proposed_execpolicy_amendment,
|
||||
..
|
||||
} => Self::NeedsApproval {
|
||||
reason: None,
|
||||
proposed_execpolicy_amendment,
|
||||
},
|
||||
other => other,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// - Never, OnFailure: do not ask
|
||||
|
||||
@@ -108,33 +108,3 @@ fn guardian_bypasses_sandbox_for_explicit_escalation_on_first_attempt() {
|
||||
SandboxOverride::BypassSandboxFirstAttempt
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn force_manual_approval_converts_skip_to_needs_approval() {
|
||||
let requirement = ExecApprovalRequirement::Skip {
|
||||
bypass_sandbox: false,
|
||||
proposed_execpolicy_amendment: None,
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
requirement.force_manual_approval(),
|
||||
ExecApprovalRequirement::NeedsApproval {
|
||||
reason: None,
|
||||
proposed_execpolicy_amendment: None,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn force_manual_approval_preserves_forbidden() {
|
||||
let requirement = ExecApprovalRequirement::Forbidden {
|
||||
reason: "denied".to_string(),
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
requirement.force_manual_approval(),
|
||||
ExecApprovalRequirement::Forbidden {
|
||||
reason: "denied".to_string(),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ use crate::client_common::tools::FreeformToolFormat;
|
||||
use crate::client_common::tools::ResponsesApiTool;
|
||||
use crate::client_common::tools::ToolSpec;
|
||||
use crate::config::AgentRoleConfig;
|
||||
use crate::config::ToolExecutionMode;
|
||||
use crate::mcp::CODEX_APPS_MCP_SERVER_NAME;
|
||||
use crate::mcp_connection_manager::ToolInfo;
|
||||
use crate::models_manager::collaboration_mode_presets::CollaborationModesConfig;
|
||||
@@ -275,7 +274,6 @@ pub(crate) struct ToolsConfig {
|
||||
pub allow_login_shell: bool,
|
||||
pub enabled_tool_capabilities: Option<std::collections::BTreeSet<String>>,
|
||||
pub legacy_view_image_override: Option<bool>,
|
||||
pub execution_mode: ToolExecutionMode,
|
||||
pub apply_patch_tool_type: Option<ApplyPatchToolType>,
|
||||
pub web_search_mode: Option<WebSearchMode>,
|
||||
pub web_search_config: Option<WebSearchConfig>,
|
||||
@@ -412,7 +410,6 @@ impl ToolsConfig {
|
||||
allow_login_shell: true,
|
||||
enabled_tool_capabilities: None,
|
||||
legacy_view_image_override: None,
|
||||
execution_mode: ToolExecutionMode::Auto,
|
||||
apply_patch_tool_type,
|
||||
web_search_mode: *web_search_mode,
|
||||
web_search_config: None,
|
||||
@@ -465,11 +462,6 @@ impl ToolsConfig {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_execution_mode(mut self, execution_mode: ToolExecutionMode) -> Self {
|
||||
self.execution_mode = execution_mode;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_unified_exec_shell_mode(
|
||||
mut self,
|
||||
unified_exec_shell_mode: UnifiedExecShellMode,
|
||||
@@ -515,10 +507,6 @@ impl ToolsConfig {
|
||||
self.is_tool_capability_enabled(capability)
|
||||
}
|
||||
|
||||
pub fn requires_manual_tool_approval(&self) -> bool {
|
||||
matches!(self.execution_mode, ToolExecutionMode::Manual)
|
||||
}
|
||||
|
||||
fn is_tool_capability_enabled(&self, capability: ToolCapabilityKey) -> bool {
|
||||
if let Some(enabled_tool_capabilities) = self.enabled_tool_capabilities.as_ref() {
|
||||
return enabled_tool_capabilities.contains(capability.capability_name());
|
||||
|
||||
@@ -609,12 +609,6 @@ impl UnifiedExecProcessManager {
|
||||
prefix_rule: request.prefix_rule.clone(),
|
||||
})
|
||||
.await;
|
||||
let exec_approval_requirement = if context.turn.tools_config.requires_manual_tool_approval()
|
||||
{
|
||||
exec_approval_requirement.force_manual_approval()
|
||||
} else {
|
||||
exec_approval_requirement
|
||||
};
|
||||
let req = UnifiedExecToolRequest {
|
||||
command: request.command.clone(),
|
||||
cwd,
|
||||
|
||||
Reference in New Issue
Block a user