Skip to content

Commit af47a08

Browse files
fix(engine-claude-agent-sdk): set IS_SANDBOX=1 for spawned Claude CLI
The harness always runs the Claude Code CLI with permissionMode bypassPermissions (--dangerously-skip-permissions). Claude Code refuses that flag as root and exits 1 ("cannot be used with root/sudo privileges"), which is exactly what happens in the deployed containers (uid 0) — every agent turn fails with "Claude Code process exited with code 1" and 0 tokens, surfacing as an empty reply in the UI. The CLI is already confined to an isolated substrate workdir, so declare IS_SANDBOX=1 in the subprocess env to allow skip-permissions regardless of uid. Defaulted first so ctx.envs can still override. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent c8742d9 commit af47a08

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

  • packages/engine-claude-agent-sdk/src

packages/engine-claude-agent-sdk/src/engine.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,15 @@ export class ClaudeAgentEngine implements EngineDriver<ClaudeAgentOptions> {
102102
// isn't in the env we pass to query(), the subprocess can't resolve the
103103
// write path and silently drops every mirror frame. ctx.envs alone
104104
// typically only carries API keys — that's not enough.
105-
env: { ...inheritEssentialHostEnv(), ...ctx.envs },
105+
//
106+
// IS_SANDBOX=1: the harness always runs the CLI with permissionMode
107+
// bypassPermissions (→ --dangerously-skip-permissions). Claude Code
108+
// refuses that flag when running as root ("cannot be used with
109+
// root/sudo privileges") and exits 1 — which is exactly what happens in
110+
// our containers (they run as uid 0). Since the CLI is already confined
111+
// to an isolated substrate workdir, declare IS_SANDBOX so skip-permissions
112+
// is allowed regardless of uid. Default first so ctx.envs can override.
113+
env: { IS_SANDBOX: "1", ...inheritEssentialHostEnv(), ...ctx.envs },
106114
includePartialMessages: true,
107115
abortController,
108116
canUseTool: buildCanUseTool(ctx.onPermissionRequest),

0 commit comments

Comments
 (0)