From 80fd7b2de3d4c99d6b69ed98da6dad736e1ee277 Mon Sep 17 00:00:00 2001 From: Carlos Gutierrez Date: Thu, 5 Feb 2026 18:56:55 -0500 Subject: [PATCH] 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 --- src/services/agent-stream.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/services/agent-stream.ts b/src/services/agent-stream.ts index 886cdf5..b01ea48 100644 --- a/src/services/agent-stream.ts +++ b/src/services/agent-stream.ts @@ -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), }); }