Skip to content

codex: the model is told to write through incode, not that its sandbox is read-only (closes #19) - #89

Merged
blockmandev merged 1 commit into
mainfrom
fix/codex-model-told-where-to-write
Nov 13, 2026
Merged

blockmandev merged 1 commit into
mainfrom
fix/codex-model-told-where-to-write

Conversation

@blockmandev

Copy link
Copy Markdown
Member

Closes #19: verified with a real login on all three codex versions the issue names.

The problem found

With INCODE_CODEX_TOOLS=incode, codex told the model in a <permissions instructions> block that sandbox_mode is read-only. That's incode's own override, so that codex's apply_patch writes nothing. The model then tried codex's apply_patch, got "patch rejected: writing is blocked by read-only sandbox" (codex's session file shows both), and refused the task. Another run of the same task used incode's tools and wrote, so the route was a coin toss.

The fix: two more model-only overrides (src/agent/codex/argv.rs)

  • include_permissions_instructions=false: the misleading description 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.

Codex silently ignores an unknown key, so each key's effect was checked in codex's own session files.

Verified (each run's codex version read from its own session file)

codex create hello.txt write secret.txt under deny session file
0.145.0 incode Write, written (4/4) incode Write, refused by incode, no file (4/4) no permissions block; instructions present
0.153.4 incode Write, written incode ApplyPatch, refused (Edit(secret.txt)), no file same
0.167.0 incode Write, written incode Write, refused, no file same

The other open points on #19:

  • Project .codex/config.toml: not applied on this route. A repo config with an MCP server and shell_tool = true loaded no server, and the model had no exec_command or shell. Nothing to refuse.
  • Default flip: already done (CodexTools::Incode is #[default]).

codex tests: 36 pass, with the pinned override list updated.

Found along the way, separate: on Windows, incode starts the first codex.exe on PATH (here the Codex desktop app's, 0.145.0), while the shell's codex is npm's codex.cmd (0.167.0). incode can therefore run a different codex from the one it reports. Fixed in its own PR.

…hat 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
<permissions instructions> 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.
@blockmandev
blockmandev merged commit 8f808ba into main Nov 13, 2026
21 of 22 checks passed
@blockmandev
blockmandev deleted the fix/codex-model-told-where-to-write branch November 15, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

codex through incode's tools: verify with a real login, then make it the default

1 participant