openclaw - ✅(Solved) Fix [Bug]: agents add default workspace now nests bot inside main workspace, causing TUI routing ambiguity [3 pull requests, 1 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#78093Fetched 2026-05-06 06:16:57
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
2
Author
Timeline (top)
cross-referenced ×3commented ×1referenced ×1

Since #59789, openclaw agents add defaults to placing a new agent's workspace inside the main workspace (workspace/newbot/) instead of as a sibling directory (workspace-newbot/). This introduces TUI routing ambiguity where both the default agent and the new bot match the same file path.

Root Cause

The default workspace for a new agent is ~/.openclaw/workspace/newbot/ — nested inside the main workspace. Because resolveAgentIdsByWorkspacePath uses isPathWithinRoot (path.relative-based containment check), any path under workspace/newbot/ also matches the default agent's workspace/, so both agents are returned. The longer path wins via sort, but the boundary is ambiguous and fragile.

Fix Action

Workaround

Explicitly pass --workspace when creating agents:

openclaw agents add newbot --workspace ~/.openclaw/workspace-newbot

PR fix notes

PR #78111: fix(agents): non-default agents use sibling workspace dirs, not nested (#78093)

Description (problem / solution / changelog)

Problem

Closes #78093.

When agents.defaults.workspace was set (e.g. ~/.openclaw/workspace) and a new agent was created without an explicit --workspace, the suggested workspace path was nested inside the default workspace: ~/.openclaw/workspace/newbot.

This introduced routing ambiguity: resolveAgentIdsByWorkspacePath uses isPathWithinRoot (path prefix containment), so any path under workspace/newbot/ also matched the default agent's workspace/. Both agents were returned; the longer path won via sort, but the boundary was fragile and confusing.

The regression was introduced by #59789, which changed the non-default agent fallback from path.join(stateDir, 'workspace-${id}') to path.join(fallback, id). The #59789 fix was correct for the default agent (honour agents.defaults.workspace), but it accidentally over-applied to all agents.

Fix

For non-default agents without an explicit per-agent workspace config, when agents.defaults.workspace is set, generate the default workspace as a sibling of the fallback directory rather than a child:

Before: ~/.openclaw/workspace/newbot   ← nested, causes routing ambiguity
After:  ~/.openclaw/workspace-newbot   ← sibling, routing stays unambiguous

The workspace-${id} suffix convention matches the existing stateDir-based fallback path and is what the issue author describes as the pre-#59789 behavior.

Files changed

FileChange
src/agents/agent-scope-config.tsresolveAgentWorkspaceDir: use path.dirname(fallback)/workspace-${id} for non-default agents instead of fallback/${id}
src/agents/agent-scope.test.tsUpdate existing regression test (#59789 behavior was wrong); add test for nested defaults.workspace path

Tests

Tests  60 passed (60)   # all pre-existing tests pass with corrected assertion

🤖 Generated with Claude Code

Changed files

  • src/agents/agent-scope-config.ts (modified, +3/-1)
  • src/agents/agent-scope.test.ts (modified, +15/-2)

PR #78113: fix(agents): restore workspace-<id> sibling layout for non-default agents

Description (problem / solution / changelog)

Summary

  • Problem: PR #59789 changed resolveAgentWorkspaceDir so that non-default agents would use agents.defaults.workspace as a base, resulting in nested paths like ~/.openclaw/workspace/newbot/ instead of the expected sibling layout ~/.openclaw/workspace-newbot/. This caused TUI routing ambiguity where both the default agent and non-default bots matched the same workspace prefix.
  • Why it matters: Users who run openclaw agents add to create a new bot see workspace path changes and TUI routing breaks when agents.defaults.workspace is set.
  • What changed: resolveAgentWorkspaceDir in src/agents/agent-scope-config.ts now only applies agents.defaults.workspace to the default agent. Non-default agents always fall back to stateDir/workspace-<id> (sibling layout), restoring pre-#59789 behavior.
  • What did NOT change: Default agents still fully respect agents.defaults.workspace. Non-default agents with an explicit per-agent workspace config still use their configured path.

Change Type (select all)

  • Bug fix

Scope (select all touched areas)

  • Gateway / orchestration

Linked Issue/PR

  • Closes #78093
  • Related #59789

User-visible / Behavior Changes

Non-default agents added via agents add now get ~/.openclaw/workspace-<id>/ (sibling) as the default workspace instead of ~/.openclaw/workspace/<id>/ (nested). Users with an explicit per-agent workspace config are unaffected. Default agents are unaffected.

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No

Repro + Verification

Tests updated in src/agents/agent-scope.test.ts:

  1. uses sibling workspace-<id> path for non-default agents regardless of agents.defaults.workspace — verifies non-default agents get the workspace-<id> sibling path even when agents.defaults.workspace is set.
  2. uses agents.defaults.workspace for the default agent — verifies default agents still use agents.defaults.workspace when set.
  3. non-default agent without defaults.workspace falls back to stateDir — unchanged, verifies fallback behavior.

The pre-existing test non-default agent uses agents.defaults.workspace as base (#59789) is replaced by the corrected behavior tests above.

All 28 tests in src/agents/agent-scope.test.ts pass.

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • src/agents/agent-scope-config.ts (modified, +3/-4)
  • src/agents/agent-scope.test.ts (modified, +10/-10)

PR #78122: fix: keep new agent workspaces as siblings

Description (problem / solution / changelog)

Summary

Keep new non-default agent workspaces as sibling workspace-<id> directories instead of nesting them under agents.defaults.workspace. The configured default agent still uses agents.defaults.workspace directly.

Changes

  • Remove the non-default agents.defaults.workspace/<id> fallback in resolveAgentWorkspaceDir
  • Update resolver regression coverage for the sibling fallback
  • Add agents add wizard coverage for the suggested default workspace
  • Add changelog entry

Testing

  • PATH="/tmp/openclaw-pnpm-shim:$PATH" pnpm test src/agents/agent-scope.test.ts src/commands/agents.add.test.ts src/tui/tui.test.ts
  • PATH="/tmp/openclaw-pnpm-shim:$PATH" pnpm exec oxfmt --check --threads=1 src/agents/agent-scope-config.ts src/agents/agent-scope.test.ts src/commands/agents.commands.add.ts src/commands/agents.add.test.ts src/tui/tui.test.ts CHANGELOG.md
  • git diff --check
  • PATH="/tmp/openclaw-pnpm-shim:$PATH" node scripts/check-changed.mjs

Fixes openclaw/openclaw#78093

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • src/agents/agent-scope-config.ts (modified, +0/-3)
  • src/agents/agent-scope.test.ts (modified, +4/-2)
  • src/commands/agents.add.test.ts (modified, +41/-0)

Code Example

openclaw agents add newbot --workspace ~/.openclaw/workspace-newbot
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Summary

Since #59789, openclaw agents add defaults to placing a new agent's workspace inside the main workspace (workspace/newbot/) instead of as a sibling directory (workspace-newbot/). This introduces TUI routing ambiguity where both the default agent and the new bot match the same file path.

Steps to reproduce

  1. Set agents.defaults.workspace to ~/.openclaw/workspace in openclaw.json
  2. Run openclaw agents add newbot and accept the default workspace suggestion
  3. Observe the suggested path: ~/.openclaw/workspace/newbot
  4. Open a file under ~/.openclaw/workspace/newbot/ in TUI

Expected behavior

Non-default agents should default to a sibling directory (workspace-newbot/), independent of the main workspace. This keeps routing boundaries unambiguous.

Actual behavior

The default workspace for a new agent is ~/.openclaw/workspace/newbot/ — nested inside the main workspace. Because resolveAgentIdsByWorkspacePath uses isPathWithinRoot (path.relative-based containment check), any path under workspace/newbot/ also matches the default agent's workspace/, so both agents are returned. The longer path wins via sort, but the boundary is ambiguous and fragile.

Relevant code: src/agents/agent-scope.tsisPathWithinRoot (line 290) and resolveAgentIdsByWorkspacePath (line 295).

Root cause: #59789 fixed a real bug (default agent ignoring agents.defaults.workspace in Control UI), but the fix also changed the fallback path for non-default agents from path.join(stateDir, 'workspace-${id}') to path.join(fallback, id). The original bug was scoped to the default agent; the fix over-applied to all agents.

Expected fix scope

Restore the workspace-${id} default for non-default agents, while keeping the agents.defaults.workspace respected for the default agent (which was the actual bug in #59789).

Workaround

Explicitly pass --workspace when creating agents:

openclaw agents add newbot --workspace ~/.openclaw/workspace-newbot

OpenClaw version

2026.5.3-1

Operating system

macOS 15 (Apple Silicon)

Install method

npm global

Model

anthropic/claude-sonnet-4-6

Provider / routing chain

anthropic

Impact and severity

Affected: All users with agents.defaults.workspace configured who use openclaw agents add without --workspace Severity: Medium — routing still works (longer path wins) but boundary is implicit and brittle Frequency: 100% repro with any custom agents.defaults.workspace Consequence: TUI agent selection becomes ambiguous; confusing UX when multiple agents share a path prefix

extent analysis

TL;DR

The most likely fix is to restore the workspace-${id} default for non-default agents in the agent-scope.ts file.

Guidance

  • Review the changes made in #59789 and identify the specific lines of code that introduced the regression.
  • Update the isPathWithinRoot function in agent-scope.ts to correctly handle the workspace path for non-default agents.
  • Verify the fix by running the steps to reproduce and checking that the suggested path is now a sibling directory (workspace-newbot/) instead of a nested directory (workspace/newbot/).
  • Consider adding a test case to ensure that the resolveAgentIdsByWorkspacePath function returns the correct agent IDs for different workspace paths.

Example

// agent-scope.ts (line 290)
const isPathWithinRoot = (path: string, root: string) => {
  // Update this function to correctly handle workspace paths for non-default agents
  // ...
}

// agent-scope.ts (line 295)
const resolveAgentIdsByWorkspacePath = (path: string) => {
  // Update this function to use the corrected isPathWithinRoot function
  // ...
}

Notes

The fix should be applied to the agent-scope.ts file, and care should be taken to ensure that the changes do not introduce any new bugs or regressions.

Recommendation

Apply the workaround by explicitly passing --workspace when creating agents, until the fix is implemented and verified. This will ensure that the workspace path is correctly set for non-default 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…

FAQ

Expected behavior

Non-default agents should default to a sibling directory (workspace-newbot/), independent of the main workspace. This keeps routing boundaries unambiguous.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Bug]: agents add default workspace now nests bot inside main workspace, causing TUI routing ambiguity [3 pull requests, 1 comments, 2 participants]