openclaw - ✅(Solved) Fix [Bug]: Edit tool parameter alias coverage incomplete - old_text, new_text, file not recognized [2 pull requests, 2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#52164Fetched 2026-04-08 01:14:54
View on GitHub
Comments
2
Participants
3
Timeline
8
Reactions
0
Timeline (top)
cross-referenced ×4commented ×2closed ×1locked ×1

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

Error Message

[ERROR] [tools] edit failed: Missing required parameters: oldText (oldText or old_string), newText (newText or new_string). Supply correct parameters before retrying. [ERROR] [tools] edit failed: Missing required parameter: path (path or file_path). Supply correct parameters before retrying. From session transcripts, the error has been recurring since March 4, 2026 across multiple sessions:

  • #44203 — Same error symptom but caused by model completely omitting parameters (different root cause)

Root Cause

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.

Fix Action

Fixed

PR fix notes

PR #52371: Agents: add missing tool parameter aliases

Description (problem / solution / changelog)

Summary

  • Problem: the edit tool compatibility layer exposed file_path, old_string, and new_string, but not the common file, old_text, and new_text aliases.
  • Why it matters: Claude-style tool calls and schema-driven help could omit or reject those spellings, which makes the edit tool less reliable and less discoverable.
  • What changed: added the missing aliases to the file-tool parameter groups, normalized them to the canonical path / oldText / newText fields, exposed them in the wrapped tool schemas, and added targeted regression coverage.
  • What did NOT change (scope boundary): no broader tool-surface refactor, no behavior change outside the existing read/write/edit file-tool compatibility path.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #52164
  • Related #52164

User-visible / Behavior Changes

  • Wrapped file tools now expose file as a path alias in their schema/help surface.
  • Wrapped edit tools now expose and accept old_text / new_text in addition to the existing canonical and Claude-style aliases.

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/tokens handling changed? (No)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (Yes)
  • Data access scope changed? (No)
  • If any Yes, explain risk + mitigation: Existing file tools now accept additional alias spellings for the same canonical parameters. The underlying capabilities and data scope are unchanged; the wrapper normalizes the aliases back to the existing path / oldText / newText fields, and the new regression tests cover both schema exposure and execution.

Repro + Verification

Environment

  • OS: Windows 11
  • Runtime/container: Node v22.20.0 / pnpm 10.23.0
  • Model/provider: N/A
  • Integration/channel (if any): N/A
  • Relevant config (redacted): None

Steps

  1. Call the wrapped edit tool with file, old_text, and new_text, or inspect the wrapped tool schema for those alias properties.
  2. Before this change, the edit compatibility path only exposed and normalized file_path, old_string, and new_string.
  3. After this change, the schema exposes the missing aliases and the wrapper normalizes them to the canonical edit fields before execution.

Expected

  • The wrapped schema/help surface includes the missing aliases.
  • The wrapped edit tool accepts file / old_text / new_text without validation failures.

Actual

  • Verified via regression tests after the patch; the new alias cases pass and the older alias cases still pass.

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios: pnpm build, pnpm check, and pnpm test -- src/agents/pi-tools.create-openclaw-coding-tools.adds-claude-style-aliases-schemas-without-dropping-f.test.ts.
  • Edge cases checked: legacy file_path / old_string / new_string still pass; file works for wrapped read/write schema + execution; file / old_text / new_text work for wrapped edit schema + execution.
  • What you did not verify: I did not capture an interactive CLI help screenshot; verification was done through the wrapped schema and regression tests that drive the same compatibility path.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.

Compatibility / Migration

  • Backward compatible? (Yes)
  • Config/env changes? (No)
  • Migration needed? (No)
  • If yes, exact upgrade steps:

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: revert commit 312ce17f90.
  • Files/config to restore: src/agents/pi-tools.params.ts and src/agents/pi-tools.create-openclaw-coding-tools.adds-claude-style-aliases-schemas-without-dropping-f.test.ts.
  • Known bad symptoms reviewers should watch for: wrapped file tools missing the file alias again, or edit calls with old_text / new_text failing validation.

Risks and Mitigations

  • Risk: expanding file alias coverage to wrapped read/write alongside edit could introduce an untested path mismatch.
  • Mitigation: added regression coverage for wrapped read/write schema + execution with file, and kept normalization scoped to the existing file-tool wrapper path.

Changed files

  • src/agents/pi-tools.create-openclaw-coding-tools.adds-claude-style-aliases-schemas-without-dropping-f.test.ts (modified, +65/-0)
  • src/agents/pi-tools.params.ts (modified, +33/-24)

PR #52516: fix(agents): harden edit tool recovery

Description (problem / solution / changelog)

Summary

This PR cherry-picks the narrow, low-risk parts of the open edit-tool backlog into one cohesive fix.

It does not change edit semantics, add fuzzy matching, add patch mode, or touch sandbox write-path integrity logic.

Instead it hardens the existing exact-match flow in one shared recovery wrapper used by both host and sandbox edit tools, and extends parameter normalization for common alias spellings of the same exact-match operation.

  • include bounded current file contents on exact-match mismatch errors so the agent can retry in the same turn
  • recover post-write throws as success only when the file actually changed
  • normalize LF/CRLF during recovery checks so successful edits are not reported as failures
  • avoid false failures when oldText is a substring of newText
  • keep deletion edits recoverable when newText is the empty string
  • set recovered results to isError: false
  • accept common path/text alias spellings such as file, filePath, old_text, new_text, oldString, and newString

Why this scope

The broader requests in #42221 and #44210 are real, but folding fuzzy matching, anchor mode, retry logic, or patch mode into the existing edit tool would make this much riskier.

This PR stays narrow: make the current tool truthful, recoverable, and tolerant of common alias variants first.

What changed

  • src/agents/pi-tools.host-edit.ts
    • replace the host-only post-write wrapper with a shared edit recovery wrapper
    • snapshot original contents before execution when possible
    • add mismatch-content hints on exact-match failures
    • harden post-write recovery for CRLF, substring, and delete-edit cases
  • src/agents/pi-tools.read.ts
    • apply the same wrapper to sandbox edit tools as well as host edit tools
  • src/agents/pi-tools.params.ts
    • broaden path and edit alias normalization/schema exposure for common variants
  • src/agents/pi-tools.read.host-edit-recovery.test.ts
    • add focused regressions for mismatch hints, CRLF/substrings, unchanged-file false positives, delete edits, and sandbox recovery
  • src/agents/pi-tools.create-openclaw-coding-tools.adds-claude-style-aliases-schemas-without-dropping-f.test.ts
    • add focused coverage for broader alias variants
  • CHANGELOG.md
    • add an Unreleased fix note

Linked issues

  • Closes #27082
  • Closes #45770
  • Closes #52164
  • Related #42221
  • Related #44210
  • Related #44804

Test plan

  • corepack pnpm exec vitest run --maxWorkers=1 src/agents/pi-tools.read.host-edit-recovery.test.ts
  • corepack pnpm exec vitest run --maxWorkers=1 src/agents/pi-tools.create-openclaw-coding-tools.adds-claude-style-aliases-schemas-without-dropping-f.test.ts
  • corepack pnpm exec oxlint src/agents/pi-tools.host-edit.ts src/agents/pi-tools.read.ts src/agents/pi-tools.params.ts src/agents/pi-tools.read.host-edit-recovery.test.ts src/agents/pi-tools.create-openclaw-coding-tools.adds-claude-style-aliases-schemas-without-dropping-f.test.ts

Notes

I accidentally invoked the repo's pnpm test wrapper once while validating this, which routes through scripts/test-parallel.mjs on mb-air. I did not rely on that run and reran the focused files with direct serial Vitest invocations above.

Changed files

  • CHANGELOG.md (modified, +4/-0)
  • src/agents/pi-embedded-subscribe.handlers.tools.test.ts (modified, +60/-0)
  • src/agents/pi-tools.create-openclaw-coding-tools.adds-claude-style-aliases-schemas-without-dropping-f.test.ts (modified, +31/-0)
  • src/agents/pi-tools.host-edit.ts (modified, +150/-45)
  • src/agents/pi-tools.params.ts (modified, +29/-21)
  • src/agents/pi-tools.read.host-edit-recovery.test.ts (modified, +183/-62)
  • src/agents/pi-tools.read.ts (modified, +11/-3)
  • src/agents/tool-mutation.test.ts (modified, +16/-0)
  • src/agents/tool-mutation.ts (modified, +41/-19)

Code Example

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

---

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

---

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

---

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)" },
]

---

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

---

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

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

  • #44203 — Same error symptom but caused by model completely omitting parameters (different root cause)
  • #19085 — Empty string newText rejected (fixed with allowEmpty: true)

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)

extent analysis

Fix Plan

To resolve the issue, update the CLAUDE_PARAM_GROUPS configuration to include the missing aliases for path, oldText, and newText.

  1. Update CLAUDE_PARAM_GROUPS:
    edit: [
      { keys: ["path", "file_path", "file"], label: "path (path or file_path)" },
      { keys: ["oldText", "old_string", "old_text"], label: "oldText (oldText or old_string)" },
      { keys: ["newText", "new_string", "new_text"], label: "newText (newText or new_string)" },
    ]
  2. Apply the same changes to read and write tools: Ensure that the path parameter in these tools also accepts the file alias.
    read: [
      { keys: ["path", "file_path", "file"], label: "path (path or file_path)" },
      // ... other parameters
    ]
    write: [
      { keys: ["path", "file_path", "file"], label: "path (path or file_path)" },
      // ... other parameters
    ]
  3. Verify the update: After applying these changes, test the edit tool with the Claude models using the previously problematic parameter names (file, old_text, new_text) to ensure that the Missing required parameters error no longer occurs.

Verification

To verify that the fix worked:

  • Test the edit tool with different parameter name variants (file instead of path, old_text instead of oldText, new_text instead of newText).
  • Confirm that the edit operations complete successfully without throwing Missing required parameters errors.

Extra Tips

  • Regularly review model-generated parameter names to catch any new variants that might not be covered by the current validation logic.
  • Consider implementing a more flexible validation mechanism that can handle unforeseen parameter name variations, such as using regex patterns or fuzzy matching.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

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.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Bug]: Edit tool parameter alias coverage incomplete - old_text, new_text, file not recognized [2 pull requests, 2 comments, 3 participants]