Elffuss BraidHub

kikocis/continue public

removed need for idemessenger and added necessary logging locations
Changeset8d995509008e19b8868865686fc66e0fa99f02aca827f9fc022b701b21efe806
Authoradarshramiyer <adarsh.r.iyer@gmail.com> · 2025-07-02 19:30 -07:00
Committeradarshramiyer <adarsh.r.iyer@gmail.com> · 2025-07-02 19:30 -07:00
Parents73fcda533e5b

Browse the files at this changeset

6 files changed

modified core/tools/callTool.ts +0 −22
@@ -1,6 +1,5 @@
11 import { ContextItem, Tool, ToolCall, ToolExtras } from "..";
22 import { MCPManagerSingleton } from "../context/mcp/MCPManagerSingleton";
3-import { DataLogger } from "../data/log";
43 import { canParseUrl } from "../util/url";
54 import { BuiltInToolNames } from "./builtIn";
65
@@ -173,25 +172,6 @@
173172 }
174173 }
175174
176-function logToolUsage(
177- toolCall: ToolCall,
178- args: Record<string, any>,
179- contextItems: ContextItem[],
180- success: boolean,
181-) {
182- void DataLogger.getInstance().logDevData({
183- name: "toolUsage",
184- data: {
185- toolCallId: toolCall.id,
186- functionName: toolCall.function.name,
187- functionArgs: toolCall.function.arguments,
188- toolCallArgs: args,
189- output: contextItems,
190- succeeded: success,
191- },
192- });
193-}
194-
195175 // Handles calls for core/non-client tools
196176 // Returns an error context item if the tool call fails
197177 // Note: Edit tool is handled on client
@@ -213,7 +193,6 @@
213193 item.icon = tool.faviconUrl;
214194 });
215195 }
216- logToolUsage(toolCall, args, contextItems, true);
217196 return {
218197 contextItems,
219198 errorMessage: undefined,
@@ -223,7 +202,6 @@
223202 if (e instanceof Error) {
224203 errorMessage = e.message;
225204 }
226- logToolUsage(toolCall, {}, [], false);
227205 return {
228206 contextItems: [],
229207 errorMessage,
modified gui/src/hooks/ParallelListeners.tsx +9 −0
@@ -28,10 +28,12 @@
2828 import { exitEdit } from "../redux/thunks/edit";
2929 import { streamResponseAfterToolCall } from "../redux/thunks/streamResponseAfterToolCall";
3030
31+import { store } from "../redux/store";
3132 import { cancelStream } from "../redux/thunks/cancelStream";
3233 import { refreshSessionMetadata } from "../redux/thunks/session";
3334 import { streamResponseThunk } from "../redux/thunks/streamResponse";
3435 import { updateFileSymbolsFromHistory } from "../redux/thunks/updateFileSymbols";
36+import { findToolCall, logToolUsage } from "../redux/util";
3537 import {
3638 setDocumentStylesFromLocalStorage,
3739 setDocumentStylesFromTheme,
@@ -257,6 +259,13 @@
257259 dispatch(updateEditStateApplyState(state));
258260
259261 if (state.status === "closed") {
262+ const toolCallState = findToolCall(
263+ store.getState().session.history,
264+ state.toolCallId!,
265+ );
266+ if (toolCallState) {
267+ logToolUsage(toolCallState, true, true);
268+ }
260269 void dispatch(exitEdit({}));
261270 }
262271 } else {
modified gui/src/redux/thunks/callCurrentTool.ts +2 −4
@@ -101,8 +101,6 @@
101101 ],
102102 }),
103103 );
104-
105- logToolUsage(toolCallState, false, extra.ideMessenger, output);
106104 } else if (output?.length) {
107105 dispatch(
108106 updateToolCallOutput({
@@ -110,8 +108,6 @@
110108 contextItems: output,
111109 }),
112110 );
113-
114- logToolUsage(toolCallState, true, extra.ideMessenger, output);
115111 }
116112
117113 // Because we don't have access to use hooks, we check `allowAnonymousTelemetry`
@@ -127,12 +123,14 @@
127123
128124 if (streamResponse) {
129125 if (errorMessage) {
126+ logToolUsage(toolCallState, false, false, output);
130127 dispatch(
131128 errorToolCall({
132129 toolCallId,
133130 }),
134131 );
135132 } else {
133+ logToolUsage(toolCallState, true, true, output);
136134 dispatch(
137135 acceptToolCall({
138136 toolCallId,
modified gui/src/redux/util/index.ts +12 −7
@@ -1,6 +1,5 @@
11 import { ContextItem, ToolCallState } from "core";
2-import { safeParseToolCallArgs } from "core/tools/parseArgs";
3-import { IIdeMessenger } from "../../context/IdeMessenger";
2+import { DataLogger } from "core/data/log";
43 import { ChatHistoryItemWithMessageId } from "../slices/sessionSlice";
54 import { RootState } from "../store";
65
@@ -32,17 +31,23 @@
3231
3332 export function logToolUsage(
3433 toolCallState: ToolCallState,
34+ accepted: boolean,
3535 success: boolean,
36- messenger: IIdeMessenger,
3736 finalOutput?: ContextItem[],
3837 ) {
39- messenger.post("devdata/log", {
38+ void DataLogger.getInstance().logDevData({
4039 name: "toolUsage",
4140 data: {
4241 toolCallId: toolCallState.toolCallId,
43- functionName: toolCallState.toolCall?.function?.name,
44- functionArgs: toolCallState.toolCall?.function?.arguments,
45- toolCallArgs: safeParseToolCallArgs(toolCallState.toolCall),
42+
43+ functionName:
44+ toolCallState.tool?.function?.name ||
45+ toolCallState.toolCall.function.name,
46+
47+ functionParams: toolCallState.tool?.function.parameters,
48+
49+ toolCallArgs: toolCallState.toolCall.function.arguments,
50+ accepted: accepted,
4651 output: finalOutput || toolCallState.output || [],
4752 succeeded: success,
4853 },
modified packages/config-yaml/src/schemas/data/toolUsage/index.ts +3 −2
@@ -4,8 +4,9 @@
44 export const toolUsageEventAllSchema = baseDevDataAllSchema.extend({
55 toolCallId: z.string(),
66 functionName: z.string(),
7- functionArgs: z.string(),
8- toolCallArgs: z.any(),
7+ functionParams: z.record(z.string(), z.any()).optional(),
8+ toolCallArgs: z.string(),
9+ accepted: z.boolean(),
910 succeeded: z.boolean(),
1011 output: z.array(z.any()).optional(),
1112 });
modified packages/config-yaml/src/schemas/data/toolUsage/v0.2.0.ts +3 −2
@@ -12,15 +12,16 @@
1212 // tool-usage-specific
1313 toolCallId: true,
1414 functionName: true,
15- functionArgs: true,
15+ functionParams: true,
1616 toolCallArgs: true,
17+ accepted: true,
1718 succeeded: true,
1819 output: true,
1920 });
2021
2122 export const toolUsageEventSchema_0_2_0_noCode =
2223 toolUsageEventSchema_0_2_0.omit({
23- functionArgs: true,
24+ functionParams: true,
2425 toolCallArgs: true,
2526 output: true,
2627 });