Skip to content

feat(sandbox): allow Docker sandboxes to disable networking - #4452

Merged
seratch merged 6 commits into
openai:mainfrom
koadegno:agent/docker-sandbox-disable-network
Aug 16, 2026
Merged

seratch merged 6 commits into
openai:mainfrom
koadegno:agent/docker-sandbox-disable-network

Conversation

@koadegno

Copy link
Copy Markdown
Contributor

Summary

This pull request adds an opt-in way to create Docker sandboxes with networking completely disabled.

DockerSandboxClientOptions now accepts:

DockerSandboxClientOptions(
    image="python:3.14-slim",
    network_mode="none",
)

The new option is deliberately narrow:

network_mode: Literal["none"] | None = None

When omitted, Docker container creation remains unchanged and no network_mode argument is passed.

When set to "none", the value is forwarded to docker_client.containers.create(), causing Docker to create the sandbox without networking.

The setting is also persisted in DockerSandboxSessionState and reapplied when DockerSandboxClient.resume() needs to recreate a missing container. This prevents a sandbox originally created without networking from silently regaining Docker's default network configuration after recreation.

Older serialized session states remain compatible because the new field defaults to None.

The public option intentionally does not expose arbitrary Docker networking modes such as host, bridge, or container:<id>.

Test plan

Added regression coverage for:

  • accepting network_mode="none"
  • rejecting unsupported network modes
  • propagating "none" through the public DockerSandboxClient.create() path
  • passing network_mode="none" to Docker container creation
  • preserving the existing Docker create kwargs when the option is omitted
  • DockerSandboxClientOptions serialization and parsing
  • DockerSandboxSessionState serialization
  • backwards compatibility with serialized states that do not contain network_mode
  • reapplying network_mode="none" when resume() recreates a missing container
  • compatibility guards for the extended public options/state fields

Focused sandbox tests passed:

86 passed

Full repository verification was run with:

env UV_DEFAULT_INDEX=https://pypi.org/simple \
  bash .agents/skills/code-change-verification/scripts/run.sh

All verification steps passed, including:

  • formatting
  • lint
  • type checking
  • full test suite

Issue number

Closes #4451

Checks

  • I've added new tests, if relevant
  • I've run .agents/skills/code-change-verification/scripts/run.sh
  • I've confirmed all verification steps pass
  • If using Codex, I've run /review before submitting this PR (not applicable; this change was not prepared with Codex)

@seratch seratch added this to the 0.21.x milestone Aug 16, 2026

@seratch seratch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the contribution. The need described in #4451 is demonstrated, and the narrow Docker-specific network_mode="none" design is sound. Before merging, please make three focused changes:

  • Append network_mode after the existing keyword-only type parameter to preserve public constructor ordering.
  • Update the current unreleased RunState 1.16 summary to include the persisted Docker network-isolation state.
  • Add a deserialization test for an invalid persisted value such as bridge, asserting rejection before any Docker provider access.

These changes keep the released API ordering and durable-state contract explicit while proving the none-only security boundary. Once they are addressed and CI is green, the PR should be ready for another review.

koadegno added a commit to koadegno/openai-agents-python that referenced this pull request Aug 16, 2026
koadegno added a commit to koadegno/openai-agents-python that referenced this pull request Aug 16, 2026
koadegno added a commit to koadegno/openai-agents-python that referenced this pull request Aug 16, 2026
koadegno added a commit to koadegno/openai-agents-python that referenced this pull request Aug 16, 2026
@koadegno
koadegno force-pushed the agent/docker-sandbox-disable-network branch from f73b3cc to 2298047 Compare August 16, 2026 01:18
koadegno added a commit to koadegno/openai-agents-python that referenced this pull request Aug 16, 2026

@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: f73b3cc5a9

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agents/sandbox/sandboxes/docker.py Resolved
Comment thread src/agents/sandbox/sandboxes/docker.py Resolved
koadegno added a commit to koadegno/openai-agents-python that referenced this pull request Aug 16, 2026

@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: bd19ee0b95

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agents/sandbox/sandboxes/docker.py Resolved

@seratch seratch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the updates. The current head resolves the earlier constructor-ordering, RunState schema-summary, and persisted-value validation requests.

Can you continue working until the PR review says 👍 ?

@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: 812f23bf90

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agents/sandbox/sandboxes/docker.py Resolved
Comment thread src/agents/sandbox/sandboxes/docker.py Resolved
Comment thread src/agents/run_state.py Resolved
@seratch
seratch enabled auto-merge (squash) August 16, 2026 03:25
@seratch
seratch merged commit 2f1c83d into openai:main Aug 16, 2026
14 checks passed
@koadegno
koadegno deleted the agent/docker-sandbox-disable-network branch August 16, 2026 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Sandbox] Allow Docker sandboxes to run with networking disabled

2 participants