Changesets · Branches · Tags · Compare
| Changeset | 451a09bc47259e694b1105fa17fdcbefecc5787bf983672896f2dcb123ed5a37 |
|---|---|
| Author | adarshramiyer <adarsh.r.iyer@gmail.com> · 2025-07-01 10:47 -07:00 |
| Committer | adarshramiyer <adarsh.r.iyer@gmail.com> · 2025-07-01 10:47 -07:00 |
| Parents | 707bce180eb3 |
5 files changed
modified core/core.ts +0 −6
| @@ -821,12 +821,6 @@ | ||
| 821 | 821 | codeBaseIndexer: this.codeBaseIndexer, |
| 822 | 822 | }); |
| 823 | 823 | |
| 824 | - this.messenger.send("toolCallCompleted", { | |
| 825 | - toolCallId: toolCall.id, | |
| 826 | - contextItems: result.contextItems, | |
| 827 | - succeeded: !result.errorMessage, | |
| 828 | - }); | |
| 829 | - | |
| 830 | 824 | return result; |
| 831 | 825 | } |
| 832 | 826 |
modified core/protocol/webview.ts +0 −4
| @@ -43,9 +43,5 @@ | ||
| 43 | 43 | "jetbrains/setColors": [Record<string, string | null | undefined>, void]; |
| 44 | 44 | sessionUpdate: [{ sessionInfo: ControlPlaneSessionInfo | undefined }, void]; |
| 45 | 45 | toolCallPartialOutput: [{ toolCallId: string; contextItems: any[] }, void]; |
| 46 | - toolCallCompleted: [ | |
| 47 | - { toolCallId: string; contextItems: any[]; succeeded: boolean }, | |
| 48 | - void, | |
| 49 | - ]; | |
| 50 | 46 | freeTrialExceeded: [undefined, void]; |
| 51 | 47 | }; |
modified core/tools/callTool.ts +23 −0
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | import { ContextItem, Tool, ToolCall, ToolExtras } from ".."; |
| 2 | 2 | import { MCPManagerSingleton } from "../context/mcp/MCPManagerSingleton"; |
| 3 | +import { DataLogger } from "../data/log"; | |
| 3 | 4 | import { canParseUrl } from "../util/url"; |
| 4 | 5 | import { BuiltInToolNames } from "./builtIn"; |
| 5 | 6 | |
| @@ -169,6 +170,26 @@ | ||
| 169 | 170 | } |
| 170 | 171 | } |
| 171 | 172 | |
| 173 | +function logToolUsage( | |
| 174 | + toolCall: ToolCall, | |
| 175 | + args: Record<string, any>, | |
| 176 | + contextItems: ContextItem[], | |
| 177 | + success: boolean, | |
| 178 | +) { | |
| 179 | + void DataLogger.getInstance().logDevData({ | |
| 180 | + name: "toolUsage", | |
| 181 | + data: { | |
| 182 | + toolCallId: toolCall.id, | |
| 183 | + functionName: toolCall.function.name, | |
| 184 | + functionArgs: toolCall.function.arguments, | |
| 185 | + toolCallArgs: args, | |
| 186 | + parsedArgs: args, | |
| 187 | + output: contextItems, | |
| 188 | + succeeded: success, | |
| 189 | + }, | |
| 190 | + }); | |
| 191 | +} | |
| 192 | + | |
| 172 | 193 | // Handles calls for core/non-client tools |
| 173 | 194 | // Returns an error context item if the tool call fails |
| 174 | 195 | // Note: Edit tool is handled on client |
| @@ -190,6 +211,7 @@ | ||
| 190 | 211 | item.icon = tool.faviconUrl; |
| 191 | 212 | }); |
| 192 | 213 | } |
| 214 | + logToolUsage(toolCall, args, contextItems, true); | |
| 193 | 215 | return { |
| 194 | 216 | contextItems, |
| 195 | 217 | errorMessage: undefined, |
| @@ -199,6 +221,7 @@ | ||
| 199 | 221 | if (e instanceof Error) { |
| 200 | 222 | errorMessage = e.message; |
| 201 | 223 | } |
| 224 | + logToolUsage(toolCall, {}, [], false); | |
| 202 | 225 | return { |
| 203 | 226 | contextItems: [], |
| 204 | 227 | errorMessage, |
modified gui/src/hooks/ParallelListeners.tsx +0 −29
| @@ -27,13 +27,10 @@ | ||
| 27 | 27 | import { exitEdit } from "../redux/thunks/edit"; |
| 28 | 28 | import { streamResponseAfterToolCall } from "../redux/thunks/streamResponseAfterToolCall"; |
| 29 | 29 | |
| 30 | -import { safeParseToolCallArgs } from "core/tools/parseArgs"; | |
| 31 | -import { store } from "../redux/store"; | |
| 32 | 30 | import { cancelStream } from "../redux/thunks/cancelStream"; |
| 33 | 31 | import { refreshSessionMetadata } from "../redux/thunks/session"; |
| 34 | 32 | import { streamResponseThunk } from "../redux/thunks/streamResponse"; |
| 35 | 33 | import { updateFileSymbolsFromHistory } from "../redux/thunks/updateFileSymbols"; |
| 36 | -import { findToolCall } from "../redux/util"; | |
| 37 | 34 | import { |
| 38 | 35 | setDocumentStylesFromLocalStorage, |
| 39 | 36 | setDocumentStylesFromTheme, |
| @@ -288,32 +285,6 @@ | ||
| 288 | 285 | [currentToolCallApplyState, history], |
| 289 | 286 | ); |
| 290 | 287 | |
| 291 | - useWebviewListener( | |
| 292 | - "toolCallCompleted", | |
| 293 | - async (data) => { | |
| 294 | - const state = store.getState(); | |
| 295 | - const toolCallState = findToolCall( | |
| 296 | - state.session.history, | |
| 297 | - data.toolCallId, | |
| 298 | - ); | |
| 299 | - if (toolCallState) { | |
| 300 | - ideMessenger.post("devdata/log", { | |
| 301 | - name: "toolUsage", | |
| 302 | - data: { | |
| 303 | - toolCallId: toolCallState.toolCallId, | |
| 304 | - functionName: toolCallState.toolCall.function.name, | |
| 305 | - functionArgs: toolCallState.toolCall.function.arguments, | |
| 306 | - toolCallArgs: safeParseToolCallArgs(toolCallState.toolCall), | |
| 307 | - parsedArgs: toolCallState.parsedArgs, | |
| 308 | - output: data.contextItems, | |
| 309 | - succeeded: data.succeeded, | |
| 310 | - }, | |
| 311 | - }); | |
| 312 | - } | |
| 313 | - }, | |
| 314 | - [ideMessenger, store], | |
| 315 | - ); | |
| 316 | - | |
| 317 | 288 | useEffect(() => { |
| 318 | 289 | if (!isInEdit) { |
| 319 | 290 | dispatch(setLastNonEditSessionEmpty(history.length === 0)); |
modified gui/src/redux/thunks/callCurrentTool.ts +2 −0
| @@ -107,6 +107,7 @@ | ||
| 107 | 107 | }), |
| 108 | 108 | ); |
| 109 | 109 | |
| 110 | + console.log("logging Tool from callCurrentTool"); | |
| 110 | 111 | logToolUsage(toolCallState, false, extra.ideMessenger, output); |
| 111 | 112 | } else if (output?.length) { |
| 112 | 113 | dispatch( |
| @@ -116,6 +117,7 @@ | ||
| 116 | 117 | }), |
| 117 | 118 | ); |
| 118 | 119 | |
| 120 | + console.log("logging Tool from callCurrentTool"); | |
| 119 | 121 | logToolUsage(toolCallState, true, extra.ideMessenger, output); |
| 120 | 122 | } |
| 121 | 123 |