Skip to content

[Bug]: Edit tool parameter alias coverage incomplete - old_text, new_text, file not recognized #52164

@wezuntanglang-create

Description

@wezuntanglang-create

Bug type

Behavior bug (incorrect output/state without crash)

Summary

The edit tool's parameter validation in CLAUDE_PARAM_GROUPS does not cover common parameter name variants that LLMs generate. This causes repeated Missing required parameters errors even when the model provides correct values under slightly different parameter names.

Current accepted aliases:

  • Path: path, file_path
  • Old text: oldText, old_string
  • New text: newText, new_string

Missing aliases that LLMs commonly generate:

  • file (for path) — Claude models frequently use this
  • old_text (for oldText) — snake_case variant
  • new_text (for newText) — snake_case variant

Steps to reproduce

  1. Use any Claude model (tested with claude-opus-4-6, claude-sonnet-4-6)
  2. Have the model call the edit tool repeatedly across sessions
  3. Observe that the model sometimes generates file instead of path, or old_text instead of oldText
  4. These calls fail with Missing required parameters even though the values are correct

Expected behavior

The edit tool should accept file, old_text, and new_text as valid parameter aliases, similar to how it already accepts both camelCase (oldText) and snake_case (old_string) variants.

Actual behavior

[ERROR] [tools] edit failed: Missing required parameters: oldText (oldText or old_string), newText (newText or new_string). Supply correct parameters before retrying.

or:

[ERROR] [tools] edit failed: Missing required parameter: path (path or file_path). Supply correct parameters before retrying.

Root Cause Analysis

The validation logic in assertRequiredParams checks:

for (const group of groups) if (!group.keys.some((key) => {
  if (!(key in record)) return false;
  // ...
}))

When the LLM sends old_text, it doesn't match oldText or old_string, so validation fails.

Suggested Fix

Add missing aliases to CLAUDE_PARAM_GROUPS:

edit: [
-  { keys: ["path", "file_path"], label: "path (path or file_path)" },
+  { keys: ["path", "file_path", "file"], label: "path (path or file_path)" },
-  { keys: ["oldText", "old_string"], label: "oldText (oldText or old_string)" },
+  { keys: ["oldText", "old_string", "old_text"], label: "oldText (oldText or old_string)" },
-  { keys: ["newText", "new_string"], label: "newText (newText or new_string)" },
+  { keys: ["newText", "new_string", "new_text"], label: "newText (newText or new_string)" },
]

Same aliases should be added for read and write tools' path parameter.

OpenClaw version

2026.3.2

Operating system

Windows 10

Install method

npm global

Model

anthropic/claude-opus-4-6, anthropic/claude-sonnet-4-6

Evidence

From session transcripts, the error has been recurring since March 4, 2026 across multiple sessions:

Case 1 — file alias (2026-03-21):

{"name":"edit","arguments":{"file":"C:\\Users\\PC\\Desktop\\openclaw-panel\\main.js","oldText":"...","newText":"..."}}

Result: Missing required parameter: path (path or file_path)

Case 2 — old_text/new_text alias (2026-03-22):

{"name":"edit","arguments":{"file_path":"C:\\Users\\PC\\Desktop\\openclaw-panel\\main.js","old_text":"...","new_text":"..."}}

Result: Missing required parameters: oldText (oldText or old_string), newText (newText or new_string)

Both cases had correct values — only the parameter names were slightly different from what the validator accepts.

Related Issues

Impact and severity

Frequency: Intermittent but recurring (multiple times per day across sessions)
Severity: Blocks edit operations, forces fallback to write tool (data loss risk)
Affected models: Claude Opus 4, Claude Sonnet 4 (likely affects all models)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions