Skip to content

fix(agents): resolve write and edit destinations to the literal path - #126797

Merged
obviyus merged 2 commits into
openclaw:mainfrom
yetval:fix/write-path-literal-destination
Aug 21, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
yetval:fix/write-path-literal-destination

Conversation

@yetval

@yetval yetval commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Preserve Unicode spaces in agent workspace paths. Reads retain their existence-checked Unicode-equivalent fallback; write, edit, list, find, grep, and touched-file projection now operate on the literal path supplied by the model.

What Problem This Solves

resolveToCwd eagerly converted Unicode spaces such as U+202F (narrow no-break space, used in macOS screenshot names) to ASCII spaces before filesystem access. A read of Meeting 9.30<U+202F>AM.md could succeed, while a later write or edit using the same string silently targeted Meeting 9.30 AM.md. That created a phantom sibling or overwrote an existing ASCII-spelled file while reporting the untouched Unicode path.

Root Cause

Unicode equivalence policy lived in the shared lexical path resolver. That resolver is also the destination owner for mutating and search tools, so an optional read convenience silently changed write identity.

Fix

  • Make resolveToCwd purely lexical: @, file URL, home, absolute, and cwd handling only.
  • Delete the now-identical resolveReadPath path.
  • Use the single literal resolver from read callers.
  • Keep Unicode-space, AM/PM, quote, and NFC/NFD alternatives in getReadPathVariants, which runs only after an exact read misses and verifies candidates before choosing one.

Production delta: 8 additions, 17 deletions (net -9). No config, schema, protocol, dependency, or compatibility surface changes.

Evidence

Real createReadTool, createHostWorkspaceWriteTool, and createHostWorkspaceEditTool factories were driven against fresh isolated workspaces with identical inputs on pristine main and the patch. On main, a read-then-write created an ASCII-space copy, and write/edit against U+202F paths overwrote ASCII-space siblings. With the patch, the literal U+202F files changed and ASCII-space siblings retained their original bytes.

Regression coverage:

  • path-utils.test.ts: U+202F resolves to the literal destination, not the ASCII spelling.
  • write.test.ts: writing the U+202F path creates/updates that file and preserves an existing ASCII-space sibling.

Both cases fail with pristine path-utils.ts and pass on this head. The write test is the owner-boundary regression for the reported destructive behavior.

Verification

Exact head: cf42d951815d2f009f7715c61eae5c3ed1dd9253

  • git diff --check origin/main...HEAD
  • pnpm exec oxfmt --check on all five changed files
  • OPENCLAW_OXLINT_SKIP_PREPARE=1 node scripts/run-oxlint.mjs on all five changed files
  • pnpm tsgo
  • pnpm check:test-types
  • node scripts/run-vitest.mjs src/agents/sessions/tools/path-utils.test.ts src/agents/sessions/tools/read.test.ts src/agents/sessions/tools/write.test.ts src/agents/sessions/tools/edit.test.ts src/agents/sessions/tools/edit-diff.test.ts src/agents/agent-tools.workspace-paths.test.ts: 3 shards passed; 170 passed, 2 skipped
  • Exact-head CI: openclaw/ci-gate green
  • Local ClawSweeper (gpt-5.6-terra, high): patch correct; 0 findings; security cleared; no maintainer decision; 0 Rank-up moves

Telegram real-user proof

telegram-e2e-userbot drove a dedicated QA user DM through a fresh gateway built from the exact head. Its deterministic provider issued four sequential Code Mode calls that invoked the real workspace read, write, write, and edit tools, then Telegram delivered UNICODE_SPACE_PATH_SEQUENCE_DONE.

Result: completed: true; 6/6 filesystem assertions passed:

  • U+202F read/write target gained the requested line.
  • No phantom ASCII-space screenshot path was created.
  • U+202F report was rewritten while its ASCII-space sibling retained its original bytes.
  • U+202F todo was edited while its ASCII-space sibling retained its original bytes.

Recorded artifacts: events.ndjson, summary.json, gateway.log, and mock-openai-requests.ndjson. The reusable harness now supports catalog-backed Code Mode workspace sequences; its 42 tests and skill validation pass.

The write and edit tools resolved their destination through resolveToCwd,
which rewrote Unicode spaces (including the U+202F macOS puts before AM/PM
in screenshot names) to ASCII spaces before touching the filesystem. The
read tool stopped doing that in openclaw#121508 and apply_patch never did, so a
read followed by a write of the same path string landed on a different
file: a phantom ASCII-space copy when no sibling existed, or an overwrite
of the ASCII-space sibling when one did, with a receipt naming the
untouched path.

Drop the eager normalization from expandPath so resolveToCwd resolves the
literal path, delete resolveReadPath now that it is identical, and point
its callers at resolveToCwd. Unicode-equivalent matching stays where it is
existence-checked, in getReadPathVariants.

Related: openclaw#119270, openclaw#121508
@clawsweeper

clawsweeper Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Aug 20, 2026
@yetval
yetval marked this pull request as ready for review August 20, 2026 18:50
@clawsweeper clawsweeper Bot added P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 20, 2026
@clawsweeper

clawsweeper Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 21, 2026, 2:29 AM ET / 06:29 UTC.

ClawSweeper review

What this changes

The PR makes agent workspace path resolution preserve literal Unicode-space filenames for writes, edits, listings, and searches while reads retain an existence-checked equivalent-filename fallback.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open: the patch cleanly restores literal filename identity for workspace mutations while retaining verified Unicode-equivalent fallback only for reads. No correctness finding surfaced; merge after the refreshed head has a green exact-head merge result.

Priority: P1
Reviewed head: cf42d951815d2f009f7715c61eae5c3ed1dd9253

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused owner-boundary repair with direct before/after behavior evidence and targeted regression coverage.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR records after-fix isolated-workspace runs through the real read, host write, and host edit tool factories, showing literal files change while ASCII siblings retain their bytes.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR records after-fix isolated-workspace runs through the real read, host write, and host edit tool factories, showing literal files change while ASCII siblings retain their bytes.
Evidence reviewed 7 items Literal destination resolver: The shared resolver now only removes the @ prefix, handles file URLs/home paths, and resolves relative paths; it no longer rewrites Unicode spaces.
Read fallback remains read-only: Reads attempt the literal resolved path first and enumerate equivalent variants only after ENOENT/ENOTDIR, preserving the intended convenience without changing mutation identity.
Mutation and sibling call paths: Write, edit, edit preview, find, grep, and ls all consume the same lexical resolver; host workspace wrappers instantiate those tool factories rather than adding a competing resolver.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw --help

Result: PASS (completed)

pnpm openclaw --help
runner@runnervm76f27:/tmp/clawsweeper-live-proof-126797-3w1RWp/target$ pnpm openclaw --help
$ node scripts/run-node.mjs --help
pnpm openclaw --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 96.93 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

[tsdown-build] invocation 2/2 finished in 13.1s
[plugin-control-plane-loads] verified 35 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 4662ms (slowest: built plugin control-plane loads 3924ms)

OpenClaw 2026.8.1 (cf42d95) — All your chats, one OpenClaw.

Usage: openclaw [options] [command]

Options:
  --container ‹name›   Run the CLI inside a running Podman/Docker container named ‹name› (default: env OPENCLAW_CONTAINER)
  --dev                Dev profile: isolate state under ~/.openclaw-dev, default gateway port 19001, and shift derived ports (browser/canvas)
  -h, --help           Display help for command
  --log-level ‹level›  Global log level override for file + console 
… output truncated …

Assertions:

  • PASS expect_output: Usage:

How this fits together

Agent workspace tools turn model-supplied paths into filesystem targets. Read operations can recover from a verified filename spelling mismatch, whereas write and edit operations must preserve the requested target identity.

flowchart LR
  A[Model-supplied path] --> B[Lexical workspace resolution]
  B --> C{Tool operation}
  C -->|Read| D[Exact access then verified variants]
  C -->|Write or edit| E[Literal filesystem target]
  D --> F[Read result]
  E --> G[Workspace change]
Loading

Before merge

  • Resolve merge risk (P1) - GitHub reports the branch as behind and required checks are still running; merge only after exact-head checks pass against the refreshed merge result.
  • Complete next step (P2) - No repair is indicated; a maintainer should wait for exact-head CI and the refreshed merge result before landing.
Agent review details

Security

None.

PR surface

Source -9, Tests +19. Total +10 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 8 17 -9
Tests 2 26 7 +19
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 34 24 +10

Review metrics

Metric Value Why it matters
Production versus test LOC production -9, tests +19 The fix removes shared normalization behavior while adding focused resolver and write-boundary regression coverage.

Stored data model

Persistent data-model change detected: serialized state: src/agents/sessions/tools/path-utils.ts, serialized state: src/agents/sessions/tools/write.test.ts, unknown-data-model-change: src/agents/sessions/tools/path-utils.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain one literal resolver for all destination-bearing tools, keep equivalent-name probing behind read access failure, and merge once the current merge result is green.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain one literal resolver for all destination-bearing tools, keep equivalent-name probing behind read access failure, and merge once the current merge result is green.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: a U+202F path reaches the shared resolver used by write and edit, while the added isolated-workspace regression distinguishes it from an ASCII-space sibling; the reviewer did not execute the contributor branch.

Is this the best way to solve the issue?

Yes. Moving Unicode-equivalent matching out of the shared resolver and retaining it only after an exact read miss is the narrowest owner-boundary fix.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 3b295b374cab.

Labels

Label changes:

  • add P1: Without this repair, an agent write or edit can silently target an ASCII-space sibling instead of the requested workspace file.
  • remove P0: Current review triage priority is P1, so this older priority label is no longer current.

Label justifications:

  • P1: Without this repair, an agent write or edit can silently target an ASCII-space sibling instead of the requested workspace file.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR records after-fix isolated-workspace runs through the real read, host write, and host edit tool factories, showing literal files change while ASCII siblings retain their bytes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR records after-fix isolated-workspace runs through the real read, host write, and host edit tool factories, showing literal files change while ASCII siblings retain their bytes.

Evidence

What I checked:

  • Literal destination resolver: The shared resolver now only removes the @ prefix, handles file URLs/home paths, and resolves relative paths; it no longer rewrites Unicode spaces. (src/agents/sessions/tools/path-utils.ts:37, cf42d951815d)
  • Read fallback remains read-only: Reads attempt the literal resolved path first and enumerate equivalent variants only after ENOENT/ENOTDIR, preserving the intended convenience without changing mutation identity. (src/agents/sessions/tools/read.ts:250, cf42d951815d)
  • Mutation and sibling call paths: Write, edit, edit preview, find, grep, and ls all consume the same lexical resolver; host workspace wrappers instantiate those tool factories rather than adding a competing resolver. (src/agents/sessions/tools/write.ts:540, cf42d951815d)
  • Behavioral regression coverage: The new write test creates both Unicode-space and ASCII-space siblings and verifies the literal path changes without overwriting the ASCII sibling; resolver coverage separately asserts distinct destinations. (src/agents/sessions/tools/write.test.ts:181, cf42d951815d)
  • Existing read contract: Current read tests prove exact Unicode spellings win and equivalent filenames are considered only as fallback candidates, matching the separation retained by this patch. (src/agents/sessions/tools/read.test.ts:371, cf42d951815d)
  • Feature provenance: The relevant read-safety change dates to the merged read-path commit, whose message explicitly introduced unambiguous Unicode-equivalent reads; this PR addresses the remaining mutation identity boundary. (src/agents/sessions/tools/path-utils.ts:59, 5295f2578e1b)

Likely related people:

  • obviyus: Authored the merged Unicode-equivalent read-safety work and the current branch's merge update touching the same resolver surface. (role: introduced related read-path behavior and recent area contributor; confidence: high; commits: 5295f2578e1b, cf42d951815d; files: src/agents/sessions/tools/path-utils.ts, src/agents/sessions/tools/read.ts)
  • steipete: Authored the recent Windows home-path compatibility update in the same session path resolver. (role: recent adjacent contributor; confidence: medium; commits: f798f9999b4d; files: src/agents/sessions/tools/path-utils.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-20T18:57:33.476Z sha d177032 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. and removed P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. labels Aug 21, 2026
@obviyus
obviyus merged commit 8ec5ae0 into openclaw:main Aug 21, 2026
265 checks passed
vincentkoc added a commit that referenced this pull request Aug 21, 2026
* origin/main: (107 commits)
  perf(test): speed up Agents page observation polling (#127063)
  fix(android): explicitly target notification intents (#127055)
  fix(agents): preserve literal Unicode-space paths (#126797)
  fix(agents): distinguish review routing from enforcement (#126216)
  fix(ui): associate steering work by target run (#126997)
  fix(ui): collapse completed pre-steer work
  fix(codex): preserve steering transcript order
  fix(gateway): retain Bonjour cleanup on startup failure (#127062)
  fix(release): require concrete validation retry groups (#127012)
  fix(file-transfer): expose directory page tokens (#127051)
  perf: trim setup detection worker imports (#127053)
  fix(onboard): make --auth-choice help match the accepted set (#127030)
  fix(gateway): await cron exit watcher drain (#126963)
  fix(telegram): preserve direct-topic self-history (#127050)
  fix: dismiss sidebar session menu tooltip (#127044)
  perf(test): speed up pairing access polling (#127047)
  perf(cli): remove ineffective dynamic imports (#127046)
  fix(gateway): recover credential-file accounts after secrets reload (#126999)
  fix(gateway): restore scheduler-owned Gateway context (#126640)
  fix(macos): keep first-run onboarding visible after Gateway changes (#127038)
  ...

# Conflicts:
#	.github/workflows/full-release-validation.yml
#	test/scripts/full-release-validation-at-sha.test.ts
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 22, 2026
Preserve model-supplied filename identity for mutations while keeping existence-checked Unicode-equivalent fallback for reads.

Co-authored-by: yetval <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants