Skip to content

Add needed sandbox activation mode - #95005

Closed
yu-xin-c wants to merge 1 commit into
openclaw:mainfrom
yu-xin-c:codex/80296-sandbox-needed-mode
Closed

yu-xin-c wants to merge 1 commit into
openclaw:mainfrom
yu-xin-c:codex/80296-sandbox-needed-mode

Conversation

@yu-xin-c

@yu-xin-c yu-xin-c commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #80296

What Problem This Solves

Resolves a problem where chat-only turns can fail whenever Docker is unavailable because sandbox.mode: "all" creates the backend before the model can answer, even when the turn never invokes execution.

Why This Change Was Made

This adds an opt-in sandbox.mode: "needed" while leaving existing defaults unchanged. Chat setup uses run activation and does not create a backend; exec uses tool activation, lazily resolves the configured sandbox once, and fails closed if the backend is unavailable. Codex app-server native shell, filesystem, MCP, and app-backed tools stay disabled while an auto/sandbox target is waiting for OpenClaw sandbox activation, while explicit gateway and existing node semantics remain intact.

The policy extension now validates and publishes needed, and its effective exec-security evidence reports the sandbox default instead of host full.

User Impact

Operators can keep normal chat available during a temporary Docker outage without allowing sandbox-bound exec to fall back to the host. openclaw sandbox explain now reports the direct run and sandbox-on-tool states separately.

Evidence

  • Final focused acceptance run: 10 test files across 6 Vitest shards, 475 tests passed.
  • Final type checks passed: pnpm tsgo:core, pnpm tsgo:extensions, and pnpm tsgo:extensions:test.
  • Full pnpm build passed.
  • Full pnpm lint:core and pnpm lint:extensions passed during this follow-up.
  • Formatting and git diff --check passed.
  • Existing Telegram UI proof remains available from the Mantis run.

Real behavior proof

Behavior addressed: With mode: "needed", chat-only OpenClaw and Codex turns must work without Docker, while embedded exec and Codex-native execution must not fall back to the host.

Real environment tested: An isolated macOS checkout running the actual OpenClaw Gateway, the managed QA mock provider, and a real Codex app-server. The Docker CLI was absent and DOCKER_HOST pointed at a nonexistent Unix socket.

Exact steps or command run after this patch: Installed the exact lockfile with pnpm install --frozen-lockfile, configured agents.defaults.sandbox.mode="needed", then ran node --import tsx scripts/needed-sandbox-proof.ts from a disposable local proof harness. The harness sent chat and exec-canary turns through the real Gateway and Codex app-server.

Evidence after fix:

docker.cliAvailable=false
sandbox.explain: mode=needed sessionIsSandboxed=false toolActivationIsSandboxed=true

openclaw.chat: status=ok marker=NEEDED_CHAT_OK
openclaw.exec: hostMarkerExists=false
openclaw.exec.error: Sandbox mode requires Docker, but the "docker" command was not found in PATH.

codex.chat: status=ok marker=NEEDED_CODEX_CHAT_OK
codex.providerRequest.tools=[]
codex.nativeShellTools=[]
codex.exec: hostMarkerExists=false

Observed result after fix: Both chat-only paths completed successfully. Embedded exec attempted lazy sandbox activation, returned the Docker-unavailable error, and did not create its host canary. Codex exposed no native execution schema under pending needed activation and also did not create its host canary.

What was not tested: This follow-up did not repeat the Docker-off case through the live Telegram transport; the linked Mantis artifact covers Telegram-visible behavior but not Docker availability. Live SSH and OpenShell backends were not exercised; registered-backend unit coverage verifies activation timing independently of Docker.

Focused command

node scripts/run-vitest.mjs \
  src/agents/sandbox/tool-policy.test.ts \
  src/agents/sandbox.resolveSandboxContext.test.ts \
  src/agents/exec-defaults.test.ts \
  src/agents/bash-tools.exec.path.test.ts \
  src/commands/sandbox-explain.test.ts \
  src/auto-reply/reply/bash-command.stop.test.ts \
  extensions/codex/src/app-server/native-execution-policy.test.ts \
  extensions/codex/src/app-server/dynamic-tool-build.test.ts \
  extensions/policy/src/policy-state.test.ts \
  extensions/policy/src/doctor/register.test.ts \
  --reporter=verbose

Codex boundary basis

Codex's app-server protocol exposes fixed sandbox selections rather than an OpenClaw-owned lazy needed transition: see SandboxMode and turn sandbox policy. Therefore, while OpenClaw has no active sandbox context, disabling the native surface is the fail-closed boundary; OpenClaw-owned dynamic tools remain the activation path where available.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime commands Command implementations docker Docker and sandbox tooling agents Agent runtime and tooling extensions: policy size: M triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 19, 2026
@clawsweeper

clawsweeper Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 31, 2026, 8:58 AM ET / 12:58 UTC.

ClawSweeper review

What this changes

Adds an opt-in sandbox.mode: "needed" that keeps chat turns direct, activates a sandbox only when sandbox-bound execution is requested, and blocks Codex native execution until that sandbox exists.

Merge readiness

⚠️ Needs maintainer review before merge - 5 items remain

Keep this PR open: it presents a credible, evidence-backed implementation for the Docker-outage chat failure, but it introduces a public sandbox mode and changes a security-sensitive execution boundary that still needs explicit maintainer product sponsorship and a current-base review before merge.

Priority: P2
Reviewed head: 1212d3e88b94f00969d361357d6b0772076882a6
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Strong real behavior proof supports a useful implementation, while the new public configuration contract and stale merge state still need maintainer direction and current-base review.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body includes an after-fix run against a real Gateway and Codex app-server with Docker deliberately unavailable, showing successful chat and no host-execution canary; redact any private environment details in future proof updates.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body includes an after-fix run against a real Gateway and Codex app-server with Docker deliberately unavailable, showing successful chat and no host-execution canary; redact any private environment details in future proof updates.
Evidence reviewed 5 items Tool-activation implementation: The proposed runtime policy distinguishes normal turn setup from tool activation: needed is direct for run activation and sandboxed for tool activation.
Fail-closed Codex boundary: The proposed Codex policy blocks its native execution surface while needed mode has no active OpenClaw sandbox, rather than allowing the native surface to select host execution.
Focused regression coverage: The branch adds targeted tests for deferred backend creation, lazy exec failure, sandbox explanation output, policy validation, and Codex native-tool gating.
Findings None None.
Security None None.

How this fits together

OpenClaw resolves sandbox policy before preparing an agent turn and builds the execution tools available to that turn. This PR changes that decision from session-wide activation to tool-triggered activation, affecting embedded exec, Codex app-server tools, policy diagnostics, and operator-facing sandbox documentation.

flowchart LR
  A[Operator sandbox config] --> B[Sandbox runtime policy]
  B --> C[Chat turn preparation]
  C --> D[Direct model reply]
  B --> E[Sandbox-bound tool request]
  E --> F[Lazy sandbox activation]
  F --> G[Isolated execution or clear failure]
  B --> H[Codex native tool gating]
Loading

Decision needed

Question Recommendation
Should OpenClaw permanently expose sandbox.mode: "needed" as the supported opt-in policy for keeping chat available while sandbox-bound execution fails closed during backend outages? Sponsor the mode and complete current-base review: Accept needed as a supported opt-in policy, then require a rebase and refreshed backend-boundary validation before merge.

Why: The implementation is broader than a localized bug repair: it adds a durable configuration mode and defines a new execution-isolation contract across core and the Codex extension.

Before merge

  • Resolve merge risk (P1) - The new needed value is a compatibility-sensitive public configuration contract; maintainers need to confirm that the additional mode is the desired long-term product surface rather than a narrower repair to Docker availability handling.
  • Resolve merge risk (P1) - The branch is reported as draft and currently dirty against main, so its real-behavior evidence and focused tests need a rebase/current-head refresh before it can be merged.
  • Resolve merge risk (P1) - The change deliberately alters isolation timing across embedded exec and the Codex app-server boundary; maintainer review should confirm that the documented fail-closed behavior remains consistent for every supported sandbox backend and execution target.
  • Complete next step (P2) - A maintainer must first choose whether the new public sandbox mode belongs in the long-term product contract; after that, the contributor should rebase and refresh validation on the mergeable head.
Agent review details

Security

None.

PR surface

Source +190, Tests +354, Docs +4. Total +548 across 49 files.

View PR surface stats
Area Files Added Removed Net
Source 31 262 72 +190
Tests 11 358 4 +354
Docs 7 25 21 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 49 645 97 +548

Review metrics

Metric Value Why it matters
Public configuration contract 1 sandbox mode added needed expands the validated configuration and documentation contract across core and policy extension surfaces.

Stored data model

Persistent data-model change detected: database schema: src/claws/schema.test.ts, serialized state: extensions/policy/src/doctor/register.sandbox-and-tools.test-utils.ts, serialized state: src/commands/sandbox-explain.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Sponsor, rebase, and refresh boundary proof (recommended)
    Confirm the new configuration contract, rebase the branch onto current main, and show the fail-closed behavior for the supported sandbox backends before merge.
  2. Pause the public-mode proposal
    Keep the existing mode contract if maintainers do not want another long-lived sandbox configuration value.

Technical review

Best possible solution:

Sponsor needed as a documented opt-in sandbox mode, preserve existing stored modes and defaults, then rebase onto current main and refresh focused proof for Docker plus the supported non-Docker sandbox backends.

Do we have a high-confidence way to reproduce the issue?

Unclear. The PR supplies a detailed after-fix macOS Gateway and Codex app-server transcript, and the changed policy has focused tests, but this read-only review did not independently reproduce the Docker-unavailable baseline on current main.

Is this the best way to solve the issue?

Unclear. Lazy, fail-closed activation is a coherent solution to the reported outage, but adding a durable public sandbox mode is only the best solution if maintainers endorse that product and security contract.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 2f80f87c32b5.

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: Adding a validated sandbox mode changes the public configuration, policy-validation, diagnostic, and documentation contract.
  • add merge-risk: 🚨 security-boundary: The mode changes when isolated execution is activated and relies on fail-closed handling to prevent host execution while no sandbox exists.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes an after-fix run against a real Gateway and Codex app-server with Docker deliberately unavailable, showing successful chat and no host-execution canary; redact any private environment details in future proof updates.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes an after-fix run against a real Gateway and Codex app-server with Docker deliberately unavailable, showing successful chat and no host-execution canary; redact any private environment details in future proof updates.

Label justifications:

  • P2: This is a substantial but non-emergency availability and execution-policy improvement whose merge requires product and upgrade review.
  • merge-risk: 🚨 compatibility: Adding a validated sandbox mode changes the public configuration, policy-validation, diagnostic, and documentation contract.
  • merge-risk: 🚨 security-boundary: The mode changes when isolated execution is activated and relies on fail-closed handling to prevent host execution while no sandbox exists.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes an after-fix run against a real Gateway and Codex app-server with Docker deliberately unavailable, showing successful chat and no host-execution canary; redact any private environment details in future proof updates.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes an after-fix run against a real Gateway and Codex app-server with Docker deliberately unavailable, showing successful chat and no host-execution canary; redact any private environment details in future proof updates.

Evidence

What I checked:

Likely related people:

  • steipete: This PR adds a public sandbox configuration mode and changes the repository's execution-isolation posture, so the owner of product and security direction is the appropriate routing point; direct local history inspection was unavailable in this read-only environment. (role: likely product-direction owner; confidence: low; files: src/agents/sandbox/runtime-status.ts, src/config/zod-schema.agent-runtime.ts, extensions/codex/src/app-server/native-execution-policy.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Obtain explicit sponsorship for the needed sandbox-mode contract.
  • Rebase onto current main and refresh the focused boundary evidence on the rebased head.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-07-01T15:49:53.918Z sha c7e216167ec5b09f43f808215231ae3b7a3eda11 :: needs real behavior proof before merge. :: [P1] Block Codex native execution under needed mode
  • reviewed 2026-07-01T19:09:42.671Z sha c7e216167ec5b09f43f808215231ae3b7a3eda11 :: needs real behavior proof before merge. :: [P1] Block Codex native tools under needed mode | [P2] Align policy validation with needed mode

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. labels Jun 19, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jun 20, 2026
@clawsweeper
clawsweeper Bot temporarily deployed to qa-live-shared June 20, 2026 18:18 Inactive
@openclaw-mantis

Copy link
Copy Markdown
Contributor

Mantis Telegram Desktop Proof

Summary: Mantis captured native Telegram Desktop before/after GIFs showing a chat prompt without a baseline reply and the PR returning the expected reply.

Main screenshot This PR screenshot
Baseline native Telegram Desktop screenshot Candidate native Telegram Desktop screenshot
Main This PR
Baseline native Telegram Desktop proof GIF Candidate native Telegram Desktop proof GIF

Motion-trimmed clips:

Raw QA files: https://artifacts.openclaw.ai/mantis/telegram-desktop/pr-95005/run-27879744883-1/index.json

@clawsweeper clawsweeper Bot added proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: 🎥 video Contributor real behavior proof includes video or recording evidence. and removed proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. labels Jun 20, 2026
@xuwei-xy

Copy link
Copy Markdown

A potential solution is to modify ui. What do you think?

@yu-xin-c yu-xin-c changed the title [codex] Add needed sandbox activation mode Add needed sandbox activation mode Jul 1, 2026
@clawsweeper clawsweeper Bot removed the proof: 🎥 video Contributor real behavior proof includes video or recording evidence. label Jul 1, 2026
@barnacle-openclaw

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@barnacle-openclaw barnacle-openclaw Bot added the stale Marked as stale due to inactivity label Jul 22, 2026
@yu-xin-c
yu-xin-c force-pushed the codex/80296-sandbox-needed-mode branch from c7e2161 to f36938b Compare July 22, 2026 08:11
@openclaw-barnacle openclaw-barnacle Bot added size: L and removed size: M triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 22, 2026
@yu-xin-c
yu-xin-c force-pushed the codex/80296-sandbox-needed-mode branch 2 times, most recently from 746a790 to 3168399 Compare July 23, 2026 04:15
@yu-xin-c

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Jul 23, 2026
@yu-xin-c
yu-xin-c force-pushed the codex/80296-sandbox-needed-mode branch from 3168399 to 1212d3e Compare July 24, 2026 08:42
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. and removed mantis: telegram-visible-proof Mantis should capture Telegram visible proof. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 29, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Aug 15, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations docker Docker and sandbox tooling docs Improvements or additions to documentation extensions: codex extensions: policy gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L stale Marked as stale due to inactivity status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

agents.defaults.sandbox.mode is binary (all/none) — full bot outage when Docker briefly stops, including chat-only turns

2 participants