Repository navigation
fix(agents): resolve write and edit destinations to the literal path - #126797
Conversation
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
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 21, 2026, 2:29 AM ET / 06:29 UTC. ClawSweeper reviewWhat this changesThe 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 readinessKeep 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 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherAgent 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]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -9, Tests +19. Total +10 across 5 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest 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. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
* 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
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]>
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
resolveToCwdeagerly converted Unicode spaces such as U+202F (narrow no-break space, used in macOS screenshot names) to ASCII spaces before filesystem access. A read ofMeeting 9.30<U+202F>AM.mdcould succeed, while a later write or edit using the same string silently targetedMeeting 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
resolveToCwdpurely lexical:@, file URL, home, absolute, and cwd handling only.resolveReadPathpath.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, andcreateHostWorkspaceEditToolfactories 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.tsand pass on this head. The write test is the owner-boundary regression for the reported destructive behavior.Verification
Exact head:
cf42d951815d2f009f7715c61eae5c3ed1dd9253git diff --check origin/main...HEADpnpm exec oxfmt --checkon all five changed filesOPENCLAW_OXLINT_SKIP_PREPARE=1 node scripts/run-oxlint.mjson all five changed filespnpm tsgopnpm check:test-typesnode 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 skippedopenclaw/ci-gategreengpt-5.6-terra, high): patch correct; 0 findings; security cleared; no maintainer decision; 0 Rank-up movesTelegram real-user proof
telegram-e2e-userbotdrove 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 workspaceread,write,write, andedittools, then Telegram deliveredUNICODE_SPACE_PATH_SEQUENCE_DONE.Result:
completed: true; 6/6 filesystem assertions passed:Recorded artifacts:
events.ndjson,summary.json,gateway.log, andmock-openai-requests.ndjson. The reusable harness now supports catalog-backed Code Mode workspace sequences; its 42 tests and skill validation pass.