Skip to content

Commit 7464ec0

Browse files
charley-oaicodex
andcommitted
core: stabilize fork snapshot across platforms
Co-authored-by: Codex <noreply@openai.com>
1 parent bea065b commit 7464ec0

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

codex-rs/core/src/codex_tests.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1224,7 +1224,12 @@ async fn fork_startup_context_then_first_turn_diff_snapshot() -> anyhow::Result<
12241224
.lines()
12251225
.map(|line| {
12261226
let mut line = line.to_string();
1227-
for (tag, replacement) in [("cwd", "<CWD>"), ("current_date", "<CURRENT_DATE>")] {
1227+
for (tag, replacement) in [
1228+
("cwd", "<CWD>"),
1229+
("shell", "<SHELL>"),
1230+
("current_date", "<CURRENT_DATE>"),
1231+
("timezone", "<TIMEZONE>"),
1232+
] {
12281233
let open_tag = format!("<{tag}>");
12291234
let close_tag = format!("</{tag}>");
12301235
if let (Some(start), Some(end)) = (line.find(&open_tag), line.find(&close_tag)) {

codex-rs/core/src/snapshots/codex_core__codex_tests__fork_startup_context_then_first_turn_diff.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
---
22
source: core/src/codex_tests.rs
3-
assertion_line: 1262
3+
assertion_line: 1282
44
expression: snapshot
55
---
66
Scenario: First request after fork when fork startup changes approval policy and the first forked turn changes approval policy again and enters plan mode.
77

88
## First Forked Turn Request
99
00:message/developer:<permissions instructions>\nFilesystem sandboxing defines which files can be read or written. `sandbox_mode` is `read-only`: The sandbox only permits reading files. Network access is restricted.\n# Escalation Requests\n\nCommands are run outside the sandbox if they are approved by the user, or match an existing rule that allows it to run unrestricted. The command string is split into independent command segments at shell control operators, including but not limited to:\n\n- Pipes: |\n- Logical operators: &&, ||\n- Command separators: ;\n- Subshell boundaries: (...), $(...)\n\nEach resulting segment is evaluated independently for sandbox restrictions and approval requirements.\n\nExample:\n\ngit pull | tee output.txt\n\nThis is treated as two command segments:\n\n["git", "pull"]\n\n["tee", "output.txt"]\n\nCommands that use more advanced shell features like redirection (>, >>, <), substitutions ($(...), ...), environment variables (FOO=bar), or wildcard patterns (*, ?) will not be evaluated against rules, to limit the scope of what an approved rule allows.\n\n## How to request escalation\n\nIMPORTANT: To request approval to execute a command that will require escalated privileges:\n\n- Provide the `sandbox_permissions` parameter with the value `"require_escalated"`\n- Include a short question asking the user if they want to allow the action in `justification` parameter. e.g. "Do you want to download and install dependencies for this project?"\n- Optionally suggest a `prefix_rule` - this will be shown to the user with an option to persist the rule approval for future sessions.\n\nIf you run a command that is important to solving the user's query, but it fails because of sandboxing or with a likely sandbox-related network error (for example DNS/host resolution, registry/index access, or dependency download failure), rerun the command with "require_escalated". ALWAYS proceed to use the `justification` parameter - do not message the user before requesting approval for the command.\n\n## When to request escalation\n\nWhile commands are running inside the sandbox, here are some scenarios that will require escalation outside the sandbox:\n\n- You need to run a command that writes to a directory that requires it (e.g. running tests that write to /var)\n- You need to run a GUI app (e.g., open/xdg-open/osascript) to open browsers or files.\n- If you run a command that is important to solving the user's query, but it fails because of sandboxing or with a likely sandbox-related network error (for example DNS/host resolution, registry/index access, or dependency download failure), rerun the command with `require_escalated`. ALWAYS proceed to use the `sandbox_permissions` and `justification` parameters. do not message the user before requesting approval for the command.\n- You are about to take a potentially destructive action such as an `rm` or `git reset` that the user did not explicitly ask for.\n- Be judicious with escalating, but if completing the user's request requires it, you should do so - don't try and circumvent approvals by using other tools.\n\n## prefix_rule guidance\n\nWhen choosing a `prefix_rule`, request one that will allow you to fulfill similar requests from the user in the future without re-requesting escalation. It should be categorical and reasonably scoped to similar capabilities. You should rarely pass the entire command into `prefix_rule`.\n\n### Banned prefix_rules \nAvoid requesting overly broad prefixes that the user would be ill-advised to approve. For example, do not request ["python3"], ["python", "-"], or other similar prefixes that would allow arbitrary scripting.\nNEVER provide a prefix_rule argument for destructive commands like rm.\nNEVER provide a prefix_rule if your command uses a heredoc or herestring. \n\n### Examples\nGood examples of prefixes:\n- ["npm", "run", "dev"]\n- ["gh", "pr", "check"]\n- ["cargo", "test"]\n</permissions instructions>
10-
01:message/user:<environment_context>\n <cwd><CWD></cwd>\n <shell>zsh</shell>\n <current_date><CURRENT_DATE></current_date>\n <timezone>America/Los_Angeles</timezone>\n</environment_context>
10+
01:message/user:<environment_context>\n <cwd><CWD></cwd>\n <shell><SHELL></shell>\n <current_date><CURRENT_DATE></current_date>\n <timezone><TIMEZONE></timezone>\n</environment_context>
1111
02:message/user:fork seed
1212
03:message/developer:<permissions instructions>\nFilesystem sandboxing defines which files can be read or written. `sandbox_mode` is `read-only`: The sandbox only permits reading files. Network access is restricted.\n Approvals are your mechanism to get user consent to run shell commands without the sandbox. `approval_policy` is `unless-trusted`: The harness will escalate most commands for user approval, apart from a limited allowlist of safe "read" commands.\n</permissions instructions>
13-
04:message/user:<environment_context>\n <cwd><CWD></cwd>\n <shell>zsh</shell>\n <current_date><CURRENT_DATE></current_date>\n <timezone>America/Los_Angeles</timezone>\n</environment_context>
13+
04:message/user:<environment_context>\n <cwd><CWD></cwd>\n <shell><SHELL></shell>\n <current_date><CURRENT_DATE></current_date>\n <timezone><TIMEZONE></timezone>\n</environment_context>
1414
05:message/developer[2]:
1515
[01] <permissions instructions>\nFilesystem sandboxing defines which files can be read or written. `sandbox_mode` is `read-only`: The sandbox only permits reading files. Network access is restricted.\nApproval policy is currently never. Do not provide the `sandbox_permissions` for any reason, commands will be rejected.\n</permissions instructions>
1616
[02] <collaboration_mode>Fork turn collaboration instructions.</collaboration_mode>

0 commit comments

Comments
 (0)