Skip to content

codex: headless sessions run read-only and cannot write files (SetApprovalMode ignored in exec path) #311

Description

@edwin-zvs

Summary

A headless codex session (created with an initial prompt) runs codex exec in a read-only sandbox and cannot write files. It hard-blocks with "Blocked: the workspace is read-only, so index.html could not be [written]" and then goes silently to awaiting_input — no approval request, no error event the user can act on.

Why it happens

In crates/adapter-codex/src/main.rs the headless exec path:

  • adds no --sandbox / -a (--ask-for-approval) flag, so codex uses its default read-only policy; and
  • ignores AdapterInboxMsg::SetApprovalMode (the match arm just continues).

So changing the session approval mode (Manual / Auto-review / Unsafe-auto) in the TUI or webui has no effect on a headless codex session, and there is no agent new flag for sandbox/approval. The only workaround was reconfiguring the adapter command and restarting the daemon:

[adapters.codex.env]
AGENTD_CODEX_CMD = "codex --sandbox workspace-write --ask-for-approval never"

Repro

  1. Isolated daemon, default config.
  2. agent new codex "edit index.html to add X" --cwd <repo>
  3. Session reports read-only block and stops; the file is never written.

Suggested fix

  • Map the session approval mode to codex flags in the exec path, e.g. UnsafeAuto → --dangerously-bypass-approvals-and-sandbox, AutoReview → --sandbox workspace-write -a on-failure, Manual → read-only.
  • Surface the read-only block as an error/approval event with a hint, not a silent awaiting_input.
  • Document the codex sandbox default in docs/harnesses.md.

Related: #271 (auto-approve policy for codex/antigravity).

Found during an isolated dogfood run building a browser game with claude/codex/zarvis.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions