Skip to content

Edit/Write tools restricted to workspace root even with tools.fs.workspaceOnly=false #29612

@miykael

Description

@miykael

Description

After updating to 2026.2.26, the edit and write tools reject paths outside the workspace directory even when tools.fs.workspaceOnly is set to false in the config.

Expected behavior

Per the type definition in types.tools.d.ts:

export type FsToolsConfig = {
    /**
     * Restrict filesystem tools (read/write/edit/apply_patch) to the agent workspace directory.
     * Default: false (unrestricted, matches legacy behavior).
     */
    workspaceOnly?: boolean;
};

With workspaceOnly: false, edit/write should allow paths outside the workspace. The read tool works correctly outside the workspace.

Actual behavior

  • edit returns "File not found: /home/claw/obsidian/file.md" (file exists, read works fine on it)
  • write returns "Path escapes workspace root: /home/claw"

Root cause (traced in source)

The workspaceOnly flag correctly controls the outer wrapToolWorkspaceRootGuard wrapper, but the inner operations (createHostEditOperations(root) and createHostWriteOperations(root)) unconditionally call toRelativePathInRoot(root, absolutePath) which rejects any path outside the workspace root.

Relevant code in reply-Duq0R59W.js:

// Outer guard is conditionally applied (correct):
return [workspaceOnly ? wrapToolWorkspaceRootGuard(wrapped, workspaceRoot) : wrapped];

// But inner operations always restrict (bug):
function createHostEditOperations(root) {
    return {
        readFile: async (absolutePath) => {
            const opened = await openFileWithinRoot({
                rootDir: root,
                relativePath: toRelativePathInRoot(root, absolutePath) // <-- always enforces root
            });

Use case

Agent workspace is at ~/.openclaw/workspace, but an Obsidian vault at /home/claw/obsidian/ (separate git repo) needs to be edited via the edit tool. This worked in previous versions.

Config

{
  "tools": {
    "fs": {
      "workspaceOnly": false
    }
  },
  "agents": {
    "defaults": {
      "workspace": "/home/claw/.openclaw/workspace"
    }
  }
}

Environment

  • OpenClaw version: 2026.2.26
  • OS: Linux (Ubuntu)
  • Install method: npm

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions