fix: rollback now correctly extracts file path from tool arguments

The rollback system was failing because it looked for `file_path`
(snake_case) but the write/edit tools use `filePath` (camelCase).

Now checks both formats when extracting the file path for rollback tracking.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-05 18:56:55 -05:00
parent f8cde24d87
commit 80fd7b2de3

View File

@@ -373,10 +373,12 @@ const executeTool = async (
const rollbackType = ROLLBACK_CAPABLE_TOOLS[toolCall.name];
let originalState: { filePath: string; content: string } | null = null;
// Extract file path - tools use filePath (camelCase), not file_path
const toolFilePath = (toolCall.arguments.filePath ?? toolCall.arguments.file_path) as string | undefined;
if (rollbackType && (rollbackType === "file_edit" || rollbackType === "file_delete")) {
const filePath = toolCall.arguments.file_path as string | undefined;
if (filePath) {
originalState = await captureFileState(filePath);
if (toolFilePath) {
originalState = await captureFileState(toolFilePath);
}
}
@@ -386,11 +388,10 @@ const executeTool = async (
// Record action for rollback if successful and modifying
if (result.success && rollbackType) {
const filePath = toolCall.arguments.file_path as string | undefined;
state.executionControl.recordAction({
type: rollbackType,
description: `${toolCall.name}: ${filePath ?? "unknown file"}`,
originalState: originalState ?? (filePath ? { filePath, content: "" } : undefined),
description: `${toolCall.name}: ${toolFilePath ?? "unknown file"}`,
originalState: originalState ?? (toolFilePath ? { filePath: toolFilePath, content: "" } : undefined),
});
}