fix(agents): allow empty edit replacement text

This commit is contained in:
github-actions[bot]
2026-02-23 13:35:14 -05:00
parent e40ee3c2c7
commit 3c21fc30d3
2 changed files with 26 additions and 0 deletions

View File

@@ -353,6 +353,7 @@ export const CLAUDE_PARAM_GROUPS = {
{
keys: ["newText", "new_string"],
label: "newText (newText or new_string)",
allowEmpty: true,
},
],
} as const;

View File

@@ -60,6 +60,31 @@ describe("workspace path resolution", () => {
});
});
it("allows deletion edits with empty newText", async () => {
await withTempDir("openclaw-ws-", async (workspaceDir) => {
await withTempDir("openclaw-cwd-", async (otherDir) => {
const testFile = "delete.txt";
await fs.writeFile(path.join(workspaceDir, testFile), "hello world", "utf8");
const cwdSpy = vi.spyOn(process, "cwd").mockReturnValue(otherDir);
try {
const tools = createOpenClawCodingTools({ workspaceDir });
const { editTool } = expectReadWriteEditTools(tools);
await editTool.execute("ws-edit-delete", {
path: testFile,
oldText: " world",
newText: "",
});
expect(await fs.readFile(path.join(workspaceDir, testFile), "utf8")).toBe("hello");
} finally {
cwdSpy.mockRestore();
}
});
});
});
it("defaults exec cwd to workspaceDir when workdir is omitted", async () => {
await withTempDir("openclaw-ws-", async (workspaceDir) => {
const tools = createOpenClawCodingTools({