Skip to content

sessions_spawn cross-agent subagents run in requester workspace (cwd ignored) #43900

Description

@PMIagentC

Title: sessions_spawn cross-agent subagents run in requester workspace (cwd ignored), blocking separate agent workspace brains

Summary

When spawning a subagent via sessions_spawn with agentId="tech-support", the spawned run behaves as if its working directory/workspace context is still the requester agent’s workspace (~/.openclaw/workspace-pmi-assistant). Attempts to override with cwd did not change this behavior. This blocks a multi-agent setup where the delegated specialist must operate from its own seeded workspace (~/.openclaw/workspace-tech-support).

Environment

  • OpenClaw: 2026.3.11 (29dc654)
  • OS: macos 26.3 (arm64)
  • Node: 22.22.1 (per openclaw status)
  • Gateway: local loopback ws://127.0.0.1:18789 (reachable)
  • Agents configured:
    • pmi-assistant (default), workspace ~/.openclaw/workspace-pmi-assistant
    • tech-support, workspace ~/.openclaw/workspace-tech-support

Relevant config (high level)

  • agents.list contains both pmi-assistant (default) and tech-support with distinct workspace paths.
  • agents.list.0.subagents.allowAgents includes tech-support (so spawning is allowed).
  • tools.agentToAgent.enabled=true, allow=["tech-support"] (also enabled, though core issue is sessions_spawn cwd/workspace behavior).

Reproduction steps

  1. Create two agents with distinct workspaces.
  2. Allow pmi-assistant to spawn tech-support:
    • set agents.list.0.subagents.allowAgents to include tech-support
    • confirm agents_list shows tech-support
  3. From a pmi-assistant session, call sessions_spawn with:
    • runtime: "subagent"
    • agentId: "tech-support"
    • task instructing the child to read ./AGENTS.md + ./MEMORY.md and verify ./memory/* (files exist in ~/.openclaw/workspace-tech-support).
  4. Control test: call sessions_spawn with cwd: "/tmp" and ask the child to run pwd.

Expected behavior

  • If agentId targets another agent, the spawned run should use the target agent’s workspace as default cwd (so relative paths and bootstrap/memory files resolve under that workspace).
  • If cwd is supported for runtime=subagent, it should be honored.

Actual behavior

  • The spawned run consistently operates as if in ~/.openclaw/workspace-pmi-assistant.
  • The cwd parameter appears ignored for runtime=subagent.

Local evidence (transcript)

For a strict-evidence run under agent:tech-support:subagent:..., the session transcript header shows:

  • "cwd":"/Users/pmi.agent/.openclaw/workspace-pmi-assistant"

And the child’s tool calls read PMI workspace files, e.g.:

  • read /Users/pmi.agent/.openclaw/workspace-pmi-assistant/AGENTS.md
  • read /Users/pmi.agent/.openclaw/workspace-pmi-assistant/MEMORY.md (ENOENT)

Control test:

  • spawn with cwd=/tmp → child pwd still prints /Users/pmi.agent/.openclaw/workspace-pmi-assistant.

Docs note

The Session Tools docs for sessions_spawn do not mention a cwd parameter or workspace override semantics:

Questions

  1. Is this intended (subagents always inherit requester workspace) or a bug for cross-agent spawn?
  2. If intended, what is the supported mechanism to delegate work to another agent and ensure the target agent’s workspace bootstrap/memory are used?
  3. If a bug, should sessions_spawn(agentId=...) set child cwd to the target agent workspace?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions