Elffuss BraidHub

kikocis/continue public

moved logToolUsage to outside thunk
Changeset707bce180eb3803c8bc96e52208397e9dc0315fdee21b3e6a27989867991764a
Authoradarshramiyer <adarsh.r.iyer@gmail.com> · 2025-07-01 10:26 -07:00
Committeradarshramiyer <adarsh.r.iyer@gmail.com> · 2025-07-01 10:26 -07:00
Parents0b91103abe86

Browse the files at this changeset

5 files changed

modified extensions/vscode/package-lock.json +0 −0

Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.

modified gui/package-lock.json +0 −0

Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.

modified gui/src/redux/thunks/callCurrentTool.ts +3 −18
@@ -1,7 +1,6 @@
11 import { createAsyncThunk, unwrapResult } from "@reduxjs/toolkit";
22 import { ContextItem } from "core";
33 import { CLIENT_TOOLS_IMPLS } from "core/tools/builtIn";
4-import { safeParseToolCallArgs } from "core/tools/parseArgs";
54 import posthog from "posthog-js";
65 import { callClientTool } from "../../util/clientTools/callClientTool";
76 import { selectCurrentToolCall } from "../selectors/selectCurrentToolCall";
@@ -13,6 +12,7 @@
1312 updateToolCallOutput,
1413 } from "../slices/sessionSlice";
1514 import { ThunkApiType } from "../store";
15+import { logToolUsage } from "../util";
1616 import { streamResponseAfterToolCall } from "./streamResponseAfterToolCall";
1717
1818 export const callCurrentTool = createAsyncThunk<void, undefined, ThunkApiType>(
@@ -29,21 +29,6 @@
2929 return;
3030 }
3131
32- const logToolUsage = (success: boolean, finalOutput?: ContextItem[]) => {
33- extra.ideMessenger.post("devdata/log", {
34- name: "toolUsage",
35- data: {
36- toolCallId: toolCallState.toolCallId,
37- functionName: toolCallState.toolCall?.function?.name,
38- functionArgs: toolCallState.toolCall?.function?.arguments,
39- toolCallArgs: safeParseToolCallArgs(toolCallState.toolCall),
40- parsedArgs: toolCallState.parsedArgs,
41- output: finalOutput || toolCallState.output || [],
42- succeeded: success,
43- },
44- });
45- };
46-
4732 const selectedChatModel = selectSelectedChatModel(state);
4833
4934 if (!selectedChatModel) {
@@ -122,7 +107,7 @@
122107 }),
123108 );
124109
125- logToolUsage(false, output);
110+ logToolUsage(toolCallState, false, extra.ideMessenger, output);
126111 } else if (output?.length) {
127112 dispatch(
128113 updateToolCallOutput({
@@ -131,7 +116,7 @@
131116 }),
132117 );
133118
134- logToolUsage(true, output);
119+ logToolUsage(toolCallState, true, extra.ideMessenger, output);
135120 }
136121
137122 // Because we don't have access to use hooks, we check `allowAnonymousTelemetry`
modified gui/src/redux/util/index.ts +23 −1
@@ -1,4 +1,6 @@
1-import { ToolCallState } from "core";
1+import { ContextItem, ToolCallState } from "core";
2+import { safeParseToolCallArgs } from "core/tools/parseArgs";
3+import { IIdeMessenger } from "../../context/IdeMessenger";
24 import { RootState } from "../store";
35
46 export function findCurrentToolCall(
@@ -15,3 +17,23 @@
1517 (item) => item.toolCallState?.toolCallId === toolCallId,
1618 )?.toolCallState;
1719 }
20+
21+export function logToolUsage(
22+ toolCallState: ToolCallState,
23+ success: boolean,
24+ messenger: IIdeMessenger,
25+ finalOutput?: ContextItem[],
26+) {
27+ messenger.post("devdata/log", {
28+ name: "toolUsage",
29+ data: {
30+ toolCallId: toolCallState.toolCallId,
31+ functionName: toolCallState.toolCall?.function?.name,
32+ functionArgs: toolCallState.toolCall?.function?.arguments,
33+ toolCallArgs: safeParseToolCallArgs(toolCallState.toolCall),
34+ parsedArgs: toolCallState.parsedArgs,
35+ output: finalOutput || toolCallState.output || [],
36+ succeeded: success,
37+ },
38+ });
39+}
modified packages/config-yaml/package-lock.json +0 −0

Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.