Skip to content

tools.fs.workspaceOnly: false does not propagate to Write/Edit tool operations #31716

@richydeeee

Description

@richydeeee

Bug Description

tools.fs.workspaceOnly: false in config does not allow Write/Edit tools to write outside the workspace root. The setting is accepted by the config schema but never reaches the operation factories that enforce path boundaries.

Steps to Reproduce

  1. Set tools.fs.workspaceOnly: false globally and per-agent in config
  2. Attempt to use the Write tool to write to /tmp/test.txt (or any path outside workspace)
  3. Error: Path escapes workspace root: /tmp

Expected Behavior

Write/Edit tools should allow writing to arbitrary paths when workspaceOnly is false.

Actual Behavior

toRelativePathInRoot() always enforces workspace boundaries regardless of the workspaceOnly config value.

Root Cause Analysis

The config value is correctly resolved by resolveToolFsConfig() and consumed by createToolFsPolicy(). However, in createOpenClawCodingTools() (in subagent-registry-*.js), the workspaceOnly variable is used for the wrapToolWorkspaceRootGuard wrapper but is not passed through to createHostWorkspaceWriteTool() / createHostWorkspaceEditTool(), which in turn call createHostWriteOperations(root) / createHostEditOperations(root) without any opts parameter.

The operation factories unconditionally use toRelativePathInRoot() and writeFileWithinRoot(), which enforce workspace boundaries regardless of config.

The workspaceOnly flag only controls whether wrapToolWorkspaceRootGuard is applied (an outer wrapper), but the inner operations themselves always enforce the boundary — making the outer guard redundant and the config ineffective.

Affected Files (v2026.2.26)

  • dist/subagent-registry-CVXe4Cfs.jscreateHostWriteOperations(root), createHostEditOperations(root), createHostWorkspaceWriteTool(root), createHostWorkspaceEditTool(root)
  • Same pattern in dist/reply-Deht_wOB.js, dist/pi-embedded-CaI0IFWw.js, dist/pi-embedded-CQnl8oWA.js

Suggested Fix

Pass { workspaceOnly } opts through the chain:

  1. createHostWorkspaceWriteTool(root, opts)createHostWriteOperations(root, opts)
  2. When opts.workspaceOnly === false, use raw fs.writeFile/fs.mkdir/fs.readFile instead of writeFileWithinRoot/toRelativePathInRoot

Workaround

Use exec tool with inline shell commands (e.g. echo 'content' > /path/to/file) instead of Write/Edit tools for paths outside workspace.

Environment

  • OpenClaw v2026.2.26 (bc50708)
  • macOS Darwin 25.3.0 (arm64)
  • Node v22.15.0

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