Skip to content

bug(session-manager): CLAUDECODE nesting env vars leak to child Claude Code processes — silent exit #3

Description

@apex-skyner

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions