Repository navigation
Description
Bug type
Behavior bug (incorrect output/state without crash)
Summary
OpenClaw can treat failed codex exec --json runs as successful because Codex may emit sandbox/write-denied failure information in JSONL agent output while still exiting with status code 0.
Steps to reproduce
- Use OpenClaw
2026.3.2with the built-incodex-clibackend. - Trigger a Codex-backed subagent write task in an effective read-only Codex sandbox, or reproduce directly with Codex:
codex exec "Write a new file named TEST_RO.md with the content 'hello'." --json --color never --sandbox read-only --skip-git-repo-check
- Observe that no file is created.
- Observe that Codex emits JSONL events describing the write failure as agent output.
- Observe that the Codex process still exits with
EXIT_CODE=0. - In OpenClaw, the run can then be interpreted as completed/successful even though the requested mutation never happened.
Expected behavior
OpenClaw should inspect Codex JSONL output for failed action/tool signals and propagate the run as failed when the underlying file mutation or command execution was denied or rejected.
Actual behavior
A Codex run can fail semantically while still looking successful to OpenClaw because:
- the process exit code is
0 - the failure is surfaced only in JSONL event content
- no file is actually created or modified
This can cause subagent orchestration to record a run as completed even though the requested write never happened.
OpenClaw version
2026.3.2 (52a583035f)
Operating system
Debian GNU/Linux 13 (trixie)
Install method
Local source checkout / dev run
Logs, screenshots, and evidence
Direct Codex repro:
codex exec "Write a new file named TEST_RO.md with the content 'hello'." --json --color never --sandbox read-only --skip-git-repo-check
Observed:
- No file created
- Codex JSONL includes an agent message explaining the write was blocked by a read-only filesystem / write approval policy
- Process exit code is still 0
Control repro:
- Same command with --sandbox workspace-write creates the file successfullyImpact and severity
Affected: Users relying on Codex-backed subagents or Codex fallback runs for coding/file tasks
Severity: High, because failed work can be misreported as successful
Frequency: Reproducible whenever Codex surfaces the failure only through JSONL content while exiting 0
Consequence: Silent false positives in subagent execution, misleading summaries, and harder debugging of failed automation
Additional information
A robust fix is to parse Codex JSONL for failed command_execution / shell_command / file_change items and known sandbox-denied agent messages instead of relying only on process exit status.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
[-]OpenClaw treats codex exec sandbox-denied runs as success because codex exits 0[/-][+][Bug]: OpenClaw treats codex exec sandbox-denied runs as success because codex exits 0[/+]rnrnstar2 commentedon Mar 8, 2026
Priority: P1 - 実行状態管理の欠陥。サンドボックス拒否を成功と誤認し、セキュリティリスクとデバッグ困難性を引き起こす。
rnrnstar2 commentedon Mar 8, 2026
🔥 P1 Priority - OpenClaw treats codex exec sandbox-denied runs as success because codex exits 0. This causes silent failures in subagent workflows. Requires exit code handling fix.
fix(agents): detect codex sandbox-denied runs that exit 0 as failures
mvanhorn commentedon Mar 8, 2026
Submitted a fix in #39460.
The approach: scan structured JSONL fields (error items, tool-call outputs, status fields) for sandbox-denied signals after Codex exits 0. When detected, the CLI runner throws a
FailoverErrorwith reason"sandbox_denied"instead of passing the agent's failure reasoning as successful output.Key design choice: detection only checks structured fields (
item.type === "error", tool/command items, top-levelerror), not regular message text. This prevents false positives when an agent merely discusses sandboxing without actually being denied.Also added
"sandbox_denied"as a newFailoverReason(mapped to 403) and excluded it from auth profile failure tracking since it's a local config issue.11 regression tests covering detection and false-positive prevention.
openclaw-barnacle commentedon Apr 23, 2026
This issue has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.
clawsweeper commentedon Apr 26, 2026
Thanks for the context here. I did a careful shell check against current
main, and this is already implemented.Current main resolves the reported built-in
codex-clifalse-success path by removing the bundled direct Codex CLI backend and routing legacy Codex CLI refs to the Codex app-server runtime. The earlier structured-JSONL fix attempt is useful context, but the supported core path no longer executescodex exec --jsonthrough a bundledcodex-clibackend.So I’m closing this as already implemented rather than keeping a duplicate issue open.
Review details
Best possible solution:
Keep the Codex app-server migration as the supported OpenAI Codex path, and treat any future false-success report for an explicit custom CLI backend as a new plugin-owned or generic CLI contract issue with current-main config evidence.
Do we have a high-confidence way to reproduce the issue?
No current-main reproduction remains for the reported built-in
codex-clipath. Current source and docs show that OpenClaw no longer bundles that backend and migrates legacy Codex CLI refs to the Codex app-server route.Is this the best way to solve the issue?
Yes, for the reported supported core path. Removing the bundled direct Codex CLI route is the narrower maintainable core solution; Codex-specific JSONL failure parsing should only return if a supported plugin/runtime contract needs it.
Security review:
Security review cleared: No PR diff is under review; the sandbox-denial false-success concern is addressed on current main by removing the affected bundled runtime path.
What I checked:
openai/*and OpenClaw no longer registers a bundledcodex-clibackend. Public docs:docs/gateway/cli-backends.md. (docs/gateway/cli-backends.md:300, 8dc213227bee)FALLBACK_CLI_BACKEND_POLICIESis empty, soresolveCliBackendConfighas no core-owned built-incodex-clibackend without a plugin or explicit user config. (src/agents/cli-backends.ts:70, 8dc213227bee)table.owners.cliBackends.get("codex-cli")is undefined, proving the bundled registry no longer mapscodex-clito the OpenAI plugin. (src/plugins/plugin-lookup-table.test.ts:251, 8dc213227bee)agentRuntime.id: "codex-cli"to"codex", preserving legacy config on the supported app-server route instead of the old direct CLI backend. (src/commands/doctor/shared/legacy-config-core-normalizers.ts:255, 8dc213227bee)v2026.5.12removes"cliBackends": ["codex-cli"]from the OpenAI plugin metadata and changes the lookup-table expectation fromcodex-cliowned byopenaito undefined. (extensions/openai/openclaw.plugin.json, b7893fc1586c)codex-clidocs and migration lines in this checkout tob7893fc1586cd9e9d9ebe86680fda65a561b895b, which is the best current-main proof SHA for this cleanup. Public docs:docs/gateway/cli-backends.md. (docs/gateway/cli-backends.md:296, b7893fc1586c)Likely related people:
codex-clisandbox-default change and later introduced/maintained the Codex app-server harness work that now owns the supported Codex route. (role: introduced behavior and adjacent owner; confidence: high; commits: 5b257c65d5a7, dd26e8c44d4e, 58f1db1bc8eb; files:src/agents/cli-backends.ts,extensions/codex/openclaw.plugin.json,extensions/codex/src/app-server/run-attempt.ts)src/agents/openai-codex-routing.ts,src/agents/pi-embedded-runner/run.ts,docs/plugins/codex-harness.md)CHANGELOG.md,docs/gateway/cli-backends.md,docs/concepts/model-providers.md)sandbox_deniedfailover design. (role: prior fix proposer; confidence: medium; commits: 15b25584b029, 82a261c92701, d80cd24509c6; files:src/agents/cli-runner.ts,src/agents/cli-runner/helpers.ts,src/agents/failover-error.ts)Codex review notes: model gpt-5.5, reasoning high; reviewed against 8dc213227bee; fix evidence: commit b7893fc1586c, main fix timestamp 2026-05-17T05:09:05Z.