Skip to content

Edit tool does not expand ~ (tilde) in file paths #30669

@Chrisr6records

Description

@Chrisr6records

Problem

The Edit tool (used for precise file edits) does not expand ~ in file_path/path parameters. This causes File not found errors when targeting files like ~/.codex/config.toml.

Other tools handle this fine:

  • exec — shell expands ~ naturally
  • Read — resolves ~ to $HOME

The Edit tool bypasses shell expansion, so ~ is treated as a literal character.

Impact

  • Agents have a SOUL.md rule saying "never use ~ in tool calls" but it's not sticky across sessions — the error recurs regularly
  • LLMs naturally generate ~ paths since it's standard Unix convention
  • Every occurrence wastes a tool call (Edit fails → fallback to sed or retry with absolute path)

Expected behavior

Edit should resolve ~ to $HOME (or the agent's home directory) before attempting the file operation, consistent with Read and other file-access tools.

Reproduction

Edit(file_path="~/.codex/config.toml", old_string="foo", new_string="bar")
→ Error: File not found: ~/.codex/config.toml

Works fine with absolute path:

Edit(file_path="/home/user/.codex/config.toml", old_string="foo", new_string="bar")
→ Success

Environment

  • OpenClaw v2026.2.19-2
  • Ubuntu 24.04 (WSL2)

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