From 1b9acfe2e30f309370a2644b84c017aa7fcbd86d Mon Sep 17 00:00:00 2001 From: blockmandev <194144408+blockmandev@users.noreply.github.com> Date: Fri, 13 Nov 2026 12:16:21 -0600 Subject: [PATCH] codex bridged route: the model is told to write through incode, not that its sandbox is read-only Closes #19. Found running #19 with a real login (gpt-5.6-terra): `incode -t "write secret.txt with x"` under INCODE_CODEX_TOOLS=incode never reached incode's Write. Codex's own session file shows why: codex told the model, in a block, that sandbox_mode is read-only (incode's own override, so codex's apply_patch writes nothing); the model tried codex's apply_patch, got "patch rejected: writing is blocked by read-only sandbox", and answered that the filesystem was read-only. Another run of the same task used incode's ApplyPatch and wrote: the route was a coin toss. Two more overrides (both keys are in codex's config types; an unknown key would be ignored, so each was checked in the session file): - include_permissions_instructions=false: the misleading block goes; the sandbox itself stays read-only. - developer_instructions: every change and command goes through incode's tools, codex's apply_patch is always rejected, never decline a change because of codex's sandbox. Measured after, on the three versions #19 names, each run's version read from its own session file: - codex 0.145.0: "create hello.txt" used incode's Write 3/3 and wrote it; "write secret.txt" under a deny rule used incode's Write and was refused by incode 3/3, no file; plus one more of each. - codex 0.153.4 and 0.167.0: one run of each step, the same results (0.153.4 tried ApplyPatch, refused by the Edit(secret.txt) rule). - every session file: no permissions block, the developer instructions in. - a repository's .codex/config.toml (an MCP server, shell_tool=true) is not applied on this route: the server never appeared, the model had no exec_command or shell. codex tests: 36 pass. --- src/agent/codex/argv.rs | 25 ++++++++++++++++++++++++- src/agent/codex/pinned_tests.rs | 6 +++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/agent/codex/argv.rs b/src/agent/codex/argv.rs index 9bbea9a..04200e2 100644 --- a/src/agent/codex/argv.rs +++ b/src/agent/codex/argv.rs @@ -47,7 +47,17 @@ const HOOKS_OFF: [&str; 2] = ["--disable", "hooks"]; /// codex's own reach writes nothing — `apply_patch` is rejected before it /// runs (see the notes on [`crate::agent::codex`]) — and nothing waits on /// a person. -pub const MODEL_ONLY_OVERRIDES: [&str; 14] = [ +/// - `include_permissions_instructions=false`: codex does not describe that +/// sandbox to the model. It told the model, in a `` block, that `sandbox_mode` is `read-only`, and the model +/// then refused writes outright: measured on 0.167.0 with gpt-5.6-terra, +/// it tried codex's own `apply_patch`, got "patch rejected: writing is +/// blocked by read-only sandbox" and answered that the filesystem was +/// read-only, never trying incode's `Write` (the session file in +/// `~/.codex/sessions` shows both). The sandbox stays read-only; only the +/// misleading description goes. +/// - [`WRITE_THROUGH_INCODE`]: says, in its place, where changes are made. +pub const MODEL_ONLY_OVERRIDES: [&str; 16] = [ "features.shell_tool=false", "features.view_image=false", "web_search=\"disabled\"", @@ -62,8 +72,21 @@ pub const MODEL_ONLY_OVERRIDES: [&str; 14] = [ "features.image_generation=false", "sandbox_mode=\"read-only\"", "approval_policy=\"never\"", + "include_permissions_instructions=false", + WRITE_THROUGH_INCODE, ]; +/// The developer instructions on the bridged route: changes and commands go +/// through incode's tools, and codex's own `apply_patch`, which the read-only +/// sandbox always rejects, is not the way. One TOML basic string (no `"` or +/// `\` inside), so `-c` parses it as written. +pub const WRITE_THROUGH_INCODE: &str = "developer_instructions=\"Every file change and \ +command in this session goes through the incode tools (Write, Edit, MultiEdit, ApplyPatch, \ +Bash, Read and the others served by the incode MCP server), which incode runs with its own \ +permissions. Codex's own apply_patch is switched off here and is always rejected: never use \ +it, and never decline a change because of codex's sandbox. Make every change with the \ +incode tools; if incode refuses one, say what it said.\""; + /// Codex's user config (`$CODEX_HOME/config.toml`) is not read on the /// bridged route — the counterpart of the Claude route's /// `--setting-sources ""`: an MCP server the operator registered there would diff --git a/src/agent/codex/pinned_tests.rs b/src/agent/codex/pinned_tests.rs index f10d8e3..79b5eba 100644 --- a/src/agent/codex/pinned_tests.rs +++ b/src/agent/codex/pinned_tests.rs @@ -844,6 +844,8 @@ fn bridged_overrides(exe: &str) -> Vec { "features.image_generation=false".to_string(), "sandbox_mode=\"read-only\"".to_string(), "approval_policy=\"never\"".to_string(), + "include_permissions_instructions=false".to_string(), + super::argv::WRITE_THROUGH_INCODE.to_string(), format!("mcp_servers.incode.command=\"{exe}\""), "mcp_servers.incode.args=[\"--tool-server\"]".to_string(), "mcp_servers.incode.env_vars=[\"INCODE_TOOL_BRIDGE\",\"INCODE_TOOL_TOKEN\"]".to_string(), @@ -888,7 +890,7 @@ fn the_bridged_command_escapes_a_windows_server_path() { } #[test] -fn the_model_only_overrides_are_the_fourteen() { +fn the_model_only_overrides_are_the_sixteen() { assert_eq!( MODEL_ONLY_OVERRIDES, [ @@ -906,6 +908,8 @@ fn the_model_only_overrides_are_the_fourteen() { "features.image_generation=false", "sandbox_mode=\"read-only\"", "approval_policy=\"never\"", + "include_permissions_instructions=false", + super::argv::WRITE_THROUGH_INCODE, ] ); }