openclaw - ✅(Solved) Fix [Bug]: write 工具 content 參數驗證失敗 - "content: must have required property 'content'" [1 pull requests, 1 comments, 2 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#55528Fetched 2026-04-08 01:38:29
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Timeline (top)
labeled ×2commented ×1cross-referenced ×1

write 工具無法創建文件,報錯 "content: must have required property 'content'",即使已提供 content 參數。

Error Message

error error error error error error error error Gateway service update failed: Error: schtasks create failed: ���: �s���Q�ڡC Gateway service update failed: Error: schtasks create failed: ���: �s���Q�ڡC

Root Cause

write 工具無法創建文件,報錯 "content: must have required property 'content'",即使已提供 content 參數。

PR fix notes

PR #57716: Agents/tools: fix empty required array bug in tool schema alias handling

Description (problem / solution / changelog)

AI-Assisted

  • This PR was created with assistance from Claude
  • Testing: Unit tests updated and passing (25/26), scoped tests validate the fix
  • I understand the code changes and have verified they work correctly

Summary

Fixes #44203, #37645, #57551, #55528, #54975, #54366

This PR fixes a critical bug where tool schema required arrays were being incorrectly emptied when a dding parameter aliases (e.g., file_path as alias for path). The addClaudeParamAliasesToSchema f unction was removing original parameter names from required without preserving them, causing LLMs to receive schemas with no required parameters.

Changelog Entry

  • Agents/tools: fix empty required array bug in tool schema alias handling. Fixes #44203, #37645.

Problem

The addClaudeParamAliasesToSchema function was removing original parameter names (like path, oldT ext, newText) from the required array but not adding their aliases (like file_path, old_string , new_string). This caused:

  1. LLMs received schemas with empty or incomplete required arrays
  2. Models didn't know which parameters were actually required
  3. Tool calls failed validation with "Missing required parameters" errors
  4. Users experienced 100% failure rate for edit tool and other file operations

Related Issues

This bug has been reported multiple times with various symptoms:

  • #44203 - Original bug report: Edit tool fails with "Missing required parameters"
  • #37645 - Root cause analysis: patchToolSchemaForClaudeCompatibility empties required[] with ex act fix suggestion
  • #57551 - Kimi infinite retry loop consuming tokens due to repeated validation failures
  • #55528 - Write tool content parameter validation failure
  • #54975 - All tools receive empty {} arguments (closed but same root cause)
  • #54366 - kimi-coding/k2p5 model tool parameters empty object

Error Messages Users See

[tools] edit failed: Missing required parameters: path alias, oldText alias, newText alias. Supply cor rect parameters before retrying. [tools] read failed: Missing required parameter: path alias. Supply c orrect parameters before retrying.

Solution

  1. Preserve canonical keys in required array: The addClaudeParamAliasesToSchema function no lo nger modifies the required array. Original parameter names (e.g., path) remain in required, whil e aliases (e.g., file_path) are only added to properties.

  2. Add optional flag to RequiredParamGroup: Allows marking parameter groups as optional for ru ntime validation, supporting edit tool's dual-mode operation (single replacement vs. multi-replacement ).

  3. Cross-field validation for edit tool: Added explicit validation to ensure edit tool receives ei ther edits array or both oldText and newText.

Changes

  • src/agents/pi-tools.params.ts:

    • Add optional field to RequiredParamGroup type
    • Mark oldText/newText as optional in CLAUDE_PARAM_GROUPS.edit
    • Stop modifying required array in addClaudeParamAliasesToSchema
    • Update assertRequiredParams to skip optional groups
    • Add cross-field validation for edit tool
  • src/agents/pi-tools.create-openclaw-coding-tools.adds-claude-style-aliases-schemas-without-dropping .test.ts:

    • Update test assertion to verify path remains in required

Changed files

  • src/agents/pi-tools.create-openclaw-coding-tools.adds-claude-style-aliases-schemas-without-dropping.test.ts (modified, +3/-1)
  • src/agents/pi-tools.params.ts (modified, +45/-8)
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

write 工具無法創建文件,報錯 "content: must have required property 'content'",即使已提供 content 參數。

環境信息

可能原因

類似 PR #7451 修復的 read 工具 file_path 問題,write 工具的 content 參數可能也有類似的別名/驗證問題。

臨時解決方案

使用手動創建文件

Steps to reproduce

  1. 運行 OpenClaw 最新版本
  2. 嘗試使用 write 工具創建文件
  3. 提供 content 和 file_path 參數
  4. 報錯:Validation failed for tool "write": content: must have required property 'content'

Expected behavior

應該成功創建文件

Actual behavior

報錯無法創建文件

OpenClaw version

OpenClaw Version: v2026.3.24 - 發生時間:2025-03-27 升級後

Operating system

  • OS: Windows 11 家用版 -

Install method

npm

Model

kimi 2.5

Provider / routing chain

類似 PR #7451 修復的 read 工具 file_path 問題,write 工具的 content 參數可能也有類似的別名/驗證問題。

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

上午1:43:28 error [tools] read failed: Missing required parameter: path alias. Supply correct parameters before retrying. [tools] read failed: Missing required parameter: path alias. Supply correct parameters before retrying. 上午1:43:32 error [tools] read failed: Missing required parameter: path alias. Supply correct parameters before retrying. [tools] read failed: Missing required parameter: path alias. Supply correct parameters before retrying. 上午1:43:38 error [tools] read failed: Missing required parameter: path alias. Supply correct parameters before retrying. [tools] read failed: Missing required parameter: path alias. Supply correct parameters before retrying. 上午1:43:44 error [tools] edit failed: Missing required parameters: path alias, oldText alias, newText alias. Supply correct parameters before retrying. 上午2:31:09 error [tools] read failed: Missing required parameter: path alias. Supply correct parameters before retrying. [tools] read failed: Missing required parameter: path alias. Supply correct parameters before retrying. 上午2:31:14 error [tools] read failed: Missing required parameter: path alias. Supply correct parameters before retrying. [tools] read failed: Missing required parameter: path alias. Supply correct parameters before retrying. 上午9:53:18 error Gateway restart timed out after 60s waiting for health checks. Gateway restart timed out after 60s waiting for health checks. 上午11:16:42 error Gateway service update failed: Error: schtasks create failed: ���: �s���Q�ڡC Gateway service update failed: Error: schtasks create failed: ���: �s���Q�ڡC

extent analysis

Fix Plan

The fix involves updating the write tool to correctly validate and use the content parameter.

  • Update the write tool's validation logic to check for the content parameter correctly.
  • Ensure the content parameter is properly passed to the file creation function.

Example code changes:

// Update validation logic
const validateContent = (content) => {
  if (!content || typeof content !== 'string') {
    throw new Error('Content must be a non-empty string');
  }
  return content;
};

// Update file creation function
const createFile = (filePath, content) => {
  const validatedContent = validateContent(content);
  // Create file with validated content
  fs.writeFileSync(filePath, validatedContent);
};

Verification

To verify the fix, follow these steps:

  • Run the updated write tool with the content and file_path parameters.
  • Check if the file is created successfully with the provided content.
  • Test with different input scenarios to ensure the validation logic works correctly.

Extra Tips

  • Review the read tool's validation logic to ensure consistency with the write tool's changes.
  • Consider adding additional error handling and logging to improve debugging and issue tracking.

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

應該成功創建文件

Still need to ship something?

×6

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

Back to top recommendations

TRENDING