Add an explicit --network flag for read-only tasks - #739
Conversation
In Codex CLI 0.147.0 the read-only sandbox has no network access, so a
read-only task that needs to reach the network fails with a misleading DNS
error ('Temporary failure in name resolution'). The existing --write flag
cannot express a task that needs network access but should not be granted
workspace writes as a side effect of asking for it.
Add an explicit --network boolean flag, independent from --write, propagated
through buildTaskRequest and buildThreadParams to thread/start. Default
behaviour is unchanged: without either flag the task stays read-only with no
network.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AkNscDxiaiErzXieHYnydc
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
This makes --network violate the read-only guarantee it is intended to preserve. When network=true and write=false, executeTaskRun() selects the workspace-write sandbox, and the added config only enables network access inside that sandbox; it does not remove workspace write permission. A read-only task that asks for network can therefore modify the workspace. I would not use workspace-write as the transport for this flag unless the permission profile explicitly denies writes. If Codex 0.147.0 cannot express read-only plus network directly, this should fail closed or use a request-scoped filesystem profile that keeps the workspace read-only while enabling network. A regression should attempt an actual workspace write under --network without --write and require it to fail.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 894aefffd4
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| effort: request.effort, | ||
| sandbox: request.write ? "workspace-write" : "read-only", | ||
| // Codex 0.147.0 turns network off for read-only, so network-only mandates use workspace-write. | ||
| sandbox: request.write || request.network ? "workspace-write" : "read-only", |
There was a problem hiding this comment.
Preserve read-only isolation when enabling network
For every task --network invocation without --write, this selects workspace-write, so the agent can modify the repository despite the flag being intended for mandates that “must not write.” Because thread startup also uses approvalPolicy: "never", those writes are not gated by an approval prompt, and the job is still recorded as write: false; use a sandbox/policy that combines read-only filesystem access with networking, or reject this mode until one is available.
Useful? React with 👍 / 👎.
Title
Add an explicit network flag for read-only mandates
Problem
In Codex CLI 0.147.0, the read-only sandbox has no network access. As a
result, read-only mandates that need to reach the network fail with a
misleading DNS error. The existing
--writeflag cannot express a mandatethat needs network access but must not write to the workspace.
Solution
Add an explicit
--networkboolean flag, separate from--write. When--networkis selected, task startup usesworkspace-writeand explicitlyenables
sandbox_workspace_write.network_access;--writeremainsindependent, and the default behavior is unchanged when neither flag is
provided.
Verification
--networkuses theread-onlysandbox and a network probe fails with the sandbox's DNS error.--networkusesworkspace-writewith network access enabled and the same network probesucceeds; a task without
--networkremains network-disabled.node --checkpasses forscripts/codex-companion.mjsandscripts/lib/codex.mjs.