claude-code - 💡(How to fix) Fix Auto-retry sandboxed Bash commands with sandbox disabled instead of instructing the model to do it

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

  1. Reliability — in practice the retry often doesn't happen. The model reads the sandbox error as a real bug (missing file, bad argument, network flake, etc.) and either gives up, asks the user, or starts debugging the wrong thing instead of re-running with the sandbox disabled. The decision is fully deterministic from the error signal, so the harness is better positioned to make it than the model is — it's both faster and more reliable. Today, users pay an extra turn of latency in the best case and silently lose the retry entirely in the worst case.

Root Cause

  1. Latency — every sandbox-blocked command adds a full model round-trip before the user sees a working result. And because the same prompt also says never to preempt the sandbox on the first attempt, this round-trip repeats on every out-of-sandbox command in a session.
  2. Reliability — in practice the retry often doesn't happen. The model reads the sandbox error as a real bug (missing file, bad argument, network flake, etc.) and either gives up, asks the user, or starts debugging the wrong thing instead of re-running with the sandbox disabled.
RAW_BUFFERClick to expand / collapse

Problem

The system prompt tells the model: "When you see evidence of sandbox-caused failure: immediately retry with dangerouslyDisableSandbox: true (don't ask, just do it)." This routes a deterministic retry through the model, which has two costs:

  1. Latency — every sandbox-blocked command adds a full model round-trip before the user sees a working result. And because the same prompt also says never to preempt the sandbox on the first attempt, this round-trip repeats on every out-of-sandbox command in a session.
  2. Reliability — in practice the retry often doesn't happen. The model reads the sandbox error as a real bug (missing file, bad argument, network flake, etc.) and either gives up, asks the user, or starts debugging the wrong thing instead of re-running with the sandbox disabled.

Proposal

On a Bash tool result that matches the documented sandbox-failure signals ("Operation not permitted", "Access denied to specific paths outside allowed directories", network/socket errors on non-whitelisted hosts), have Claude Code transparently re-run the same command with the sandbox disabled and return the second result to the model. The model only gets involved if the retry also fails.

Why it matters

The decision is fully deterministic from the error signal, so the harness is better positioned to make it than the model is — it's both faster and more reliable. Today, users pay an extra turn of latency in the best case and silently lose the retry entirely in the worst case.

Prior art

Some other coding agents in this space already handle sandbox/permission retries at the harness layer rather than asking the model to do it, and the result is a noticeably tighter feedback loop.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING