Skip to content

Commit 2f1ed97

Browse files
authored
fix: separate preprocessed tool args (#8111)
1 parent 8f0e597 commit 2f1ed97

File tree

6 files changed

+22
-71
lines changed

6 files changed

+22
-71
lines changed

core/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ interface ToolCallState {
478478
toolCall: ToolCall;
479479
status: ToolStatus;
480480
parsedArgs: any;
481+
processedArgs?: Record<string, any>; // Added in preprocesing step
481482
output?: ContextItem[];
482483
tool?: Tool;
483484
}

gui/src/pages/gui/ToolCallDiv/FunctionSpecificToolCallDiv.tsx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ function FunctionSpecificToolCallDiv({
1414
historyIndex: number;
1515
}) {
1616
const args = toolCallState.parsedArgs;
17+
const processedArgs = toolCallState.processedArgs;
1718
const toolCall = toolCallState.toolCall;
1819

1920
switch (toolCall.function?.name) {
@@ -28,26 +29,26 @@ function FunctionSpecificToolCallDiv({
2829
case BuiltInToolNames.EditExistingFile:
2930
return (
3031
<EditFile
31-
relativeFilePath={args?.filepath ?? ""}
32-
changes={args?.changes ?? ""}
32+
relativeFilePath={processedArgs?.filepath ?? args?.filepath ?? ""}
33+
changes={processedArgs?.changes ?? args?.changes ?? ""}
3334
toolCallId={toolCall.id}
3435
historyIndex={historyIndex}
3536
/>
3637
);
3738
case BuiltInToolNames.SingleFindAndReplace:
3839
const edits: EditOperation[] = [
3940
{
40-
old_string: args?.old_string ?? "",
41-
new_string: args?.new_string ?? "",
42-
replace_all: args?.replace_all,
41+
old_string: processedArgs?.old_string ?? args?.old_string ?? "",
42+
new_string: processedArgs?.new_string ?? args?.new_string ?? "",
43+
replace_all: processedArgs?.replace_all ?? args?.replace_all,
4344
},
4445
];
4546
return (
4647
<FindAndReplaceDisplay
47-
editingFileContents={args?.editingFileContents}
48-
fileUri={args?.fileUri ?? ""}
49-
newFileContents={args?.newFileContents}
50-
relativeFilePath={args?.filepath ?? ""}
48+
editingFileContents={processedArgs?.editingFileContents}
49+
fileUri={processedArgs?.fileUri ?? ""}
50+
newFileContents={processedArgs?.newFileContents}
51+
relativeFilePath={processedArgs?.filepath ?? args?.filepath ?? ""}
5152
edits={edits}
5253
toolCallId={toolCall.id}
5354
historyIndex={historyIndex}
@@ -56,11 +57,11 @@ function FunctionSpecificToolCallDiv({
5657
case BuiltInToolNames.MultiEdit:
5758
return (
5859
<FindAndReplaceDisplay
59-
editingFileContents={args?.editingFileContents}
60-
relativeFilePath={args?.filepath ?? ""}
61-
fileUri={args?.fileUri ?? ""}
62-
newFileContents={args?.newFileContents}
63-
edits={args?.edits ?? []}
60+
editingFileContents={processedArgs?.editingFileContents}
61+
relativeFilePath={processedArgs?.filepath ?? args?.filepath ?? ""}
62+
fileUri={processedArgs?.fileUri ?? ""}
63+
newFileContents={processedArgs?.newFileContents}
64+
edits={processedArgs?.edits ?? args?.edits ?? []}
6465
toolCallId={toolCall.id}
6566
historyIndex={historyIndex}
6667
/>

gui/src/redux/slices/sessionSlice.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ export const sessionSlice = createSlice({
848848
);
849849
}
850850
},
851-
setToolCallArgs: (
851+
setProcessedToolCallArgs: (
852852
state,
853853
action: PayloadAction<{
854854
toolCallId: string;
@@ -860,7 +860,7 @@ export const sessionSlice = createSlice({
860860
action.payload.toolCallId,
861861
);
862862
if (toolCallState) {
863-
toolCallState.parsedArgs = action.payload.newArgs;
863+
toolCallState.processedArgs = action.payload.newArgs;
864864
}
865865
},
866866
cancelToolCall: (
@@ -1038,7 +1038,7 @@ export const {
10381038
acceptToolCall,
10391039
setToolGenerated,
10401040
updateToolCallOutput,
1041-
setToolCallArgs,
1041+
setProcessedToolCallArgs,
10421042
setMode,
10431043
setIsSessionMetadataLoading,
10441044
setAllSessionMetadata,

gui/src/redux/thunks/enhanceParsedArgs.ts

Lines changed: 0 additions & 52 deletions
This file was deleted.

gui/src/redux/thunks/preprocessToolCallArgs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import posthog from "posthog-js";
44
import { IIdeMessenger } from "../../context/IdeMessenger";
55
import {
66
errorToolCall,
7-
setToolCallArgs,
7+
setProcessedToolCallArgs,
88
updateToolCallOutput,
99
} from "../slices/sessionSlice";
1010
import { AppThunkDispatch } from "../store";
@@ -61,7 +61,7 @@ export async function preprocessToolCalls(
6161
);
6262
} else if (preprocessedArgs) {
6363
dispatch(
64-
setToolCallArgs({
64+
setProcessedToolCallArgs({
6565
toolCallId: tcState.toolCallId,
6666
newArgs: preprocessedArgs,
6767
}),

gui/src/util/clientTools/editImpl.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { resolveRelativePathInDir } from "core/util/ideUtils";
22
import { v4 as uuid } from "uuid";
33
import { applyForEditTool } from "../../redux/thunks/handleApplyStateUpdate";
44
import { ClientToolImpl } from "./callClientTool";
5+
56
export const editToolImpl: ClientToolImpl = async (
67
args,
78
toolCallId,

0 commit comments

Comments
 (0)