Problem
When OpenClaw dispatches Claude Code as a background agent via agent_launch, the child process inherits CLAUDECODE=1, CLAUDE_CODE_SESSION, and CLAUDE_CODE_ENTRYPOINT from the parent environment.
Claude Code checks for CLAUDECODE=1 as a nesting guard and silently exits without running the task. This gives a 0% success rate on all agent_launch calls with harness: "claude-code".
Root Cause
In src/session-manager.ts:
env: {
...process.env, // <-- inherits CLAUDECODE=1, CLAUDE_CODE_SESSION, CLAUDE_CODE_ENTRYPOINT
CI: 'true',
TERM: 'dumb',
},
Fix
Strip the nesting markers from the child env:
env: {
...process.env,
CI: 'true',
TERM: 'dumb',
// Strip Claude Code nesting markers to prevent silent exit in nested spawns
CLAUDECODE: undefined,
CLAUDE_CODE_SESSION: undefined,
CLAUDE_CODE_ENTRYPOINT: undefined,
CLAUDE_CODE_SKIP_TELEMETRY_CONFIRM: '1',
},
Related
Problem
When OpenClaw dispatches Claude Code as a background agent via
agent_launch, the child process inheritsCLAUDECODE=1,CLAUDE_CODE_SESSION, andCLAUDE_CODE_ENTRYPOINTfrom the parent environment.Claude Code checks for
CLAUDECODE=1as a nesting guard and silently exits without running the task. This gives a 0% success rate on allagent_launchcalls withharness: "claude-code".Root Cause
In
src/session-manager.ts:Fix
Strip the nesting markers from the child env:
Related