Skip to content

Commit 86d5a9d

Browse files
authored
chore: rename unless-allow-listed to untrusted (#1378)
For the `approval_policy` config option, renames `unless-allow-listed` to `untrusted`. In general, when it comes to exec'ing commands, I think "trusted" is a more accurate term than "safe." Also drops the `AskForApproval::AutoEdit` variant, as we were not really making use of it, anyway. Fixes #1250. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/openai/codex/pull/1378). * #1379 * __->__ #1378
1 parent 531ce76 commit 86d5a9d

File tree

6 files changed

+22
-24
lines changed

6 files changed

+22
-24
lines changed

codex-rs/common/src/approval_mode_cli_arg.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ use codex_core::protocol::AskForApproval;
88
#[derive(Clone, Copy, Debug, ValueEnum)]
99
#[value(rename_all = "kebab-case")]
1010
pub enum ApprovalModeCliArg {
11+
/// Only run "trusted" commands (e.g. ls, cat, sed) without asking for user
12+
/// approval. Will escalate to the user if the model proposes a command that
13+
/// is not in the "trusted" set.
14+
Untrusted,
15+
1116
/// Run all commands without asking for user approval.
1217
/// Only asks for approval if a command fails to execute, in which case it
1318
/// will escalate to the user to ask for un-sandboxed execution.
1419
OnFailure,
1520

16-
/// Only run "known safe" commands (e.g. ls, cat, sed) without
17-
/// asking for user approval. Will escalate to the user if the model
18-
/// proposes a command that is not allow-listed.
19-
UnlessAllowListed,
20-
2121
/// Never ask for user approval
2222
/// Execution failures are immediately returned to the model.
2323
Never,
@@ -26,8 +26,8 @@ pub enum ApprovalModeCliArg {
2626
impl From<ApprovalModeCliArg> for AskForApproval {
2727
fn from(value: ApprovalModeCliArg) -> Self {
2828
match value {
29+
ApprovalModeCliArg::Untrusted => AskForApproval::UnlessAllowListed,
2930
ApprovalModeCliArg::OnFailure => AskForApproval::OnFailure,
30-
ApprovalModeCliArg::UnlessAllowListed => AskForApproval::UnlessAllowListed,
3131
ApprovalModeCliArg::Never => AskForApproval::Never,
3232
}
3333
}

codex-rs/config.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,13 @@ wire_api = "chat"
8080
Determines when the user should be prompted to approve whether Codex can execute a command:
8181

8282
```toml
83-
# This is analogous to --suggest in the TypeScript Codex CLI
84-
approval_policy = "unless-allow-listed"
83+
# Codex has hardcoded logic that defines a set of "trusted" commands.
84+
# Setting the approval_policy to `untrusted` means that Codex will prompt the
85+
# user before running a command not in the "trusted" set.
86+
#
87+
# See https://github.com/openai/codex/issues/1260 for the plan to enable
88+
# end-users to define their own trusted commands.
89+
approval_policy = "untrusted"
8590
```
8691

8792
```toml

codex-rs/core/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ writable_roots = [
586586
fn create_test_fixture() -> std::io::Result<PrecedenceTestFixture> {
587587
let toml = r#"
588588
model = "o3"
589-
approval_policy = "unless-allow-listed"
589+
approval_policy = "untrusted"
590590
disable_response_storage = false
591591
592592
# Can be used to determine which profile to use if not specified by

codex-rs/core/src/protocol.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,22 +110,18 @@ pub enum Op {
110110
GetHistoryEntryRequest { offset: usize, log_id: u64 },
111111
}
112112

113-
/// Determines how liberally commands are auto‑approved by the system.
113+
/// Determines the conditions under which the user is consulted to approve
114+
/// running the command proposed by Codex.
114115
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
115116
#[serde(rename_all = "kebab-case")]
116117
pub enum AskForApproval {
117-
/// Under this policy, only known safe commands—as determined by
118+
/// Under this policy, only "known safe" commands—as determined by
118119
/// `is_safe_command()`—that **only read files** are auto‑approved.
119120
/// Everything else will ask the user to approve.
120121
#[default]
122+
#[serde(rename = "untrusted")]
121123
UnlessAllowListed,
122124

123-
/// In addition to everything allowed by **`Suggest`**, commands that
124-
/// *write* to files **within the user’s approved list of writable paths**
125-
/// are also auto‑approved.
126-
/// TODO(ragona): fix
127-
AutoEdit,
128-
129125
/// *All* commands are auto‑approved, but they are expected to run inside a
130126
/// sandbox where network access is disabled and writes are confined to a
131127
/// specific set of paths. If the command fails, it will be escalated to

codex-rs/core/src/safety.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub fn assess_patch_safety(
3131
}
3232

3333
match policy {
34-
AskForApproval::OnFailure | AskForApproval::AutoEdit | AskForApproval::Never => {
34+
AskForApproval::OnFailure | AskForApproval::Never => {
3535
// Continue to see if this can be auto-approved.
3636
}
3737
// TODO(ragona): I'm not sure this is actually correct? I believe in this case

codex-rs/mcp-server/src/codex_tool_config.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,15 @@ pub(crate) struct CodexToolCallParam {
4747
#[derive(Debug, Clone, Deserialize, JsonSchema)]
4848
#[serde(rename_all = "kebab-case")]
4949
pub(crate) enum CodexToolCallApprovalPolicy {
50-
AutoEdit,
51-
UnlessAllowListed,
50+
Untrusted,
5251
OnFailure,
5352
Never,
5453
}
5554

5655
impl From<CodexToolCallApprovalPolicy> for AskForApproval {
5756
fn from(value: CodexToolCallApprovalPolicy) -> Self {
5857
match value {
59-
CodexToolCallApprovalPolicy::AutoEdit => AskForApproval::AutoEdit,
60-
CodexToolCallApprovalPolicy::UnlessAllowListed => AskForApproval::UnlessAllowListed,
58+
CodexToolCallApprovalPolicy::Untrusted => AskForApproval::UnlessAllowListed,
6159
CodexToolCallApprovalPolicy::OnFailure => AskForApproval::OnFailure,
6260
CodexToolCallApprovalPolicy::Never => AskForApproval::Never,
6361
}
@@ -164,8 +162,7 @@ mod tests {
164162
"approval-policy": {
165163
"description": "Execution approval policy expressed as the kebab-case variant name (`unless-allow-listed`, `auto-edit`, `on-failure`, `never`).",
166164
"enum": [
167-
"auto-edit",
168-
"unless-allow-listed",
165+
"untrusted",
169166
"on-failure",
170167
"never"
171168
],

0 commit comments

Comments
 (0)