Skip to content

Add an explicit --network flag for read-only tasks - #739

Open
naniastudios wants to merge 1 commit into
openai:mainfrom
naniastudios:feat/network-flag-for-read-only-mandates
Open

Add an explicit --network flag for read-only tasks#739
naniastudios wants to merge 1 commit into
openai:mainfrom
naniastudios:feat/network-flag-for-read-only-mandates

Conversation

@naniastudios

Copy link
Copy Markdown

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 --write flag cannot express a mandate
that needs network access but must not write to the workspace.

Solution

Add an explicit --network boolean flag, separate from --write. When
--network is selected, task startup uses workspace-write and explicitly
enables sandbox_workspace_write.network_access; --write remains
independent, and the default behavior is unchanged when neither flag is
provided.

Verification

  • Red: before the patch, a task started without --network uses the
    read-only sandbox and a network probe fails with the sandbox's DNS error.
  • Green: after the patch, a task started with --network uses
    workspace-write with network access enabled and the same network probe
    succeeds; a task without --network remains network-disabled.
  • node --check passes for scripts/codex-companion.mjs and
    scripts/lib/codex.mjs.

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
@naniastudios
naniastudios requested a review from a team September 5, 2026 12:16

@sylvesterkaczmarek sylvesterkaczmarek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

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.

2 participants