#22778: fix: allow empty string for edit tool newText parameter
agents
size: XS
Cluster:
TUI and Tool Execution Fixes
## Summary
Allows the edit tool to accept an empty string for `newText`/`new_string`, enabling text deletion (replacing a block with nothing).
## Problem
When a model calls the edit tool with `newText: ""` to delete a text block, `assertRequiredParams` rejects it with "Missing required parameter: newText" because empty strings are treated as missing by default.
## Fix
Added `allowEmpty: true` to the `newText` parameter group in `src/agents/pi-tools.read.ts`. The `allowEmpty` flag is already supported by the validation logic (line 510) and used elsewhere in the codebase.
**1 file changed**, 1 property added.
Fixes #19085
## Local Validation
- Verified `allowEmpty` is already used in 6+ other locations
- Confirmed the validation logic at line 510 handles the flag correctly
## Scope
Single property addition in `src/agents/pi-tools.read.ts`.
## AI Assistance
Claude Code assisted with locating the parameter definition and validating the existing `allowEmpty` support.
## Author
**Miloud Belarebia** — [@miloudbelarebia](https://github.com/miloudbelarebia)
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds `allowEmpty: true` to the `newText` parameter in the edit tool configuration, enabling text deletion by allowing empty strings as valid input. The validation logic at line 511 already handles this flag correctly, and the pattern is consistently used throughout the codebase.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- Single property addition that enables an already-supported feature. The validation logic at line 511 correctly handles the `allowEmpty` flag, and the pattern is used consistently in 6+ other locations in the codebase. No breaking changes or edge cases identified.
- No files require special attention
<sub>Last reviewed commit: 2a1be57</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#19125: fix(edit): allow empty string newText for line deletion
by aldoeliacim · 2026-02-17
90.2%
#23381: fix(tools): allow empty newText in edit tool for text deletion
by SidQin-cyber · 2026-02-22
88.8%
#4964: fix: strip null-valued optional parameters from tool calls for prov...
by umut-polat · 2026-01-30
72.3%
#6502: fix(tui): skip empty text for tool-only assistant turns
by douvy · 2026-02-01
72.1%
#21695: fix(edit): include line numbers in duplicate match errors
by lbo728 · 2026-02-20
71.7%
#14470: fix(agents): unescape newlines in write and edit tool content
by VintLin · 2026-02-12
71.6%
#18464: fix(web-search): handle empty query gracefully instead of crashing
by Clawborn · 2026-02-16
70.1%
#16733: fix(ui): avoid injected newlines when tool output is hidden
by jp117 · 2026-02-15
70.0%
#19094: Fix empty tool_call_id and function names in provider transcript pa...
by yxshee · 2026-02-17
69.8%
#10097: fix: add empty thinking blocks to tool call messages when thinking is…
by cyxer000 · 2026-02-06
69.8%