openclaw - ✅(Solved) Fix Subagent loads bootstrap files from main workspace instead of configured agent workspace [1 pull requests, 7 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#43653Fetched 2026-04-08 00:16:20
View on GitHub
Comments
7
Participants
2
Timeline
11
Reactions
0
Author
Participants
Timeline (top)
commented ×7closed ×1cross-referenced ×1locked ×1

Fix Action

Fix / Workaround

Workarounds Attempted

PR fix notes

PR #44862: fix(agents): use correct bootstrap files for subagents

Description (problem / solution / changelog)

When a subagent runs with a custom workspace, resolveBootstrapContextForRun was using the parent's workspace instead of the agent's configured workspace. This caused subagents to use incorrect bootstrap files.

The fix passes agentId to resolveBootstrapContextForRun so it can resolve the correct agent-specific workspace via resolveAgentWorkspaceDir.

Added test to verify agent-specific workspace resolution.

Summary

Describe the problem and fix in 2–5 bullets:

  • Problem:
  • Why it matters:
  • What changed:
  • What did NOT change (scope boundary):

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

User-visible / Behavior Changes

List user-visible changes (including defaults/config).
If none, write None.

Security Impact (required)

  • New permissions/capabilities? (Yes/No)
  • Secrets/tokens handling changed? (Yes/No)
  • New/changed network calls? (Yes/No)
  • Command/tool execution surface changed? (Yes/No)
  • Data access scope changed? (Yes/No)
  • If any Yes, explain risk + mitigation:

Repro + Verification

Environment

  • OS:
  • Runtime/container:
  • Model/provider:
  • Integration/channel (if any):
  • Relevant config (redacted):

Steps

  1. in Gateway Dashboard webui input "@agent_xxx who are you?"

Expected

  • answer as agent_xxx, use agent_xxx's soul.md

Actual

  • answer as default agent, use soul.md under default workspace

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios:
  • Edge cases checked:
  • What you did not verify:

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.

Compatibility / Migration

  • Backward compatible? (Yes/No)
  • Config/env changes? (Yes/No)
  • Migration needed? (Yes/No)
  • If yes, exact upgrade steps:

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly:
  • Files/config to restore:
  • Known bad symptoms reviewers should watch for:

Risks and Mitigations

List only real risks for this PR. Add/remove entries as needed. If none, write None.

  • Risk:
    • Mitigation:

Changed files

  • src/agents/bootstrap-files.test.ts (modified, +38/-0)
  • src/agents/bootstrap-files.ts (modified, +8/-3)
  • src/agents/pi-embedded-runner/run/attempt.ts (modified, +1/-0)

Code Example

{
  "agents": {
    "list": [
      {
        "id": "main",
        "workspace": "/Users/river/.openclaw/workspace"
      },
      {
        "id": "pdm",
        "workspace": "/Users/river/.openclaw/workspace-pdm"
      },
      {
        "id": "designer", 
        "workspace": "/Users/river/.openclaw/workspace-designer"
      },
      {
        "id": "rd",
        "workspace": "/Users/river/.openclaw/workspace-rd"
      },
      {
        "id": "qa",
        "workspace": "/Users/river/.openclaw/workspace-qa"
      }
    ]
  }
}

---

{
  "task": "Report your working directory and the first 3 lines of SOUL.md",
  "agentId": "rd",
  "mode": "run",
  "runtime": "subagent"
}
RAW_BUFFERClick to expand / collapse

Bug Description

When spawning subagents via sessions_spawn, the subagent loads bootstrap files (SOUL.md, AGENTS.md, etc.) from the main workspace (~/.openclaw/workspace) instead of the workspace configured for that specific agent in openclaw.json.

Environment

  • OpenClaw Version: 2026.3.8 (3caab92)
  • OS: macOS (Darwin 24.6.0 arm64)
  • Node: v25.6.1

Configuration

My openclaw.json has multiple agents configured with separate workspaces:

{
  "agents": {
    "list": [
      {
        "id": "main",
        "workspace": "/Users/river/.openclaw/workspace"
      },
      {
        "id": "pdm",
        "workspace": "/Users/river/.openclaw/workspace-pdm"
      },
      {
        "id": "designer", 
        "workspace": "/Users/river/.openclaw/workspace-designer"
      },
      {
        "id": "rd",
        "workspace": "/Users/river/.openclaw/workspace-rd"
      },
      {
        "id": "qa",
        "workspace": "/Users/river/.openclaw/workspace-qa"
      }
    ]
  }
}

Each workspace has its own SOUL.md with different role definitions.

Steps to Reproduce

  1. Configure multiple agents with separate workspaces in openclaw.json
  2. Create different SOUL.md files in each workspace
  3. Spawn a subagent using sessions_spawn with specific agentId
  4. Ask the subagent to report its working directory and SOUL.md content

Example spawn request:

{
  "task": "Report your working directory and the first 3 lines of SOUL.md",
  "agentId": "rd",
  "mode": "run",
  "runtime": "subagent"
}

Expected Behavior

The subagent should:

  1. Use the workspace configured for that agent (workspace-rd for agentId: rd)
  2. Load the SOUL.md from that workspace

Actual Behavior

AgentExpected WDActual WDExpected SOULActual SOULStatus
pdmworkspace-pdmworkspacepdm's SOULmain's SOUL❌ Fail
designerworkspace-designerworkspacedesigner's SOULmain's SOUL❌ Fail
rdworkspace-rdworkspace-rd*rd's SOULmain's SOUL⚠️ Partial
qaworkspace-qaworkspaceqa's SOULmain's SOUL❌ Fail

* Note: RD got the correct working directory once, but still loaded the wrong SOUL.md

Impact

This bug prevents multi-agent workflows where different agents need different identity/persona definitions. All subagents effectively become clones of the main agent.

Workarounds Attempted

  • Tried using cwd parameter in sessions_spawn - causes inconsistent behavior
  • Verified all workspace directories exist with correct permissions
  • Confirmed openclaw.json configuration is valid (agents show correct workspace in openclaw agents list)

Additional Context

The agent:bootstrap event seems to load files from the parent session's context rather than the agent's configured workspace. This happens even when the working directory is technically correct (as seen with RD agent).

extent analysis

Fix Plan

To resolve the issue, we need to ensure that the subagent loads the bootstrap files from the correct workspace. We can achieve this by modifying the sessions_spawn function to set the working directory and load the bootstrap files from the agent's configured workspace.

Step 1: Update sessions_spawn function

// Update the sessions_spawn function to set the working directory
// and load bootstrap files from the agent's workspace
function sessions_spawn(agentId, task) {
  const agentConfig = getAgentConfig(agentId);
  const workspace = agentConfig.workspace;

  // Set the working directory to the agent's workspace
  process.chdir(workspace);

  // Load bootstrap files from the agent's workspace
  loadBootstrapFiles(workspace);

  // Spawn the subagent
  const subagent = spawnSubagent(task);

  return subagent;
}

// Helper function to load bootstrap files from a given workspace
function loadBootstrapFiles(workspace) {
  const bootstrapFiles = ['SOUL.md', 'AGENTS.md'];
  bootstrapFiles.forEach((file) => {
    const filePath = path.join(workspace, file);
    const fileContent = fs.readFileSync(filePath, 'utf8');
    // Process the file content as needed
  });
}

Step 2: Update getAgentConfig function

// Update the getAgentConfig function to retrieve the agent's configuration
// from the openclaw.json file
function getAgentConfig(agentId) {
  const openclawConfig = JSON.parse(fs.readFileSync('openclaw.json', 'utf8'));
  const agents = openclawConfig.agents.list;
  const agentConfig = agents.find((agent) => agent.id === agentId);

  return agentConfig;
}

Verification

To verify that the fix worked, you can test the sessions_spawn function with different agent IDs and verify that the subagent loads the correct bootstrap files from the agent's workspace.

// Example test request
{
  "task": "Report your working directory and the first 3 lines of SOUL.md",
  "agentId": "rd",
  "mode": "run",
  "runtime": "subagent"
}

Extra Tips

  • Ensure that the openclaw.json file is correctly formatted and that the agent configurations are valid.
  • Verify that the workspace directories exist and have the correct permissions.
  • Test the sessions_spawn function with different agent IDs to ensure that the fix works for all agents.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING