Skip to content

sessions_spawn subagent inherits parent agent's cwd instead of using target agent's workspace #42712

@Yunsnow

Description

@Yunsnow

Bug Description

When using sessions_spawn to spawn a subagent with a different agentId, the subagent inherits the parent agent's current working directory (cwd) instead of using the target agent's configured workspace path.

Steps to Reproduce

  1. Configure two agents with different workspaces:
{
  "agents": {
    "list": [
      { "id": "main", "workspace": "~/.openclaw/workspace" },
      { "id": "clc-backend", "workspace": "~/.openclaw/workspace-clc-backend" }
    ]
  }
}
  1. From main agent, spawn clc-backend:
sessions_spawn(agentId="clc-backend", task="run pwd to show workspace")
  1. Check the subagent transcript - the cwd is set to /Users/dylon/.openclaw/workspace (main's workspace) instead of /Users/dylon/.openclaw/workspace-clc-backend.

Expected Behavior

The subagent should start with cwd set to the target agent's configured workspace path.

Actual Behavior

The subagent inherits the parent agent's cwd.

Environment

  • OpenClaw version: 2026.3.8
  • OS: macOS (Darwin 25.3.0 arm64)

Workaround

Currently need to explicitly cd in the task or use absolute paths.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions