Skip to content

[Bug]: edit tool: confusing error on whitespace mismatch, needs better surfacing #66915

Description

@ifearghal

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

When the edit tool's oldText parameter doesn't match the file exactly — due to whitespace differences (trailing spaces, tabs, line ending differences) — the edit fails and OpenClaw posts an opaque user-visible notification to the chat:

⚠️ 📝 Edit: in /path/to/file.md failed
Now

This is confusing for users who don't understand what the error means, and there's no clear path to recovery.

Steps to reproduce

  1. Read a file using the read tool
  2. Make an edit that slightly changes whitespace (add/remove trailing spaces, change line endings)
  3. Attempt to use the edit tool with the original oldText
  4. Observe the error message shown to the user

Observed Behavior

The user sees:

⚠️ 📝 Edit: in /path/to/file.md failed
Now

Expected behavior

When edit fails, the error surfaced to the user should be clear and actionable — something like:

edit failed: text not found (possibly due to whitespace changes). write tool used instead.

Additionally, a permanent solution should allow disabling edit entirely via config, using write exclusively for agents or self-hosted deployments that prioritize reliability over precise editing.

Actual behavior

The user sees:

⚠️ 📝 Edit: in /path/to/file.md failed
Now

OpenClaw version

2026.4.14 (observed) — likely affects all recent versions

Operating system

AlmaLinux 10.1 (self-hosted Linux)

Install method

No response

Model

Any model — the issue is tool-level, not model-level

Provider / routing chain

Any provider — the issue affects all channels (Signal, Discord, web UI)

Additional provider/model setup details

No response

Logs, screenshots, and evidence

⚠️ 📝 Edit: in /path/to/file.md failed
Now
 "Now" button is non-functional and provides no context.

Impact and severity

  • Poor observability — users cannot tell what failed or why
  • Degrades user experience with cryptic, non-actionable errors
  • Affects self-hosted deployments where users expect polished, clear feedback
  • Forces reliance on the write workaround, which overwrites entire files
  • Severity: Medium

Additional information

Workaround: Use the write tool instead of edit for dynamic files. This works but write overwrites the entire file rather than patching a section, which is riskier in multi-agent scenarios.

Suggested fixes:

  1. Immediate: Better error messaging when edit fails — surface the actual cause clearly
  2. Permanent: Provide a config option to disable edit and use write exclusively, eliminating the failure mode at the source

Code pointers (for maintainers):

  • Tool error surfacing logic likely in the OpenClaw gateway tool execution layer
  • edit tool exact-match logic in the tool implementation
  • Consider normalizing whitespace before match attempt, or returning typed errors (TEXT_NOT_FOUND, PERMISSION_DENIED, etc.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.bugSomething isn't workingbug:behaviorIncorrect behavior without a crashclawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.staleMarked as stale due to inactivity

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions