openclaw - โœ…(Solved) Fix [Bug]: edit tool 100% failure in 2026.3.30 โ€” CLAUDE_PARAM_GROUPS.edit validation rejects edits[] array format [1 pull requests, 3 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#57973โ€ขFetched 2026-04-08 01:55:27
View on GitHub
Comments
3
Participants
3
Timeline
4
Reactions
1
Timeline (top)
commented ร—3cross-referenced ร—1

The edit tool fails with Missing required parameters: oldText alias, newText alias on every invocation since gateway restart on OpenClaw 2026.3.30.

Root Cause

CLAUDE_PARAM_GROUPS.edit in pi-tools.params.ts expects oldText and newText at the top level of the params object. However, the current tool schema wraps these inside an edits[] array:

{
  "edits": [{"oldText": "...", "newText": "..."}],
  "file": "path/to/file"
}

assertRequiredParams() scans the top-level record and does not find oldText/newText (they are nested in edits[0]), so it rejects every call.

Fix Action

Fixed

PR fix notes

PR #58018: fix(tools): hoist oldText/newText from edits[] array in param normalization

Description (problem / solution / changelog)

Summary

  • Problem: The edit tool fails with Missing required parameters: oldText alias, newText alias on every invocation since 2026.3.30
  • Why it matters: All file editing via the edit tool is broken โ€” agents must fall back to sed or write. Cron jobs and automated workflows are accumulating errors.
  • What changed: normalizeToolParams() now hoists oldText/newText (and all aliases) from edits[0] to the top level before validation
  • What did NOT change: Top-level params still take precedence. The edits[] array is preserved in the normalized output. No schema changes.

Change Type (select all)

  • Bug fix

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 #57973
  • This PR fixes a bug or regression

Root Cause / Regression History (if applicable)

  • Root cause: CLAUDE_PARAM_GROUPS.edit expects oldText/newText at the top level of the params record, but the current tool schema wraps them inside an edits[] array. assertRequiredParams() scans only the top-level record.
  • Missing detection / guardrail: No test covered the edits[] array input format
  • Prior context: The schema appears to have changed to use edits[] format, but normalizeToolParams was not updated to handle it

Regression Test Plan (if applicable)

  • pi-tools.params.edits-array.test.ts โ€” 6 tests covering:
    • Hoisting from edits[0] to top level
    • Top-level params take precedence over hoisted values
    • Alias keys (old_string, new_string) hoisted and normalized
    • Empty edits[] array handled safely
    • assertRequiredParams passes after hoisting
    • Missing params in edits[] still fails validation

Security Impact

  • This change touches auth, secrets, network, or sandboxing

Evidence

  • pnpm test -- src/agents/pi-tools.params.edits-array.test.ts โ€” 6/6 pass
  • oxlint --type-aware โ€” 0 warnings, 0 errors
  • All pre-commit hooks pass (oxlint, conflict markers, host env policy, webhook auth, pairing scope)

Human Verification

  • I have tested this change locally
  • I understand the code I am submitting

Changed files

  • apps/macos/Sources/OpenClaw/HostEnvSecurityPolicy.generated.swift (modified, +1/-0)
  • src/agents/pi-tools.params.edits-array.test.ts (added, +78/-0)
  • src/agents/pi-tools.params.ts (modified, +27/-0)

Code Example

{
  "edits": [{"oldText": "...", "newText": "..."}],
  "file": "path/to/file"
}

---

2026-03-31T03:06:14.390+08:00 tools: edit failed stack:
[tools] edit failed: Missing required parameters: oldText alias, newText alias.

2026-03-31T03:31:35.754+08:00 tools: edit failed stack:
[tools] edit failed: Missing required parameters: oldText alias, newText alias.

2026-03-31T04:18:55.538+08:00 tools: edit failed stack:
[tools] edit failed: Missing required parameters: oldText alias, newText alias.

2026-03-31T06:04:19.606+08:00 tools: edit failed stack:
[tools] edit failed: Missing required parameters: oldText alias, newText alias.
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Summary

The edit tool fails with Missing required parameters: oldText alias, newText alias on every invocation since gateway restart on OpenClaw 2026.3.30.

Root cause analysis

CLAUDE_PARAM_GROUPS.edit in pi-tools.params.ts expects oldText and newText at the top level of the params object. However, the current tool schema wraps these inside an edits[] array:

{
  "edits": [{"oldText": "...", "newText": "..."}],
  "file": "path/to/file"
}

assertRequiredParams() scans the top-level record and does not find oldText/newText (they are nested in edits[0]), so it rejects every call.

Steps to reproduce

  1. Start OpenClaw gateway with version 2026.3.30
  2. Call edit tool with any valid parameters
  3. Every call returns: Missing required parameters: oldText alias, newText alias. Supply correct parameters before retrying.

Evidence from logs

2026-03-31T03:06:14.390+08:00 tools: edit failed stack:
[tools] edit failed: Missing required parameters: oldText alias, newText alias.

2026-03-31T03:31:35.754+08:00 tools: edit failed stack:
[tools] edit failed: Missing required parameters: oldText alias, newText alias.

2026-03-31T04:18:55.538+08:00 tools: edit failed stack:
[tools] edit failed: Missing required parameters: oldText alias, newText alias.

2026-03-31T06:04:19.606+08:00 tools: edit failed stack:
[tools] edit failed: Missing required parameters: oldText alias, newText alias.

All sessions affected โ€” cron, heartbeat, and interactive.

Impact

  • All file editing via edit tool is broken โ€” agents must fall back to sed or write
  • Cron jobs (daily-review, daily-handoff, daily-audit) accumulating consecutiveErrors
  • Automated workflows that rely on edit are degraded

Suggested fix

Either:

  1. Update CLAUDE_PARAM_GROUPS.edit to handle the edits[] array format (check inside array elements)
  2. Or adjust the tool schema to accept top-level oldText/newText alongside the edits[] format

Environment

  • OpenClaw version: 2026.3.30
  • Model: claude-opus-4.6 (custom proxy)
  • Gateway started: 2026-03-30T18:04 (UTC+8)

extent analysis

Fix Plan

To resolve the issue, we will update CLAUDE_PARAM_GROUPS.edit to handle the edits[] array format. Here are the steps:

  • Update pi-tools.params.ts to modify the CLAUDE_PARAM_GROUPS.edit function to check for oldText and newText inside the edits[] array.
  • Add a check to ensure that edits[] is not empty and contains the required oldText and newText properties.

Example code:

// pi-tools.params.ts
CLAUDE_PARAM_GROUPS.edit = {
  // ... other properties ...
  validate: (params: any) => {
    if (params.edits && params.edits.length > 0) {
      const edit = params.edits[0];
      if (!edit.oldText || !edit.newText) {
        throw new Error('Missing required parameters: oldText alias, newText alias');
      }
    } else {
      throw new Error('Missing required parameters: oldText alias, newText alias');
    }
  }
}

Alternatively, you can also adjust the tool schema to accept top-level oldText/newText alongside the edits[] format.

Verification

To verify that the fix worked, restart the OpenClaw gateway and test the edit tool with a valid request. The tool should no longer return the Missing required parameters error.

Example test request:

{
  "edits": [{"oldText": "old text", "newText": "new text"}],
  "file": "path/to/file"
}

If the fix is successful, the edit tool should complete without errors.

Extra Tips

  • Make sure to test the updated CLAUDE_PARAM_GROUPS.edit function with different input scenarios to ensure it handles all possible cases.
  • Consider adding additional logging or monitoring to detect similar issues in the future.
  • If you choose to adjust the tool schema, ensure that it is backwards compatible with existing clients and workflows.

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โ€ฆ

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 100% failure in 2026.3.30 โ€” CLAUDE_PARAM_GROUPS.edit validation rejects edits[] array format [1 pull requests, 3 comments, 3 participants]