openclaw - ✅(Solved) Fix write tool rejects empty/whitespace-only content as "missing required parameter" [1 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#68636Fetched 2026-04-19 15:09:12
View on GitHub
Comments
2
Participants
3
Timeline
3
Reactions
0
Timeline (top)
commented ×2cross-referenced ×1

The write tool's parameter validator rejects content: "" and any whitespace-only value ("\n", " ", "\t") with the error "Missing required parameter: content (received: path, content=<empty-string>). Supply correct parameters before retrying."

This treats a legitimate operation (writing an empty or whitespace-only file — e.g. initializing an empty JSONL append-log, creating a sentinel file, or truncating an existing file) as a missing-parameter error. Because the error text tells the model to "Supply correct parameters before retrying", the model retries with another empty-ish value, gets the same error, and the turn ends with a user-visible "Write failed" banner without the file ever being created.

Error Message

write(path: "/tmp/empty.jsonl", content: "") → Error: Missing required parameter: content (received: path, content=<empty-string>). Supply correct parameters before retrying.

write(path: "/tmp/empty.jsonl", content: "\n") → Error: Missing required parameter: content (received: path, content=<empty-string>). Supply correct parameters before retrying.

Root Cause

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

export const REQUIRED_PARAM_GROUPS = {
  write: [
    { keys: ["path"], label: "path" },
    { keys: ["content"], label: "content" },  // no allowEmpty
  ],
  ...
};

assertRequiredParams checks value.trim().length > 0 unless the group has allowEmpty: true. The intent of that check is to catch a missing content param, but it also catches legitimate empty/whitespace-only content.

Fix Action

Fixed

PR fix notes

PR #68637: fix(pi-tools): allow empty/whitespace-only content in write tool

Description (problem / solution / changelog)

Closes #68636

Summary

The write tool's parameter validator currently rejects content: "" and any whitespace-only value with the error "Missing required parameter: content (received: path, content=<empty-string>)". This treats a legitimate operation (initializing an empty JSONL append-log, creating a sentinel file, or truncating an existing file) as a missing-parameter error, and because the error hints "Supply correct parameters before retrying" the model retries with the same or another empty value, gets the same error, and the turn ends with a user-visible Write failed banner without the file ever being created.

See the linked issue for a live reproduction with three model-driven retries in 39s.

Fix

Single change in src/agents/pi-tools.params.ts: add allowEmpty: true to the content group of REQUIRED_PARAM_GROUPS.write.

   write: [
     { keys: ["path"], label: "path" },
-    { keys: ["content"], label: "content" },
+    { keys: ["content"], label: "content", allowEmpty: true },
   ],

This is a one-flag change that uses the existing allowEmpty mechanism. The validator still rejects:

  • content key entirely missing
  • content as null or undefined
  • content as a non-string type (object, array)
  • path missing

It now accepts:

  • content: "" (empty write)
  • content: "\n" (newline-only, e.g. JSONL append-log initialization)
  • content: " \t\n " (all-whitespace)

Tests

Added a dedicated describe("REQUIRED_PARAM_GROUPS.write") block in src/agents/pi-tools.params.test.ts with six cases: three accepting (empty, newline, all-whitespace), three still-rejecting (missing content, non-string content, missing path). All pass locally.

Rationale

The intent of the .trim().length > 0 check is to catch content being missing (the model forgot the parameter), but it also catches the legitimate case where the model is intentionally writing an empty file. The existing allowEmpty flag exists for exactly this distinction. The write tool's natural semantics (create/truncate) should accept empty content.

Changed files

  • src/agents/pi-tools.params.test.ts (modified, +73/-0)
  • src/agents/pi-tools.params.ts (modified, +7/-1)

Code Example

write(path: "/tmp/empty.jsonl", content: "")
Error: Missing required parameter: content (received: path, content=<empty-string>). Supply correct parameters before retrying.

write(path: "/tmp/empty.jsonl", content: "\n")
Error: Missing required parameter: content (received: path, content=<empty-string>). Supply correct parameters before retrying.

---

11:55:08 [tools] write failed: Missing required parameter: content (received: path, content=<empty-string>). Supply correct parameters before retrying. raw_params={"path":"/home/frank/.openclaw/workspace/knowledge/career/frank/interview-prep-progress.jsonl","content":""}
11:55:24 [tools] write failed: ... raw_params={"...","content":""}
11:55:47 [tools] write failed: ... raw_params={"...","content":"\n"}
11:59:50 ⚠️ ✍️ Write: `to ~/.openclaw/workspace/knowledge/career/frank/interview-prep-progress.jsonl (1 chars)` failed

---

export const REQUIRED_PARAM_GROUPS = {
  write: [
    { keys: ["path"], label: "path" },
    { keys: ["content"], label: "content" },  // no allowEmpty
  ],
  ...
};

---

{ keys: ["content"], label: "content", allowEmpty: true }
RAW_BUFFERClick to expand / collapse

Summary

The write tool's parameter validator rejects content: "" and any whitespace-only value ("\n", " ", "\t") with the error "Missing required parameter: content (received: path, content=<empty-string>). Supply correct parameters before retrying."

This treats a legitimate operation (writing an empty or whitespace-only file — e.g. initializing an empty JSONL append-log, creating a sentinel file, or truncating an existing file) as a missing-parameter error. Because the error text tells the model to "Supply correct parameters before retrying", the model retries with another empty-ish value, gets the same error, and the turn ends with a user-visible "Write failed" banner without the file ever being created.

Reproduce

write(path: "/tmp/empty.jsonl", content: "")
  → Error: Missing required parameter: content (received: path, content=<empty-string>). Supply correct parameters before retrying.

write(path: "/tmp/empty.jsonl", content: "\n")
  → Error: Missing required parameter: content (received: path, content=<empty-string>). Supply correct parameters before retrying.

Observed live (2026-04-18, three LLM-driven retries over 39 seconds, all with the same error, ending with a failed turn):

11:55:08 [tools] write failed: Missing required parameter: content (received: path, content=<empty-string>). Supply correct parameters before retrying. raw_params={"path":"/home/frank/.openclaw/workspace/knowledge/career/frank/interview-prep-progress.jsonl","content":""}
11:55:24 [tools] write failed: ... raw_params={"...","content":""}
11:55:47 [tools] write failed: ... raw_params={"...","content":"\n"}
11:59:50 ⚠️ ✍️ Write: `to ~/.openclaw/workspace/knowledge/career/frank/interview-prep-progress.jsonl (1 chars)` failed

Root cause

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

export const REQUIRED_PARAM_GROUPS = {
  write: [
    { keys: ["path"], label: "path" },
    { keys: ["content"], label: "content" },  // no allowEmpty
  ],
  ...
};

assertRequiredParams checks value.trim().length > 0 unless the group has allowEmpty: true. The intent of that check is to catch a missing content param, but it also catches legitimate empty/whitespace-only content.

Fix (see linked PR)

Add allowEmpty: true to the content group:

{ keys: ["content"], label: "content", allowEmpty: true }

This accepts "", "\n", " " as valid. A completely missing content key, a null, or a non-string value still throws (covered by tests). The same pattern is already used elsewhere; this just applies it to the write tool where empty/truncate semantics are expected.

extent analysis

TL;DR

The issue can be fixed by adding allowEmpty: true to the content parameter group in src/agents/pi-tools.params.ts to allow empty or whitespace-only values.

Guidance

  • Review the REQUIRED_PARAM_GROUPS configuration in src/agents/pi-tools.params.ts to ensure that the allowEmpty property is set correctly for the content parameter.
  • Update the content group to include allowEmpty: true to permit empty or whitespace-only values.
  • Verify that the assertRequiredParams function is correctly handling the updated configuration.
  • Test the write tool with various input values, including empty strings and whitespace-only strings, to ensure that it behaves as expected.

Example

export const REQUIRED_PARAM_GROUPS = {
  write: [
    { keys: ["path"], label: "path" },
    { keys: ["content"], label: "content", allowEmpty: true },
  ],
  ...
};

Notes

This fix assumes that the intent is to allow empty or whitespace-only values for the content parameter, while still rejecting completely missing or invalid values.

Recommendation

Apply the workaround by adding allowEmpty: true to the content parameter group, as this will correctly handle empty or whitespace-only values while maintaining the existing validation logic.

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 write tool rejects empty/whitespace-only content as "missing required parameter" [1 pull requests, 2 comments, 3 participants]